Automate Dark Icon Theme Switch in Dark Style

Hello, all…

I’m wondering if anyone is aware of a way to automate the process of switching to a dark icon theme when selecting “Dark Style” for GNOME; for example, automatically change the icon theme from “Flatery” to “Flatery-Dark” when choosing “Dark Style” from the GNOME panel’s settings.

I thought something like that might exist in Tweaks or as an extension, but it doesn’t appear so. “Night Theme Switcher” looks like it used to cover icon themes, but doesn’t any longer.

Thanks for the help…

This makes the legacy GTK theme and icon theme to match the current color mode:

sudo dnf -y install gnome-themes-extra
sudo tee /usr/local/bin/theme-sync << "EOF" > /dev/null
#!/usr/bin/bash
gsettings monitor org.gnome.desktop.interface color-scheme \
| while read -r COLOR_SCHEME
do
    case "${COLOR_SCHEME}" in
    (*default*)
        GTK_THEME="Adwaita"
        ICON_THEME="Flatery" ;;
    (*dark*)
        GTK_THEME="Adwaita-dark"
        ICON_THEME="Flatery-Dark" ;;
    esac
    gsettings set org.gnome.desktop.interface gtk-theme "${GTK_THEME}"
    gsettings set org.gnome.desktop.interface icon-theme "${ICON_THEME}"
done
EOF
sudo chmod +x /usr/local/bin/*

sudo tee /etc/systemd/user/theme-sync.service << EOF > /dev/null
[Unit]
Description=Theme sync service
[Service]
ExecStart=theme-sync
[Install]
WantedBy=gnome-session.target
EOF
systemctl --user daemon-reload
systemctl --user enable theme-sync.service
systemctl --user restart theme-sync.service
1 Like

That seems, well, elegant… Can you walk me through what it does exactly?

Got it… Is one “d” meant to be capitalized and the other not in this snippet?

Thanks for your help and the primer… It doesn’t seem to have worked, though.

Not only do the icons not change in, for example, Evolution, but the icon theme is still listed as regular Flatery in Tweaks.

I have a less automated method, just using two commands as aliases for switching to light or dark theme:

alias thdark='gsettings set org.gnome.desktop.interface gtk-theme "adw-gtk3-dark" ; gsettings set org.gnome.desktop.interface color-scheme "prefer-dark"'
alias thlight='gsettings set org.gnome.desktop.interface gtk-theme "adw-gtk3" ; gsettings set org.gnome.desktop.interface color-scheme "default"'

In the evening I run the alias for dark theme, and in daylight the light one.

1 Like

Thanks for the help; I’ve been able to get it to work, despite not changing anything. I reran the systemctl --user commands again and this time it all seems to work.

Again, a really nice and elegant automated solution!

2 Likes