weisJ / auto-dark-mode

IDEA plugin to automatically apply system theme settings on macOS and Windows.
https://plugins.jetbrains.com/plugin/14076-auto-dark-mode
MIT License
53 stars 15 forks source link

gnome-settings-daemon detection doesn't work outside of i3, GNOME, or XFCE #61

Closed telnoratti closed 1 year ago

telnoratti commented 2 years ago

I use sway, which is a Wayland based successor to i3. I still manage light/dark mode with gsettings, but Auto Dark Mode says it's not supported because it's not one of the selected desktop environments. It should work, because the associated gsettings command does indeed return information about the theme.

https://github.com/weisJ/auto-dark-mode/blob/a7dfbebdb6860e126e00689b53a6c21121da96fd/base/src/main/java/com/github/weisj/darkmode/platform/LibraryUtil.java#L41

It appears that SystemInfo in IntelliJ has similar limitations by design. https://github.com/JetBrains/intellij-community/blob/ceb2e26bfe1707dad40b3de02871b14445d8f766/platform/util/src/com/intellij/openapi/util/SystemInfo.java#L67-L81.

I noticed a recent merged PR https://github.com/weisJ/auto-dark-mode/pull/54 which expanded the detection and a discussion at https://github.com/weisJ/auto-dark-mode/issues/50#issuecomment-1098553400 which I think was discussing adding a xdg-desktop-portal component and separate detection.

weisJ commented 2 years ago

The portal implementation (#51) has indeed been worked on but stalled due to unknown limitations in the IDEA platform, which haven't been resolved yet by the looks of it.

Detecting whether the current implementation works isn't trivial as there is no unified way of checking it without running it and seeing if it doesn't fail (which I really don't want to do).

Now what I can imagine doing is adding an "I am absolutely sure my system supports the plugin, I know what I a doing" option to force the current implementation to be used. It's not ideal but the probably quickest solution.

telnoratti commented 2 years ago

Yeah, I think the best option to check if gnome-settings-daemon is in use is to use the dbus interface. That means either trying to load your native library and see if it fails or connecting to dbus directly, which I gather is the cause of the problems in the portal implementation. The "I know what I'm doing option" sounds like a good stopgap.

I don't know exactly what direction Linux is going for this. I've been using darkman which offers some cross implementation compatibility and allows running arbitrary scripts to fix all the things that don't use a "standard" interface. I think that'll be what I have to do for the next 2-3 years at least.

Janhouse commented 1 year ago

This plugin does not work with Gnome 43. Instead of checking gtk-theme it should check for color-scheme 'prefer-dark' https://wiki.archlinux.org/title/Dark_mode_switching#gsettings

weisJ commented 1 year ago

I currently don't have a lot of time for working on this plugin. I would be happy for any contributions tackling this.

weisJ commented 1 year ago

I have prepared a new version, which might fix this: https://github.com/weisJ/auto-dark-mode/issues/50#issuecomment-1489269592

weisJ commented 1 year ago

Closing this as the remaking issue with Gnome is already tracked in #72