Run Custom Actions Automatically When Switch to Light or Dark

Last updated: November 8, 2025 — Leave a comment

Want to do some actions automatically when you switch desktop theme to light or dark style? Here’s a new application can do the job for GNOME Desktop.

It’s switchcraft, a free open-source Vala written application that provides a modern simple interface, allowing to add custom commands to run automatically when the theme changes.

The app monitors the org.gnome.desktop.interface color-scheme key value and executes commands instantly when it’s changed to “prefer-dark” or “prefer-light”.

It can be useful for doing the following things automatically when switching desktop between light and dark style:

  • Change the legacy GTK3 theme, though Ubuntu already does it automatically.
  • Change Qt app theme.
  • Enable/Disable extensions, or configure extensions’ preferences.
  • Change Gnome Shell theme.
  • Or do whatever that you want.

Simply add your desired commands in the “Light” and “Dark” tabs, and turn on “Enable Monitor” option in Preferences.

Then, it will auto-run the switchcraft-monitor.sh script under .local/bin folder in next login, monitoring your desktop color scheme and running the commands automatically.

Besides that, it supports adding reusable constants for common variables in commands. And, it support exporting all the commands and importing to other systems.

Install switchcraft

Switchcraft provides official installer packages which are available to download in the link below:

They include .rpm package for Fedora/RHEL and .deb package for Debian/Ubuntu, which can be installed by system software app (e.g., Gnome Software and App Center).

For other Linux, it also provides non-install AppImage package that can be run directly to launch to the app, though you need to add executable permission from file properties dialog.

NOTE: switchcraft requires GNOME 40+, GLib >= 2.66, and jq command-line JSON processor.

Example Commands:

For those who are new to Linux, here are some example commands that may help.

1. change legacy GTK3/Icon theme

NOTE: The commands are written for Debian, Fedora, etc Linux Distributions, as Ubuntu automatically set Yaru and its variants as legacy GTK3 theme.

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

This command changes the GTK3 theme to adw-gtk3 dark mode. You need to replace adw-gtk3-dark depends on which theme you want to set.

gsettings set org.gnome.desktop.interface icon-theme 'MacTahoe-light'

This will change the icon theme to MacTahoe-light. Also you need to change the theme name accordingly.

Go to gnome-look.org for more themes, and use “Gnome Tweaks -> Appearance” to see all available choices.

2. Enable/Disable Extensions

First, run command to list all the installed extensions.

gnome-extensions list

Then, disable an extension by command:

gnome-extensions disable [email protected]

Here replace disable with enable if you want to enable an extension. And, replace extension ID [email protected] accordingly.

3. Configure Extension

For system default extensions, use similar command below to configure:

gsettings set org.gnome.shell.extensions.dash-to-dock background-color "#ffffff"

You may install and use the graphical “Dconf Editor” tool to get available extension names, keys, and key values.

For user installed extensions, you may first run command to list them:

gnome-extensions list --user --enabled

Then, print metadata of an extension (User Themes for example), to get the setting schema:

cat $HOME/.local/share/gnome-shell/extensions/user-theme\@gnome-shell-extensions.gcampax.github.com/metadata.json

Next, set constants:

THEME_SCHAMA=org.gnome.shell.extensions.user-theme
THEME_SCHAMADIR=$HOME/.local/share/gnome-shell/extensions/user-theme\@gnome-shell-extensions.gcampax.github.com/metadata.json/schemas

Finally, run command to configure the “name” (get the key from ‘gschema.xml’ file in extension folder) for the extension.

gsettings --schemadir $THEME_SCHEMADIR set $THEME_SCHEMA name "ChromeOS-dark-compact-shell"

Feel free to leave command below if you want more commands.

I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to let me know if the tutorial is outdated! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Buy me a coffee: https://ko-fi.com/ubuntuhandbook1 |

No Comments

Be the first to start the conversation.

Leave a Reply

Text formatting is available via select HTML.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

*