I know how to set and display most themes, however I can find anything about how to turn the Global Dark Theme on and off through Terminal, I can only find the option in the gnome-tweak-tool. So is there not a way to turn it on and off through Terminal? I am running Ubuntu GNOME 15.10 with GNOME 3.18.
2 Answers
For modern Gnome desktops:
Default dark mode:
gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita-dark'
Fedora 36 and above, and Ubuntu 23.04
gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
Default light mode:
gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita'
Fedora 36 and above, and Ubuntu 23.04
gsettings set org.gnome.desktop.interface color-scheme 'default'
Getting a list of available base theme names:
ls -d /usr/share/themes/* |xargs -L 1 basename
Caveats:
Some existing limitations to changing the theme: https://bugzilla.gnome.org/show_bug.cgi?id=783666 (bug conversation mentions them)
It appears that there's some variance in how this is adopted with
Adwaitabeing the currently accepted default, but the tweak tool will also attempt to write to thesettings.inifiles.Furthemore, applications provided as snaps may ship with their own
settings.inifiles making a command line solution much more difficult than a one-liner.
Ideally, a technique to invoke gnome-tweak-tool through CLI would cover most scenarios holistically. Gnome-tweak-tool is written in python3, so this should be theoretically possible to someone familiar with Python.
Fedora 36 introduced a new preference, color-scheme that is required to change theme for some apps (files, settings, software, …) and gtk-theme doesn’t work anymore for these apps.
To test at Ubuntu 23.04, launch gnome-tweaks -v (-v=Print the names of settings modified), the Style setting is not at gnome-tweaks is at Settings application, switch there and gnome-tweaks will intercept and print about org.gnome.desktop.interface color-scheme.
To set the global dark theme from the command line, first navigate to a Terminal of your choice and then from within the shell emulator ...
Navigate to your home directory:
cd ~
Create a new file called settings.ini inside of the GTK 4 directory:
nano ~/.config/gtk-4.0/settings.ini
Enter the following fields into the configuration file:
[Settings]
gtk-application-prefer-dark-theme=1
Write the changes to disk by pressing control + x, then press y, then enter.
- 356
