19

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.

0
17

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.

15
  • 1
    I did it, but didn't work...
    – Guilherme
    Feb 24 '19 at 14:51
  • Well, you need to leave way more information than that if you want help! @Guilherme
    – oemb1905
    Feb 24 '19 at 16:33
  • 1
    Confirmed that even on Ubuntu 18.04, ~/.config/gtk-3.0/settings.ini has no effect on "dark mode" (rebooted after change as well to restart display manager).
    – tresf
    Jun 3 '19 at 16:40
  • 2
    @tresf's comments are useful to others (hi!) since they at least mention an alternative solution to get a dark theme on Ubuntu. In contrast, this answer isn't useful to anybody anymore, assuming nobody runs the deprecated Ubuntu 15. Please update your answer to mention that this doesn't work for Ubuntu 16.04 and above (it's a conditional subjective) Apr 30 '20 at 9:57
  • 1
    @RobinMétral in case the GTK version was the source of confusion, it is now changed.
    – oemb1905
    Apr 30 '20 at 20:59
8

For modern Gnome desktops:

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

Default dark mode:

gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita-dark'

Default light mode:

gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita'

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.

2
  • Nothing "modern" here, just use Gnome's gsettings tool to edit the configuration files instead of a text editor.
    – oemb1905
    Jun 17 '21 at 17:44
  • 1
    This worked GREAT with Firefox. I used /usr/bin/gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita-dark' to automatically set dark mode near sunset. askubuntu.com/questions/742870/…
    – Ray Foss
    Aug 7 '21 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy