30

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 Answers2

28

For modern Gnome desktops:

  • Tested: Ubuntu 18.04, 20.04; Fedora 27, 32, 36 enter image description here

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:

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.

Sam
  • 85
tresf
  • 1,072
20

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.

oemb1905
  • 356