Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Linux #50

Closed
l0drex opened this issue Apr 12, 2022 · 8 comments · Fixed by #51
Closed

Support for Linux #50

l0drex opened this issue Apr 12, 2022 · 8 comments · Fixed by #51
Labels
enhancement New feature or request

Comments

@l0drex
Copy link
Contributor

l0drex commented Apr 12, 2022

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: flatpak/xdg-desktop-portal#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 and 2 for light mode

It is not implemented everywhere yet (as far as I can tell), so errors would need to be catched.

@weisJ
Copy link
Owner

weisJ commented Apr 12, 2022

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 :) )

@weisJ weisJ added the enhancement New feature or request label Apr 12, 2022
@weisJ
Copy link
Owner

weisJ commented Apr 12, 2022

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?

@l0drex
Copy link
Contributor Author

l0drex commented Apr 13, 2022

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

@weisJ
Copy link
Owner

weisJ commented Apr 13, 2022

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:

To 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.

@weisJ
Copy link
Owner

weisJ commented Mar 29, 2023

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 :)

@l0drex
Copy link
Contributor Author

l0drex commented Mar 30, 2023

Just tested on arch with KDE Plasma, works great! Thank you so much!

@lkraav
Copy link

lkraav commented Mar 31, 2023

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.

@weisJ
Copy link
Owner

weisJ commented Apr 1, 2023

The final version will not need a restart ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants