Closed l0drex closed 1 year ago
I know supporting more desktop environemnts than just Gnome would be very desirable, but sadly I simply do not have the capacity to implement such features at the moment (In particular mantaining the implementation).
It looks like it could be a rather simple implementation that follows a mix of the macOS/Windows and Gnome implementation. If you want to provide an implementation I would be more than happy to give pointers on how to get started with the project (and of course merge it :) )
There is now a way to detect the active theme variant on many Linux desktops
Would this also entail Gnome i.e. could this replace the current implementation for it?
I would love to do that, but I need a starting point: where is the current implementation for Gnome, what do I need to change etc
Would this also entail Gnome i.e. could this replace the current implementation for it?
Yes, Gnome has implemented it
I would love to do that, but I need a starting point: where is the current implementation for Gnome, what do I need to change etc
The Gnome implementation is located at: https://github.com/weisJ/auto-dark-mode/tree/master/linux/gnome
I'd suggest to add the new implementation as a separate module as linux/xdg-desktop-portal
.
Then the old Gnome implementation could be phased out sometime later (I kinda like the idea of simply replacing the guessing mechanism of the gnome implementation with the xdg-desktop mechanism, as this would still allow for manually choosing what Gnome theme corresponds to what Idea theme).
For a starting point you can simply follow the layout of the gnome
:
`linux/xdg-desktop-portal/build.gradle.kts
and adjust the compiler and linker flags.linux/xdg-desktop-portal
to settings.gradle.kts
xdg-desktop-portal
as a dependency in https://github.com/weisJ/auto-dark-mode/blob/master/linux/build.gradle.ktsTo integrate the native code you can follow the implementation of https://github.com/weisJ/auto-dark-mode/blob/master/linux/gnome/src/main/java/com/github/weisj/darkmode/platform/linux/gnome/GnomeLibrary.java and https://github.com/weisJ/auto-dark-mode/blob/master/linux/gnome/src/main/java/com/github/weisj/darkmode/platform/linux/gnome/GnomeNative.java (this is simply a class to declare the native functions in).
The main work then is to implement ThemeMonitorService
(see https://github.com/weisJ/auto-dark-mode/blob/master/linux/gnome/src/main/java/com/github/weisj/darkmode/platform/linux/gnome/GnomeThemeMonitorService.kt for reference) using the native functions.
I hope this helps to get started. If you have any more questions feel free to ask.
auto-dark-mode-plugin-1.8.0-2023.1.zip
I have prepared a preliminary build incorporating the new Xdg based mechanism. Please check for any issues :)
Just tested on arch with KDE Plasma, works great! Thank you so much!
Just tested on arch with KDE Plasma, works great! Thank you so much!
Yes, XDG mechanism also works on Gnome 44, tyvm!
Plugin could ask for a Restart after this settings change, because automatic changes wouldn't trigger before I manually restarted IDE.
The final version will not need a restart ;)
There is now a way to detect the active theme variant on many Linux desktops. It's a xdg-desktop key that can be accessed via dbus: https://github.com/flatpak/xdg-desktop-portal/pull/633 (also works outside of Flatpaks)
Service:
org.freedesktop.portal.Desktop
Method:/org/freedesktop/portal/desktop org.freedesktop.Settings.Read
Namespace:org.freedesktop.appearance
Key:color-scheme
It returns a
uint32
:1
for dark mode and2
for light modeIt is not implemented everywhere yet (as far as I can tell), so errors would need to be catched.