This commit is contained in:
Tibo De Peuter 2024-11-10 20:18:46 +01:00
parent 31a4c4060a
commit aeb8f52d6d
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
23 changed files with 569 additions and 304 deletions

View file

@ -30,6 +30,10 @@ declare -A wallpaper
wallpaper[${THEME_LIGHT}]="bg-light"
wallpaper[${THEME_DARK}]="bg-dark"
declare -A icon
icon[${THEME_LIGHT}]="\uf185"
icon[${THEME_DARK}]="\uf186"
#############
### Logic ###
#############
@ -48,14 +52,14 @@ while getopts ":m:g" option; do
fi
;;
g)
previous_theme="$(cat ${STATE_FILE})"
if [ "${previous_theme}" == "${THEME_LIGHT}" ]; then
current_state="$(cat "${STATE_FILE}")"
next_state="${theme_next[${current_state}]}"
if [ "${current_state}" == "${THEME_DARK}" ]; then
class="activated"
percentage=1
else
percentage=0
percentage=100
fi
printf '{ "class": "%s", "percentage": %d }' "${class}" "${percentage}"
printf '{"text": "%s", "alt": "%s", "tooltip": "Set theme to %s", "percentage": %d, "class": "%s"}' \
"${icon[${next_state}]}" "${gsettings_alt[${next_state}]}" "${next_state}" "${percentage:=0}" "${class:="none"}"
exit 0
;;
*)
@ -120,6 +124,7 @@ fi
if [ "$(command -v swaybg)" ]; then
bg_path="${BG_DIR}/${wallpaper[${theme}]}"
/run/current-system/sw/bin/cp "${bg_path}" "${STATE_DIR}/bg" && swaymsg reload &
# pkill --signal 13 "waybar" &
fi
# Vifm