rifazn / dark-toggle Goto Github PK
View Code? Open in Web Editor NEWA small POSIX compliant shell script that toggles between the dark and light variants of a GTK theme.
License: MIT License
A small POSIX compliant shell script that toggles between the dark and light variants of a GTK theme.
License: MIT License
It only changes the theme, not the shell theme. So, the panel, right-click on desktop menu, password box..etc stay at whatever previous theme it was on.
It gets confused and doesn't work when a theme has several variants. For example, it worked flawlessly on Yaru and Pop themes, because they only have (Yaru and Yaru-dark.. and Pop and Pop dark), but when I try it on the zorin theme (which has zorin blue, zorin blue dark, zorin red, zorin red dark etc of other colors), Qogir (which has Qogir, Qogir win, Qogir dark, Qogir win dark, Qogir rounded, Qogir rounded dark....You get what I am saying), it doesn't do anything.
I'd love for this to apply to icons, too.
Automatic switching (sunset to sunrise, for example) would be superb.
Videos to be used for demoing Dark Toggle
Use this instead:
Or this:
Toggling between Adwaita variants
Plata variants
ZorinGreen variants
Demoing on Yaru, Adwaita and Materia themes:
Quite a few themes additionally have light/dark variants of a 'compact' version of the base theme. The naming scheme for these themes seem common enough that they can be easily guessed.
For example: for the "Materia" theme. Normal/base version has variants: Materia, Materia-light, Materia-dark. The "compact" version has names: Materia-compact, Materia-light-compact, Materia-dark-compact. Thankfully, this same convention is used by the themes: "Orchis", "Canta" and "ChromeOS".
Currently, the code is only checking whether a theme name has "dark" at the end of it. If not, then the current theme is assumed to be a light variant (correctly so) and "dark" is just appended to the theme's name. This works no problem for the "base" version of these themes, but this guess is wrong for compact themes as the correct name is "-dark-compact", but our guess is "-compact-dark".
Adding an extra case for compact themes should be enough and the prefered way (as opposed to adding all compact themes in the config).
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.