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.
dark-toggle-swaywm.mp4
For more demos of dark-toggle
running on the default GNOME Shell and Ubuntu can be found below.
- Easy and instantaneous. Toggle darkness at will!
- Works the same for Window Managers and the Gnome Shell alike. No need to have any Gnome Shell Extensions installed!
- Is extendable using hooks (WIP). Changing the theme of your terminal emulator will soon be possible!
- Can easily be used as a hook in other programs like gammastep and redshift.
- No need to wait for a day/night cycle.
- No mouse interaction needed.
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
1.Adwaita.mp4
Plata theme
2.Plata.mp4
ZorinGreen theme
3.ZorinGreen.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.