sway dark/light switch
This commit is contained in:
@@ -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
|
||||
|
||||
23
sway/.config/sway/scripts/toggle-theme.sh
Executable file
23
sway/.config/sway/scripts/toggle-theme.sh
Executable file
@@ -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"
|
||||
Reference in New Issue
Block a user