diff --git a/sway/.config/sway/config b/sway/.config/sway/config index 87eb334..c787676 100644 --- a/sway/.config/sway/config +++ b/sway/.config/sway/config @@ -4,6 +4,8 @@ exec_always ~/.config/sway/scripts/workspace-colors.py exec_always eww daemon && (eww open bar0 || true) && (eww open bar1 || true) exec_always mako +exec /usr/libexec/polkit-mate-authentication-agent-1 + exec swayidle -w \ timeout 900 '~/.local/bin/smart-dim.sh' \ resume 'brightnessctl -r' @@ -143,6 +145,9 @@ mode "resize" { } bindsym $mod+r mode "resize" # +# Toggle dark/light theme +bindsym $mod+y exec ~/.config/sway/scripts/toggle-theme.sh + # Utilities: # # Special keys to adjust volume via PulseAudio diff --git a/sway/.config/sway/scripts/toggle-theme.sh b/sway/.config/sway/scripts/toggle-theme.sh new file mode 100755 index 0000000..7d9ee5d --- /dev/null +++ b/sway/.config/sway/scripts/toggle-theme.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# Toggle between dark and light themes for wezterm and nvim +# Source of truth: ~/.config/theme-state + +STATE_FILE="$HOME/.config/theme-state" + +# Read current state +current="dark" +if [ -f "$STATE_FILE" ]; then + current=$(cat "$STATE_FILE" | tr -d '[:space:]') +fi + +# Toggle +if [ "$current" = "light" ]; then + next="dark" +else + next="light" +fi + +# Write new state +# - wezterm watches this file via add_to_config_reload_watch_list and auto-reloads +# - nvim watches this file via vim.uv.fs_event and auto-switches colorscheme +echo "$next" > "$STATE_FILE"