2020-02-13 12:38:29 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2020-05-09 12:35:02 +00:00
|
|
|
# Shows the current moon phase.
|
2020-04-09 02:01:51 +00:00
|
|
|
|
2020-05-09 12:35:02 +00:00
|
|
|
moonfile="${XDG_DATA_HOME:-$HOME/.local/share}/moonphase"
|
|
|
|
|
|
|
|
[ "$(stat -c %y "$moonfile" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
|
2020-05-16 14:15:05 +00:00
|
|
|
{ curl -sf 'https://www.timeanddate.com/moon/phases/' | grep -m1 -o cur-moon-percent.......................................................................................................................................................... > "$moonfile" || exit 1 ;}
|
2020-05-09 12:35:02 +00:00
|
|
|
|
2020-05-16 14:15:05 +00:00
|
|
|
mnphs=$( cat $moonfile | grep -o 'New\|Waxing Crescent\|First Quarter\|Waxing Gibbous\|Full\|Waning Gibbous\|Last Quarter\|Waning Crescent' | grep -m1 '.')
|
|
|
|
prcnt=$( cat $moonfile | grep -o "[0-9.0-9]*%" | grep -o "[0-9.0-9]*" )
|
|
|
|
case "$mnphs" in
|
|
|
|
"New") icon="🌑" prcnt="0" ;;
|
|
|
|
"Waxing Crescent") icon="🌒" ;;
|
|
|
|
"First Quarter") icon="🌓" prcnt="50" ;;
|
|
|
|
"Waxing Gibbous") icon="🌔" ;;
|
|
|
|
"Full") icon="🌕" prcnt="100" ;;
|
|
|
|
"Waning Gibbous") icon="🌖" ;;
|
|
|
|
"Last Quarter") icon="🌗" prcnt="50" ;;
|
|
|
|
"Waning Crescent") icon="🌘" ;;
|
|
|
|
*) echo exit 1 ;;
|
2020-02-13 12:38:29 +00:00
|
|
|
esac
|
|
|
|
|
2020-05-16 14:15:05 +00:00
|
|
|
echo ""$icon" "$prcnt"%"
|
2020-05-09 12:35:02 +00:00
|
|
|
|
2020-05-07 21:31:42 +00:00
|
|
|
case $BLOCK_BUTTON in
|
2020-05-16 14:15:05 +00:00
|
|
|
3) notify-send "🌜 Moon phase module" "$icon: $mnphs $prcnt" ;;
|
2020-05-07 21:31:42 +00:00
|
|
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
2020-04-01 14:38:03 +00:00
|
|
|
esac
|