141 lines
4 KiB
Bash
Executable file
141 lines
4 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
require() {
|
|
for cmd in "$@"; do
|
|
command -v "$cmd" >/dev/null 2>&1 || {
|
|
echo "theme: missing dependency: $cmd" >&2
|
|
exit 1
|
|
}
|
|
done
|
|
}
|
|
|
|
require gsettings
|
|
|
|
themes="daylight
|
|
midnight"
|
|
|
|
if [ -n "$1" ]; then
|
|
theme="$1"
|
|
else
|
|
case "$(uname)" in
|
|
Linux)
|
|
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
|
|
require fuzzel
|
|
count="$(printf "%s\n" "$themes" | wc -l)"
|
|
theme="$(printf "%s\n" "$themes" | fuzzel --dmenu --hide-prompt --lines="$count")"
|
|
else
|
|
require dmenu
|
|
theme="$(printf "%s\n" "$themes" | dmenu -p 'select theme: ')"
|
|
fi
|
|
;;
|
|
Darwin)
|
|
as_list="$(printf "%s\n" "$themes" | awk 'NF{printf "\"%s\",", $0}' | sed 's/,$//')"
|
|
theme="$(
|
|
osascript <<EOF
|
|
set theList to {$as_list}
|
|
set chosenTheme to (choose from list theList with title "Theme" with prompt "Pick a theme" OK button name "Apply" cancel button name "Cancel" without empty selection allowed)
|
|
if chosenTheme is false then
|
|
return ""
|
|
else
|
|
return item 1 of chosenTheme
|
|
end if
|
|
EOF
|
|
)"
|
|
;;
|
|
*) exit 1 ;;
|
|
esac
|
|
fi
|
|
|
|
[ -z "$theme" ] && exit 1
|
|
echo "$themes" | grep -Fxq "$theme" || exit 1
|
|
|
|
state_dir="${XDG_STATE_HOME:-$HOME/.local/state}"
|
|
mkdir -p "$state_dir"
|
|
printf '%s\n' "$theme" >"$state_dir/theme"
|
|
export THEME="$theme"
|
|
|
|
case "$(uname)" in
|
|
Linux)
|
|
case "$theme" in
|
|
midnight) gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' ;;
|
|
daylight) gsettings set org.gnome.desktop.interface color-scheme 'prefer-light' ;;
|
|
esac
|
|
|
|
if [ "$XDG_CURRENT_DESKTOP" = "Hyprland" ] && command -v hyprctl >/dev/null 2>&1; then
|
|
case "$theme" in
|
|
midnight)
|
|
hyprctl keyword general:col.active_border "rgb(e0e0e0)"
|
|
hyprctl keyword general:col.inactive_border "rgb(121212)"
|
|
;;
|
|
daylight)
|
|
hyprctl keyword general:col.active_border "rgb(1a1a1a)"
|
|
hyprctl keyword general:col.inactive_border "rgb(f5f5f5)"
|
|
;;
|
|
esac
|
|
|
|
cfg="${XDG_CONFIG_HOME:-$HOME/.config}"
|
|
|
|
waybar_themes="$cfg/waybar/themes"
|
|
[ -f "$waybar_themes/$theme.css" ] && {
|
|
ln -sf "$waybar_themes/$theme.css" "$waybar_themes/theme.css"
|
|
pkill -USR2 waybar
|
|
}
|
|
|
|
hypr_themes="$cfg/hypr/themes"
|
|
[ -f "$hypr_themes/$theme.conf" ] && {
|
|
ln -sf "$hypr_themes/$theme.conf" "$hypr_themes/theme.conf"
|
|
}
|
|
|
|
sioyek_themes="$cfg/sioyek/themes"
|
|
[ -f "$sioyek_themes/$theme.config" ] && {
|
|
ln -sf "$sioyek_themes/$theme.config" "$sioyek_themes/theme.config"
|
|
}
|
|
|
|
fzf_themes="$cfg/fzf/themes"
|
|
[ -f "$fzf_themes/$theme" ] && {
|
|
ln -sf "$fzf_themes/$theme" "$fzf_themes/theme"
|
|
}
|
|
|
|
fuzzel_themes="$cfg/fuzzel/themes"
|
|
[ -f "$fuzzel_themes/$theme.ini" ] && {
|
|
ln -sf "$fuzzel_themes/$theme.ini" "$fuzzel_themes/theme.ini"
|
|
}
|
|
|
|
dunst_themes="$cfg/dunst/themes"
|
|
[ -f "$dunst_themes/$theme.conf" ] && {
|
|
mkdir -p "$cfg/dunst/dunstrc.d"
|
|
ln -sf "$dunst_themes/$theme.conf" "$cfg/dunst/dunstrc.d/theme.conf"
|
|
dunstctl reload
|
|
}
|
|
|
|
fi
|
|
;;
|
|
Darwin)
|
|
case "$theme" in
|
|
daylight) osascript -e 'tell app "System Events" to tell appearance preferences to set dark mode to false' 2>/dev/null || true ;;
|
|
midnight) osascript -e 'tell app "System Events" to tell appearance preferences to set dark mode to true' 2>/dev/null || true ;;
|
|
esac
|
|
;;
|
|
esac
|
|
|
|
if [ -n "$TMUX" ]; then
|
|
tmux_themes="${XDG_CONFIG_HOME:-$HOME/.config}/tmux/themes"
|
|
[ -f "$tmux_themes/$theme.conf" ] && tmux source "$tmux_themes/$theme.conf"
|
|
tmux setenv -g THEME "$theme"
|
|
fi
|
|
|
|
if command -v claude >/dev/null 2>&1 && command -v jq >/dev/null 2>&1; then
|
|
CLAUDE_CONFIG="${CLAUDE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/claude}/.claude.json"
|
|
case "$theme" in
|
|
midnight) claude_theme='dark' ;;
|
|
daylight) claude_theme='light' ;;
|
|
esac
|
|
[ -f "$CLAUDE_CONFIG" ] && {
|
|
jq ".theme=\"$claude_theme\"" "$CLAUDE_CONFIG" >"$CLAUDE_CONFIG.tmp" &&
|
|
mv "$CLAUDE_CONFIG.tmp" "$CLAUDE_CONFIG"
|
|
}
|
|
fi
|
|
|
|
for socket in /run/user/"$(id -u)"/nvim.*.0 /tmp/nvim-*.sock; do
|
|
[ -S "$socket" ] && nvim --server "$socket" --remote-expr "luaeval('require(\"config.fzf_reload\").reload()')" 2>/dev/null || true
|
|
done
|