albertosottile / darkdetect

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

Linux: generalise detection to any theme with 'dark' in the name #24

Closed DoctorDalek1963 closed 1 year ago

DoctorDalek1963 commented 1 year ago

This is an extension to #17 and fixes the same issue in listener(). We consider any theme with 'dark' in theme.lower() to be a dark theme.

There is no official standard for theme names, and the suffix approach is often flawed. By convention, most dark themes will have 'dark' somewhere in their name, and only a very tiny minority of light themes will have 'dark' in their name, so there should be almost 0 instances of a light theme being called dark, whereas currently, many dark themes are incorrectly called light.

albertosottile commented 1 year ago

Thanks for submitting this. I am not myself a Linux user, hence In #17 I asked for a list of theme names just to establish quantitatively on what fraction of (known) themes this (or the proposed change there) would cause issues. Could you provide such a list? Otherwise I still feel that merging this or #17 is a shot in the dark (pun intended).

@larsoner Would you like to weigh in on this?

DoctorDalek1963 commented 1 year ago

The Ubuntu default dark themes are named things like Adwaita-dark and Yaru-dark but I personally use the Vimix theme pack, which has dark theme names like Vimix-dark-[colour] and Vimix-dark-laptop-[colour]. #17 mentions Sweet-Dark-v40, which is a dark version of the Sweet theme for GNOME 40.

Just googling "top gtk themes", I found an article that links to more themes that wouldn't work. Themes with names like Ultimate-Dark-[colour], Ultimate-Dark-(Flat)-[colour], Prof-Gnome-Dark-3.6, Prof-Gnome-Darker-3.6, Solarized-Dark-[colour]_2.0.4, Solarized-Dark-[colour]-3.6_2.0.4, Cloudy-Dark-[colour], etc.

My point is, although there are dark themes that end with -dark and some dark themes that don't have "dark" in them at all, a large proportion of popular GTK dark themes have "dark" somewhere in the middle, because most of them have a version number or an accent colour like "blue" on the end.

larsoner commented 1 year ago

+1 for looking for "-dark" in the .lower() name (note leading dash)

DoctorDalek1963 commented 1 year ago

+1 for looking for "-dark" in the .lower() name (note leading dash)

Yeah, that's a good idea. Just added it in 74a4164

albertosottile commented 1 year ago

LGTM, thank you for this contribution!

albertosottile commented 1 year ago

Released in 0.7.0.