Dark color scheme switch for Byzantium

In Crimson, there will be a toggle in settings to switch between the dark and the default color schemes of the interface at will. In this forum, there were enough examples of how to reproduce a similar functionality. Here I share what I currently use in Byzantium. It allows switching the color scheme with a single icon in the applications drawer, which is convenient for Librem 5. On a desktop, I would assign a keyboard shortcut instead.

$ cat ~/.local/bin/color-scheme-switch
#! /bin/bash

CURRENT=$(gsettings get org.gnome.desktop.interface color-scheme)

if [[ "$CURRENT" == "'prefer-dark'" ]]; then
	gsettings reset org.gnome.desktop.interface color-scheme
	gsettings reset org.gnome.desktop.interface gtk-theme
else
	gsettings set org.gnome.desktop.interface color-scheme prefer-dark
	gsettings set org.gnome.desktop.interface gtk-theme Adwaita-dark
fi

The first setting is for newer applications. The older applications or older versions of applications require the second setting instead which switches the GTK theme.

$ cat ~/.local/share/applications/color-scheme-switch.desktop
[Desktop Entry]
Name[uk]=Затемнити
Name=Darken
Comment[uk]=Перемкнути колірну схему
Comment=Switch the color scheme
Keywords[uk]=Темна;Світла;Ніч;День;Перемкнути;Тема;Затемнити;Darken;
Keywords=Dark;Light;Night;Day;Switch;Theme;Darken;
TryExec=/home/purism/.local/bin/color-scheme-switch
Exec=/home/purism/.local/bin/color-scheme-switch
Icon=video-display
Terminal=false
Type=Application
Categories=GTK;GNOME;Settings;System;Utility;
StartupNotify=false
OnlyShowIn=GNOME;Phosh;
X-Purism-FormFactor=Workstation;Mobile;
6 Likes