#!/bin/bash NVIM_CONF="${HOME}/.config/nvim/init.lua" GHOSTTY_CONF="${HOME}/.config/ghostty/config" DUNST_CONF="${HOME}/.config/dunst/dunstrc" [ -f "$NVIM_CONF" ] || { echo "Missing $NVIM_CONF"; exit 1; } [ -f "$GHOSTTY_CONF" ] || { echo "Missing $GHOSTTY_CONF"; exit 1; } [ -f "$DUNST_CONF" ] || { echo "Missing $DUNST_CONF"; exit 1; } set_light_mode() { sed -E -i 's/^([[:space:]]*theme[[:space:]]*=[[:space:]]*)zenwritten-dark/\1zenwritten-light/' "$GHOSTTY_CONF" sed -E -i 's/(vim.g.light_mode[[:space:]]*=[[:space:]]*).*/\1true/' "$NVIM_CONF" MODE="light" } set_dark_mode() { sed -E -i 's/^([[:space:]]*theme[[:space:]]*=[[:space:]]*)zenwritten-light/\1zenwritten-dark/' "$GHOSTTY_CONF" sed -E -i 's/(vim.g.light_mode[[:space:]]*=[[:space:]]*).*/\1false/' "$NVIM_CONF" MODE="dark" } toggle_mode() { if grep -Eq '^\s*theme\s*=\s*zenwritten-light' "$GHOSTTY_CONF"; then set_dark_mode else set_light_mode fi } case "$1" in light) set_light_mode ;; dark) set_dark_mode ;; toggle|*) toggle_mode ;; esac # Reload neovim theme if [ "$MODE" = "light" ]; then keys=$':silent! let g:light_mode=1 | set background=light | doautocmd ColorScheme | redraw!' else keys=$':silent! let g:light_mode=0 | set background=dark | doautocmd ColorScheme | redraw!' fi for dir in "${XDG_RUNTIME_DIR:-}" "${TMPDIR:-/tmp}" "/tmp" "$HOME/.local/state/nvim"; do [ -d "$dir" ] || continue find "$dir" -type s -name 'nvim*' 2>/dev/null | while read -r sock; do timeout 1s nvim --server "$sock" --remote-send "$keys" >/dev/null 2>&1 || true done done # Reload Ghostty: send SIGUSR2 to running ghostty processes (macOS/Linux) pkill -USR2 -x ghostty 2>/dev/null echo "Switched to ${MODE} mode" # Script for changing between light and dark modes on Linux if [ "$(uname)" != "Darwin" ]; then if [ "$MODE" == "dark" ]; then echo "Swapping to dark mode" # GTK Theme gsettings set org.gnome.desktop.interface gtk-theme '' gsettings set org.gnome.desktop.interface gtk-theme 'WhiteSur-Dark' gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' sed -i -e 's@Net/ThemeName.*@Net/ThemeName "WhiteSur-Dark"@' ~/.xsettingsd # Rofi theme sed -i -e "s/light.rasi/dark.rasi/" $HOME/.config/rofi/config.rasi # Swap dunst urgency_low background and foreground sed -E -i '/^\[urgency_low\]/,/^\[.*\]/ { s/^([[:space:]]*background[[:space:]]*=[[:space:]]*).*/\1"#3d3839"/ s/^([[:space:]]*foreground[[:space:]]*=[[:space:]]*).*/\1"#8e8e8e"/ }' "$DUNST_CONF" # Swap dunst urgency_normal background and foreground sed -E -i '/^\[urgency_normal\]/,/^\[.*\]/ { s/^([[:space:]]*background[[:space:]]*=[[:space:]]*).*/\1"#3d3839"/ s/^([[:space:]]*foreground[[:space:]]*=[[:space:]]*).*/\1"#BBBBBB"/ }' "$DUNST_CONF" else echo "Swapping to light mode" # GTK Theme gsettings set org.gnome.desktop.interface gtk-theme '' gsettings set org.gnome.desktop.interface gtk-theme 'WhiteSur-Light' gsettings set org.gnome.desktop.interface color-scheme 'default' sed -i -e 's@Net/ThemeName.*@Net/ThemeName "WhiteSur-Light"@' ~/.xsettingsd # Swap dunst urgency_low background and foreground sed -E -i '/^\[urgency_low\]/,/^\[.*\]/ { s/^([[:space:]]*background[[:space:]]*=[[:space:]]*).*/\1"#8e8e8e"/ s/^([[:space:]]*foreground[[:space:]]*=[[:space:]]*).*/\1"#3d3839"/ }' "$DUNST_CONF" # Swap dunst urgency_normal background and foreground sed -E -i '/^\[urgency_normal\]/,/^\[.*\]/ { s/^([[:space:]]*background[[:space:]]*=[[:space:]]*).*/\1"#BBBBBB"/ s/^([[:space:]]*foreground[[:space:]]*=[[:space:]]*).*/\1"#191919"/ }' "$DUNST_CONF" # Rofi theme sed -i -e "s/dark.rasi/light.rasi/" $HOME/.config/rofi/config.rasi fi killall dunst killall -HUP xsettingsd fi