voidrice/.local/bin/statusbar/sb-moonphase
Jameson 7a96fb100c
script fixes (#1386)
* fix typo in lfub

* use setsid when editing scripts

* fix immediate exit on middle click

---------

Co-authored-by: 2084x <2084x@noreply.codeberg.org>
2023-12-30 17:04:51 +00:00

37 lines
899 B
Bash
Executable file

#!/bin/sh
# Shows the current moon phase.
moonfile="${XDG_DATA_HOME:-$HOME/.local/share}/moonphase"
[ -s "$moonfile" ] && [ "$(stat -c %y "$moonfile" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
{ curl -sf "wttr.in/?format=%m" > "$moonfile" || exit 1 ;}
icon="$(cat "$moonfile")"
case "$icon" in
🌑) name="New" ;;
🌒) name="Waxing Crescent" ;;
🌓) name="First Quarter" ;;
🌔) name="Waxing Gibbous" ;;
🌕) name="Full" ;;
🌖) name="Waning Gibbous" ;;
🌗) name="Last Quarter" ;;
🌘) name="Waning Crescent" ;;
*) exit 1 ;;
esac
echo "${icon-?}"
case $BLOCK_BUTTON in
3) notify-send "🌜 Moon phase module" "Displays current moon phase.
- 🌑: New
- 🌒: Waxing Crescent
- 🌓: First Quarter
- 🌔: Waxing Gibbous
- 🌕: Full
- 🌖: Waning Gibbous
- 🌗: Last Quarter
- 🌘: Waning Crescent" ;;
6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
esac