summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorskylar <me@casper>2026-11-28 05:59:53 -0800
committerskylar <me@casper>2026-11-28 05:59:53 -0800
commite4306e5435eef76bad7fa9b3b909362304a8a47e (patch)
treed7856752d733cf2ef4551b3f6c6125635060ab58 /bin
luxnox: one palette for light and dark themesHEAD main
palette.toml drives kitty, the dwl desktop (dwl, fuzzel, swaync, wob, wmenu), GTK, Qt, the console and Emacs; luxnox-toggle switches lux and nox. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/luxnox-apply82
-rwxr-xr-xbin/luxnox-menu7
-rwxr-xr-xbin/luxnox-toggle18
3 files changed, 107 insertions, 0 deletions
diff --git a/bin/luxnox-apply b/bin/luxnox-apply
new file mode 100755
index 0000000..16c824c
--- /dev/null
+++ b/bin/luxnox-apply
@@ -0,0 +1,82 @@
+#!/bin/sh
+# Point the desktop's per-mode files at lux or nox and reload what needs it.
+# dwl runs this whenever the system color-scheme changes (and once at login).
+# luxnox-apply dark|light|nox|lux
+#
+# ~/.local/state/luxnox/current links to ~/.local/share/luxnox/<mode>; the
+# apps' configs point into it (fuzzel include, swaync @import, wob.ini and
+# swaylock/config links), so switching is one link.
+case "$1" in
+dark | nox) mode=nox ;;
+light | lux) mode=lux ;;
+*) echo "usage: luxnox-apply dark|light" >&2; exit 2 ;;
+esac
+
+share="${XDG_DATA_HOME:-$HOME/.local/share}/luxnox"
+state="${XDG_STATE_HOME:-$HOME/.local/state}/luxnox"
+[ -d "$share/$mode" ] || { echo "luxnox-apply: no $share/$mode (run make install in luxnox)" >&2; exit 1; }
+mkdir -p "$state"
+
+# GTK3 apps follow the theme setting live (GTK4/libadwaita follow the
+# color-scheme by themselves). The plain user dconf database, as in
+# luxnox-toggle.
+theme=luxnox-dark
+[ "$mode" = lux ] && theme=luxnox
+env -u DCONF_PROFILE gsettings set org.gnome.desktop.interface gtk-theme "$theme"
+
+# Qt: qt6ct watches its folder, so replacing qt6ct.conf (a new file renamed
+# over it) repaints running Qt apps with the other palette. Icons too: Qt
+# draws theme icons as they are (GTK recolours symbolic ones), so Qt uses
+# Breeze in lux and Breeze Dark in nox.
+qt="${XDG_CONFIG_HOME:-$HOME/.config}/qt6ct"
+scheme="$qt/colors/luxnox-$mode.conf"
+icons=breeze
+[ "$mode" = nox ] && icons=breeze-dark
+if [ -f "$qt/qt6ct.conf" ] && [ -f "$scheme" ] &&
+ ! { grep -qx "color_scheme_path=$scheme" "$qt/qt6ct.conf" &&
+ grep -qx "icon_theme=$icons" "$qt/qt6ct.conf"; }; then
+ tmp=$(mktemp "$qt/.qt6ct.conf.XXXXXX") &&
+ sed -e "s|^color_scheme_path=.*|color_scheme_path=$scheme|" \
+ -e "s|^icon_theme=.*|icon_theme=$icons|" "$qt/qt6ct.conf" >"$tmp" &&
+ mv "$tmp" "$qt/qt6ct.conf"
+fi
+
+# Flatpak Qt apps (qBittorrent) use KDE's platform theme, which reads
+# kdeglobals. Flatpak bind-mounts this file into the sandbox, which pins its
+# inode, so overwrite it in place: a new file renamed over it would go unseen
+# by running apps.
+kdeglobals="${XDG_CONFIG_HOME:-$HOME/.config}/kdeglobals"
+if [ -f "$share/$mode/kdeglobals" ] && ! cmp -s "$share/$mode/kdeglobals" "$kdeglobals"; then
+ cat "$share/$mode/kdeglobals" >"$kdeglobals"
+ # The theme doesn't watch the file: it rereads the palette on KDE's
+ # notifyChange(PaletteChanged) signal. The Flatpak D-Bus proxy only passes
+ # signals from names the app may talk to, so send it as
+ # org.kde.KGlobalSettings, holding the name long enough for the proxy to
+ # see who owns it. In the background: it takes a second.
+ python3 -I - >/dev/null 2>&1 <<'EOF' &
+import time
+import gi
+gi.require_version("Gio", "2.0")
+from gi.repository import Gio, GLib
+bus = Gio.bus_get_sync(Gio.BusType.SESSION)
+got = bus.call_sync("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus",
+ "RequestName", GLib.Variant("(su)", ("org.kde.KGlobalSettings", 4)),
+ GLib.VariantType("(u)"), 0, -1, None).unpack()[0]
+if got == 1: # primary owner (no real KDE session holds it)
+ time.sleep(0.5)
+ bus.emit_signal(None, "/KGlobalSettings", "org.kde.KGlobalSettings", "notifyChange",
+ GLib.Variant("(ii)", (0, 0))) # PaletteChanged
+ bus.flush_sync(None)
+ time.sleep(0.5)
+EOF
+fi
+
+[ "$(readlink "$state/current")" = "$share/$mode" ] && exit 0
+ln -sfn "$share/$mode" "$state/current"
+
+# fuzzel and swaylock read their config each time they start.
+# wob reads it once, so restart it (its socket stays open meanwhile).
+systemctl --user try-restart wob.service 2>/dev/null
+# swaync reloads its CSS, imports included.
+pgrep -x swaync >/dev/null && swaync-client --reload-css >/dev/null 2>&1
+exit 0
diff --git a/bin/luxnox-menu b/bin/luxnox-menu
new file mode 100755
index 0000000..8d2f95f
--- /dev/null
+++ b/bin/luxnox-menu
@@ -0,0 +1,7 @@
+#!/bin/sh
+# wmenu in the current luxnox mode's colours (wmenu has no config file).
+# Takes wmenu's other arguments: luxnox-menu -i -l 5 -p Power
+flags="${XDG_STATE_HOME:-$HOME/.local/state}/luxnox/current/wmenu"
+# shellcheck disable=SC2046 # the flags file is one line of words
+[ -r "$flags" ] && exec wmenu $(cat "$flags") "$@"
+exec wmenu "$@"
diff --git a/bin/luxnox-toggle b/bin/luxnox-toggle
new file mode 100755
index 0000000..eb727d3
--- /dev/null
+++ b/bin/luxnox-toggle
@@ -0,0 +1,18 @@
+#!/bin/sh
+# Flip the system color scheme between dark (nox) and light (lux).
+# Apps that follow org.gnome.desktop.interface color-scheme (kitty via the
+# portal, GTK, later Emacs) switch on their own.
+# luxnox-toggle [dark|light]
+key=org.gnome.desktop.interface
+# Always the plain "user" dconf database, which the GTK portal reads. A shell
+# started from a session that inherited COSMIC's DCONF_PROFILE would otherwise
+# write to COSMIC's database and nothing would change.
+unset DCONF_PROFILE
+case "${1:-}" in
+ dark) want=prefer-dark ;;
+ light) want=prefer-light ;;
+ "") [ "$(gsettings get $key color-scheme)" = "'prefer-dark'" ] \
+ && want=prefer-light || want=prefer-dark ;;
+ *) echo "usage: luxnox-toggle [dark|light]" >&2; exit 2 ;;
+esac
+gsettings set $key color-scheme "$want"