A shell script that toggles between the dark and light variants of the current GTK theme. Works for the GNOME shell theme and icon themes too. POSIX compliant.
https://user-images.githubusercontent.com/3108565/147882436-618ba345-730b-4aab-84ea-295a6f22b2d8.mp4
For more demos of dark-toggle
running on the default GNOME Shell and Ubuntu can be found below.
gsettings
notify-send
with an appropriate notification daemon installed.Install system-wide for all users (requires root user or sudo
):
make
Install for current user only:
make PREFIX=~/.local
For current-user only, make sure ~/.local/bin
is in your $PATH
.
Just run dark-toggle
or use an app launcher to search and run Dark Toggle
. CLI options are not added yet, but see Configuration.
By default, dark-toggle
only changes the GTK Applications theme. However, further options can be added as necessary from the table below:
Option | Description |
---|---|
change-shell |
Also change the GNOME Shell theme. (GNOME Shell must be running and User Themes extension must be installed.) |
change-icons |
Also change the icon theme. |
exec-hooks |
Execute a hook each time dark-toggle is run (not implemented yet) |
The config file can also be used to add user-defined mappings between light and dark variant of themes.
Example of a config file:
# ~/.config/dark-toggle/config
## Options
#
# Guess the icon name from the gtk theme name and change to it
change-icons
# Also change the gnome shell theme
change-shell
# Run hooks found in hooks dir
exec-hooks
# Put user-defined mappings and also mappings for theme names that cannot be guessed.
mappings {
# Light Dark
Adapta Adapta-Nokto
Plata Plata-Noir
Qogir-win Qogir-dark
Plata-Lumine Plata-Noir
}
This is also useful when a theme might have more than two variants and the user would like to specify which of the two variants they would like to use.
Adwaita theme
https://user-images.githubusercontent.com/3108565/147814344-41b6b278-8872-48fb-a7d4-4a145509270b.mp4
Plata theme
https://user-images.githubusercontent.com/3108565/147814701-390c4705-d108-45cd-8ba1-17db58ea1a37.mp4
ZorinGreen theme
https://user-images.githubusercontent.com/3108565/147814722-c3a7dfb0-5a58-4766-8949-6026d7148ef4.mp4
Ubuntu
Demoing on the themes Yaru, Adwaita and Materia:
The demos shown here are using the excellent Dark Reader add-on for Firefox.
Those looking for a Gnome Shell Extension, as opposed to this cli tool, can try the Night Theme Switcher extension... But have you seen this tool's #Highlights?
This repo was made from a GitHub Gist where I appreciated much help from newnix.