rifazn / dark-toggle

A small POSIX compliant shell script that toggles between the dark and light variants of a GTK theme.
MIT License
21 stars 0 forks source link

Themes whose names don't have the usual -dark/-light suffix don't work with the script #3

Closed rifazn closed 2 years ago

rifazn commented 3 years ago

The script currently looks for either [lL]ight or [dD]ark suffix in the current gtk theme and tries to replace one suffix with the other, thus guessing the other variant's name. But for themes like "Qogir", "Plata", "Adwaita", etc. that don't follow the naming scheme of having these common suffixes, trying to guess their variants results in an invalid theme name.

This problem was also brought forward by @KarkanAlzwayed in #1.

The obvious solution is to hard-code these theme names and their variants in my code, but I would like to avoid hard-coded theme names (which is data) into my source code (which is logic). Also, having hard-coded values can make maintaining the code more difficult and affect the quality too.

I've decided that in order to support the themes with more varied (read exotic) names, I'll maintain and distribute a default config file with most common light vs. dark theme mappings. For example, in case of "Plata" theme (whose light variant is just Plata and dark variant is Plata-Noir) and Adapta (an extra example), the config file might have a line that looks like

theme_mappings="Plata: Plata-Noir, Adapta: Adapta-Nokto"

The config file might also support mapping icon themes with a gtk application theme, so that when the application theme changes, the icon theme changes as well.

To discuss whether having a config file would certainly be a good idea, and if so, what it should look like and how best to parse it, I've opened up a thread in the Arch Linux Forums. The discussion (ongoing) can be found here: https://bbs.archlinux.org/viewtopic.php?pid=1995916

rifazn commented 3 years ago

From the discussion over at the Arch Forums, considering a config format like below:

# Theme 1    Theme 2        Icon 1    Icon 2
Arc         Arc-Dark       Icon1     Icon2
Adwaita     Adwaita-dark   Icon1     Icon2
Plata       Plata-Noir     Icon1     Icon2
ZorinBlue   ZorinRed-Dark

An implementation that ignores checking and setting icons for now is in this commit: 902a03d974d6ca91a0debab81682fdb9866bc7c4. Hope to see how it fares in user testing.

rifazn commented 2 years ago

7211d28ec3d8850a7979f0c7bae1a932c3f0fc1c