albertosottile / darkdetect

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

Linux (GNOME) #7

Closed cbrnr closed 3 years ago

cbrnr commented 3 years ago

Nice project! Do you have any plans to support GNOME (or KDE) as well?

larsoner commented 3 years ago

From what (little) I've found online there doesn't seem to be a consistent way to detect this on Linux, but it seems like calling:

gsettings get org.gnome.desktop.interface gtk-theme

and looking for -dark at the end would at least get it to work for some of the people some of the time (Debian flavors with dark-configured GTK -- works for me on Ubuntu 20.10 at least!).

Happy to open a PR to subprocess this call if this sort of incremental progress seems sufficiently useful...

albertosottile commented 3 years ago

Seems to me the ecosystem is a little too vast to get this consistently right across all the Linux platforms. Also, I am not thrilled by a subprocess-based detection method, as that can fail in frozen applications.

Nevertheless, I am not against a PR on this topic, including one that uses subprocess, as users might still benefit from incremental implementations of this feature. So, please feel free to submit one and I will happily review it.

larsoner commented 3 years ago

Seems to me the ecosystem is a little too vast to get this consistently right across all the Linux platforms. Also, I am not thrilled by a subprocess-based detection method, as that can fail in frozen applications.

Indeed I imagine it could fail in all sorts of ways. Hopefully a try/except might be good enough for a first version. I'll open a quick PR and we can see if it looks reasonable.

cbrnr commented 3 years ago

Could you use PyGObject instead?

albertosottile commented 3 years ago

Could you use PyGObject instead?

I would rather not, as this would violate the "philosophy" of this package of avoiding extra dependencies

In addition, this package does not depend on other modules or packages that are not already included in standard Python distributions.

cbrnr commented 3 years ago

I would rather not, as this would violate the "philosophy" of this package of avoiding extra dependencies

You could nest the import though, so only people who really need it can install the package.

albertosottile commented 3 years ago

As I mentioned before, for the moment I would prefer to go with the way addressed in #8 as I think is leaner, though more brittle.

Medium term, it could be worthy to investigate how PyGObject is implemented and get the relevant parts needed for just this feature to include just them in Darkdetect.