Dark mode switching - ArchWiki

Jump to content
From ArchWiki

This article or section is out of date.

Reason: GNOME 42 has been released, which has built-in dark mode switching. (Discuss in Talk:Dark mode switching)

Switching between light and dark modes/themes is nice to have. It allows you to switch to dark mode on sunset or toggle modes with a keyboard shortcut.

The switch between themes can apply to currently running programs, probably requiring a daemon, or only to newly launched ones. This article focuses on switching at runtime, so toggling during use affects currently running programs.

Switching between light and dark mode requires support from applications or application toolkits like GTK and Qt.

## Tools

- darkman — darkman is a tool that allows automating transitioning to dark mode at sundown, and back to light mode at sunrise. It allows placing drop-in scripts to be run automatically at those times.

  https://gitlab.com/WhyNotHugo/darkman/ || darkmanAUR

- Yin-Yang — Yin-Yang is a similar tool, which can be also run manually (not only on sunset/sunrise). Currently it supports Plasma, GNOME & Budgie DE, as well as few of the most used miscellaneous applications (Firefox, VSCode etc.). Running custom scripts is also supported.

  https://github.com/oskarsh/Yin-Yang || yin-yangAUR

## Toolkits

### GTK

To change the light/dark mode, you have to change the used theme.

Most themes do have a dark variant and those have by convention the suffix `-dark`. For example the default GTK theme `Adwaita` has the variant `Adwaita-dark`.

To permanently change to the dark variant, see GTK#Dark theme variant

To switch themes instantly for running programs, either a daemon providing the xsettings spec or gsettings is required. For desktops running with Xorg, an xsettings daemon is needed. For desktops running with Wayland, gsettings is queried.

#### xsettings daemon

xsettings is queried for Xorg sessions

The xsettings daemon from Xfce is xfsettingsd, which is provided by the xfce4-settings package.

To query current GTK theme:

    $ xfconf-query -c xsettings -p /Net/ThemeName

To set GTK theme:

    $ xfconf-query -c xsettings -p /Net/ThemeName -s "new-theme"

Changes to this entry are instant and affect all GTK applications.

#### gsettings

gsettings is queried for Wayland sessions.

To query the current GTK theme:

    $ gsettings get org.gnome.desktop.interface gtk-theme

To set the GTK theme:

    $ gsettings set org.gnome.desktop.interface gtk-theme "new-theme"

Alternatively, if your theme does not apply the dark scheme to Gtk4 applications, you can request the dark variant of the default theme:

    $ gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'

Changes to this entry are instant and affect all GTK applications.

### Qt

Qt has theme support similar to GTK.

One method to theme Qt applications is using GTK for styling. Changes to the GTK theme then affect Qt applications as well.

Another method is using a native Qt theme, e.g. adwaita-qt5. To switch between themes, you can follow Qt#Configuration of Qt 5 applications under environments other than KDE Plasma.

## Applications

### Firefox

Firefox automatically uses the current GTK theme mode and adapts the appearance of the browser accordingly. See Firefox#Dark themes for some more settings and caveats.

To change web content smartly, the Dark Reader Add-On is recommended.

By setting `Automation` to `Use system color scheme`, Dark Reader activates automatically with dark GTK themes.

### Thunderbird

Thunderbird conforms with the current GTK Theme, but some changes are recommended.

See Thunderbird#Theming tweaks.

### Visual Studio Code

To change the theme in Visual Studio Code, this script may help.

### IntelliJ

The Auto Dark Mode plugin will automatically switch themes based on the current GTK theme once installed.

### Alacritty

Alacritty has support for multiple custom color schemes. The configuration syntax and published color schemes can be found here.

To quickly change theme, you should declare a pointer to each color scheme, for example `&black`. Then you can switch to a color scheme by simply setting `colors: *black`. This change to the configuration file is instant and affects all currently running instances. If not, you may have to set `live_config_reload: true`.

The borders and title bar are themed with GTK. To abide by the GTK theme, you should set the setting `gtk_theme_variant` to the default `None`.

Categories:

- Eye candy
- Accessibility

Hidden category:

- Pages or sections flagged with Template:Out of date