Now moonphase is correct and even more precise (#637)
As described in issue #636 using wttr.in was incorerct by 16% Now the `~/.local/share/moonphase` looks ugly, so dont look at it.
This commit is contained in:
parent
b8b9b420f9
commit
4dbff2873d
1 changed files with 15 additions and 23 deletions
|
@ -5,33 +5,25 @@
|
||||||
moonfile="${XDG_DATA_HOME:-$HOME/.local/share}/moonphase"
|
moonfile="${XDG_DATA_HOME:-$HOME/.local/share}/moonphase"
|
||||||
|
|
||||||
[ "$(stat -c %y "$moonfile" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
|
[ "$(stat -c %y "$moonfile" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
|
||||||
{ curl -sf "wttr.in/?format=%m" > "$moonfile" || exit 1 ;}
|
{ curl -sf 'https://www.timeanddate.com/moon/phases/' | grep -m1 -o cur-moon-percent.......................................................................................................................................................... > "$moonfile" || exit 1 ;}
|
||||||
|
|
||||||
icon="$(cat "$moonfile")"
|
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 "$icon" in
|
case "$mnphs" in
|
||||||
🌑) name="New" ;;
|
"New") icon="🌑" prcnt="0" ;;
|
||||||
🌒) name="Waxing Crescent" ;;
|
"Waxing Crescent") icon="🌒" ;;
|
||||||
🌓) name="First Quarter" ;;
|
"First Quarter") icon="🌓" prcnt="50" ;;
|
||||||
🌔) name="Waxing Gibbous" ;;
|
"Waxing Gibbous") icon="🌔" ;;
|
||||||
🌕) name="Full" ;;
|
"Full") icon="🌕" prcnt="100" ;;
|
||||||
🌖) name="Waning Gibbous" ;;
|
"Waning Gibbous") icon="🌖" ;;
|
||||||
🌗) name="Last Quarter" ;;
|
"Last Quarter") icon="🌗" prcnt="50" ;;
|
||||||
🌘) name="Waning Crescent" ;;
|
"Waning Crescent") icon="🌘" ;;
|
||||||
*) exit 1 ;;
|
*) echo exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo "${icon-?}"
|
echo ""$icon" "$prcnt"%"
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
3) notify-send "🌜 Moon phase module" "Displays current moon phase.
|
3) notify-send "🌜 Moon phase module" "$icon: $mnphs $prcnt" ;;
|
||||||
- 🌑: New
|
|
||||||
- 🌒: Waxing Crescent
|
|
||||||
- 🌓: First Quarter
|
|
||||||
- 🌔: Waxing Gibbous
|
|
||||||
- 🌕: Full
|
|
||||||
- 🌖: Waning Gibbous
|
|
||||||
- 🌗: Last Quarter
|
|
||||||
- 🌘: Waning Crescent" ;;
|
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in a new issue