albertosottile / darkdetect

Detect OS Dark Mode from Python
Other
178 stars 18 forks source link

add XFCE support #39

Open maharvey opened 11 months ago

maharvey commented 11 months ago

XFCE does not use gsettings and was always returning 'Light'. Added xfconf-query which is supported by XFCE. (You can set gsettings from the command line to force the GTK theme to update, and then darkdetect works as expected, but that is not the default in the XFCE settings app and most users probably don't do it.)

Added a desktop detection function, and added XFCE support to theme() and listener().

Since 'Light' was confusing when detection fails for non-GTK desktops (internal errors are swallowed), an 'Unknown' theme type is added so that application knows detection was unsuccessful and can choose an appropriate response.

Added a 'watch' option to __main__.py to demonstrate the listener.

This commit also provides a framework to support other desktop environments, like KDE. Those are left as an exercise to someone who knows what to do and is able to test it. The dbus PR looked promising but the dbus method is not working for me (I commented in that PR) and I don't know enough about dbus to debug it, so you still need the gsettings / xfconf-query fallback.

Tested on Manjaro Linux running XFCE 4.18.1