Skip to content

Switchcraft watches GNOME's light/dark preference and runs your shell commands when the theme changes.

License

Notifications You must be signed in to change notification settings

kem-a/switchcraft

Repository files navigation

Download Release License GNOME 40+ GTK 4 Vala Stars

switchcraft Switchcraft

Switchcraft watches GNOME's light/dark preference and runs your shell commands when the theme changes.

Screenshot From 2025-11-01 00-27-06

Features

  • Watches org.gnome.desktop.interface color-scheme and executes commands instantly.
  • Polished libadwaita interface with light/dark pages, icons, and header-bar actions.
  • Add, edit, enable/disable, or remove commands per theme.
  • Define reusable constants for common variables in commands.
  • Independent background monitoring - separate bash script runs even when GUI is closed.
  • Keyboard shortcuts (Ctrl+N to add, Ctrl+Q to quit) plus About and Shortcuts dialogs from the menu.
Command Examples (click to open)
  • Change legacy theme to dark:

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

  • Change icon theme to light:

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

  • Set constants:
D2DL_SCHEMADIR="$HOME/.local/share/gnome-shell/extensions/[email protected]/schemas"
D2DL_SCHEMA="org.gnome.shell.extensions.dash2dock-lite"
  • Change Dash 2 Dock Lite background based on theme and using constants

Light theme:

gsettings --schemadir $D2DL_SCHEMADIR set $D2DL_SCHEMA background-color '(0.063, 0.1216, 0.1882, 1.0)'

Dark theme:

gsettings --schemadir $D2DL_SCHEMADIR set $D2DL_SCHEMA background-color '(0.3373, 0.4392, 0.5294, 1.0)'

Requirements

  • GNOME 40+ (GTK 4 and libadwaita)
  • GLib 2.66+
  • Vala compiler (for building)
  • Meson build system
  • jq (for JSON parsing in monitor script)
  • ruby, rubygems, rpmbuild, appimagetool and chrpath (for packaging only)
Install dependencies (click to open)

Debian/Ubuntu:

sudo apt install meson valac libgtk-4-dev libadwaita-1-dev libjson-glib-dev jq ruby ruby-dev rubygems build-essential
gem install --user-install fpm

Fedora:

sudo dnf install meson vala gtk4-devel libadwaita-devel json-glib-devel jq ruby rubygems rpmbuild chrpath
gem install --user-install fpm

Arch:

sudo pacman -S meson vala gtk4 libadwaita json-glib jq ruby
gem install --user-install fpm

AppImageTool

Download from here and copy to $PATH

Installing

Download latest release rpm, deb or AppImage. For seemless AppImage installation Gear lever app is recommended.

Building

Details (click to open)

User-Level building and installation (Recommended)

# Configure for user installation
meson setup builddir --prefix="$HOME/.local"

# Compile
meson compile -C builddir

# Install to ~/.local
ninja -C builddir install

# Uninstall
ninja -C builddir remove

System-Wide Installation

# Configure for system installation
meson setup builddir --prefix=/usr/local

# Compile
meson compile -C builddir

# Install system-wide
sudo ninja -C builddir install

# Uninstall
sudo ninja -C builddir remove

Configuration

Details (click to open)

All runtime configuration lives under ~/.config/switchcraft/.

  • commands.json - per-theme command lists. Example:
{
  "dark": [{ "command": "notify-send 'Dark mode enabled'", "enabled": true }],
  "light": [{ "command": "notify-send 'Light mode enabled'", "enabled": true }]
}
  • constants.json - reusable variables referenced inside commands using $NAME or ${NAME}.

Example:

{
  "D2DL_SCHEMADIR": "$HOME/.local/share/gnome-shell/extensions/[email protected]/schemas",
  "D2DL_SCHEMA": "org.gnome.shell.extensions.dash2dock-lite"
}
  • settings.json - app settings (e.g., monitoring_enabled). The UI saves changes automatically.

Monitor Files

When monitoring is enabled:

  • ~/.local/bin/switchcraft-monitor.sh - The monitoring script (installed automatically)
  • ~/.config/autostart/switchcraft-monitor.desktop - Autostart entry for login persistence

Known issues

  • AppImages are standalone applications and does it have install/uninstall function. Because of this if you not disable monitoring before removing AppImage background script will continue running. You can temove it manually from ~/.config/autostart and ~/.local/bin.

License

This project is provided under the terms in LICENSE.

About

Switchcraft watches GNOME's light/dark preference and runs your shell commands when the theme changes.

Resources

License

Stars

Watchers

Forks

Packages

No packages published