blob: 9cdf2d9b20e6e011687adc1e76405a6eea801810 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
(setq
modus-themes-mode-line '(accented borderless padded)
modus-themes-region '(bg-only)
)
(use-package dbus)
(defun mf/set-theme-from-dbus-value (value)
"Set the appropiate theme according to the color-scheme setting value."
(message "value is %s" value)
(if (equal value '1)
(progn (message "Switch to dark theme")
(modus-themes-load-vivendi))
(progn (message "Switch to light theme")
(modus-themes-load-operandi))))
(defun mf/color-scheme-changed (path var value)
"DBus handler to detect when the color-scheme has changed."
(when (and (string-equal path "org.freedesktop.appearance")
(string-equal var "color-scheme"))
(mf/set-theme-from-dbus-value (car value))
))
;; Register for future changes
(dbus-register-signal
:session "org.freedesktop.portal.Desktop"
"/org/freedesktop/portal/desktop" "org.freedesktop.portal.Settings"
"SettingChanged"
#'mf/color-scheme-changed)
;; Request the current color-scheme
(dbus-call-method-asynchronously
:session "org.freedesktop.portal.Desktop"
"/org/freedesktop/portal/desktop" "org.freedesktop.portal.Settings"
"Read"
(lambda (value) (mf/set-theme-from-dbus-value (caar value)))
"org.freedesktop.appearance"
"color-scheme"
)
|