reddit / emacs

Following xdg-desktop-portal theme preference on Gnome 42.

discursive_moth · 2022-03-07 01:01
discursive_moth · 2022-03-07 01:02
My code (taken mostly from [here](https://github.com/hlissner/doom-emacs/issues/6027) (use-package dbus :unless is-windows-p :straight (:type built-in) :demand t :init (defun theme-switcher (value) (pcase value ;; No Preference (0 (shell-command "gsettings set org.gnome.desktop.interface gtk-theme \"adw-gtk3\"") (load-theme 'modus-operandi t)) ;; Prefers dark (1 (shell-command "gsettings set org.gnome.desktop.interface gtk-theme \"adw-gtk3-dark\"") (load-theme 'modus-vivendi t)) ;; Prefers light. Not currently used by Gnome (2 (shell-command "gsettings set org.gnome.desktop.interface gtk-theme \"adw-gtk3\"") (load-theme 'modus-operandi t)) (_ (message "Invalid key value")))) (defun handler (value) (theme-switcher (car (car value)))) (defun signal-handler (namespace key value) (if (and (string-equal namespace "org.freedesktop.appearance") (string-equal key "color-scheme")) (theme-switcher (car value)))) :config (dbus-call-method-asynchronously :session "org.freedesktop.portal.Desktop" "/org/freedesktop/portal/desktop" "org.freedesktop.portal.Settings" "Read" #'handler "org.freedesktop.appearance" "color-scheme") (dbus-register-signal :session "org.freedesktop.portal.Desktop" "/org/freedesktop/portal/desktop" "org.freedesktop.portal.Settings" "SettingChanged" #'signal-handler))
super-linux-nerd · 2022-03-07 03:23
This is awesome!
gp2b5go59c · 2022-03-07 06:52
Note that your solution globally sets the gtk theme, this is highly undesirable. In an ideal world emacs allows you to set the GtkSetting gtk-application-prefer-dark-mode setting, but emacs devs live in an alternative reality where gtk themes are supported features of gtk but gtksettigns isnt, see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=53457.
esrse · 2022-03-07 09:38
Wow this is a good idea
_viz_ · 2022-03-07 13:40
If I havent misread the thread, the conclusion was "Lets add it when a stable release is out."
chipwheel · 2022-03-07 16:35
this is wonderful! you have dotfiles repo? would love to take a look
discursive_moth · 2022-03-07 23:28
[Here's](https://gitlab.com/__tpb/tpbmacs) my emacs config, though it's nothing special and kind of disorganized. Everything else is stock Fedora 36 right now except for the [gtk3 theme](https://github.com/lassekongo83/adw-gtk3), which attempts to match gtk4 Adwaita.
discursive_moth · 2022-03-07 23:31
Yes, hopefully this gets added to Emacs at some point.