From c2afe72d3f514842fefed31943b76f24aee28aaf Mon Sep 17 00:00:00 2001 From: Romain Paquet Date: Mon, 3 Nov 2025 23:51:20 +0100 Subject: [PATCH] helix: add script to reload on dark mode change --- home/.config/niri/config.kdl | 1 + home/bin/monitor-dark-mode.sh | 4 ++++ home/bin/switch-helix-theme.sh | 15 +++++++++++++++ 3 files changed, 20 insertions(+) create mode 100755 home/bin/monitor-dark-mode.sh create mode 100755 home/bin/switch-helix-theme.sh diff --git a/home/.config/niri/config.kdl b/home/.config/niri/config.kdl index d1bb2b8..21a48db 100644 --- a/home/.config/niri/config.kdl +++ b/home/.config/niri/config.kdl @@ -337,6 +337,7 @@ screenshot-path "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png" spawn-at-startup "dms" "run" spawn-at-startup "kdeconnect-indicator" +spawn-at-startup "~/rep/flocon/home/bin/monitor-dark-mode.sh" spawn-at-startup "xwayland-satellite" environment { diff --git a/home/bin/monitor-dark-mode.sh b/home/bin/monitor-dark-mode.sh new file mode 100755 index 0000000..e8cdaf4 --- /dev/null +++ b/home/bin/monitor-dark-mode.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh + +gsettings monitor org.gnome.desktop.interface color-scheme \ + | xargs -L1 "${HOME}/rep/flocon/home/bin/switch-helix-theme.sh" diff --git a/home/bin/switch-helix-theme.sh b/home/bin/switch-helix-theme.sh new file mode 100755 index 0000000..f11f803 --- /dev/null +++ b/home/bin/switch-helix-theme.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +set -euox pipefail + +HELIX_CONFIG_PATH=$(readlink -f "${HOME}/.config/helix/config.toml") +HELIX_THEME_LIGHT="zed_onelight" +HELIX_THEME_DARK="kanagawa" + +if [[ "$2" == "prefer-dark" ]]; then + sed -i "s/^theme .*/theme = \"$HELIX_THEME_DARK\"/" "$HELIX_CONFIG_PATH" +else + sed -i "s/^theme .*/theme = \"$HELIX_THEME_LIGHT\"/" "$HELIX_CONFIG_PATH" +fi + +pkill -USR1 hx || true