Reputation: 267
I am writing a bash script to switch system theme between dark and light whenever necessary (on Linux Mint 20.3). I could make it work for the overall OS theme, the terminal theme, and some gnome applications on flatpak.
With this, I expected that Mozilla Firefox will switch theme automatically, as its theme has been set to System theme
. However, the Firefox theme does not change. It would be helpful if someone could point me in the right direction to implement this.
In short, I am looking for at least one of the following:
Thanks in advance. Here is my bash script:
#!/bin/bash
if [ $# -eq 0 ]
then
echo Current Theme: $(gsettings get org.cinnamon.theme name)
elif [ $1 == "dark" ]
then
gsettings set org.gnome.desktop.interface gtk-theme 'Yaru-dark'
flatpak override --user --env=GTK_THEME='Yaru-dark'
gsettings set org.cinnamon.theme name 'Mint-Y-Dark'
gsettings set org.cinnamon.desktop.interface gtk-theme "Mint-Y-Dark"
gsettings set org.cinnamon.desktop.wm.preferences theme "Mint-Y-Dark"
gsettings set org.cinnamon.desktop.interface icon-theme 'Mint-Y-Dark'
gsettings set org.gnome.Terminal.ProfilesList default f02cd96e-20b4-4146-a6aa-75f5da6a65b2
elif [ "$1" = "light" ]
then
gsettings set org.gnome.desktop.interface gtk-theme 'Yaru-light'
flatpak override --user --env=GTK_THEME='Yaru-light'
gsettings set org.cinnamon.theme name 'Mint-Y'
gsettings set org.cinnamon.desktop.interface gtk-theme "Mint-Y"
gsettings set org.cinnamon.desktop.wm.preferences theme "Mint-Y"
gsettings set org.cinnamon.desktop.interface icon-theme 'Mint-Y'
gsettings set org.gnome.Terminal.ProfilesList default b1dcc9dd-5262-4d8d-a863-c897e6d979b9
else
echo "Unknown argument"
fi
Upvotes: 4
Views: 2488
Reputation: 3109
Not sure about the manner but I typically force by editing the corresponding desktop file in ~/.local/share/applications/
like ~/.local/share/applications/firefox.desktop
and set edit the Exec
lines to the following, to force the light version of Adwaita theme, for example:
Exec=env GTK_THEME=Adwaita:light bash -c '/usr/bin/firefox-nightly %u'
Exec=env GTK_THEME=Adwaita:light bash -c '/usr/bin/firefox-nightly --new-window %u'
Exec=env GTK_THEME=Adwaita:light bash -c '/usr/bin/firefox-nightly --private-window %u'
If you don't have a corresponding file, then either copy the file in /usr/share/applications/
like /usr/share/applications/firefox.desktop
to the ~/.local/share/applications/
directory and then edit the copied version — or copy the desktop file over to /usr/local/applications/
and then edit that file to apply for all users.
It should be noted, however, that I think this only has an effect on like the context menus, widget tabs, default website light dark themes when available and possibly the window buttons as the overall firefox theme is independent of the gtk theme. I believe the "use system theme" mostly refers to default website preferences and again, stuff like context menus and window buttons.
For more control, search in about:config
for "gtk" and this will show a few additional settings in firefox related to using the system theme although again, these are mostly related to widgets and context menus.
Upvotes: 0
Reputation: 11
The answer you are looking for might be simply:
gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
gsettings set org.gnome.desktop.interface color-scheme 'prefer-light'
Upvotes: 1