summaryrefslogtreecommitdiffstats
path: root/.local/bin/statusbar/moonphase
diff options
context:
space:
mode:
authorHekuran <62762955+narukeh@users.noreply.github.com>2020-05-16 16:15:05 +0200
committerGitHub <noreply@github.com>2020-05-16 10:15:05 -0400
commit4dbff2873df8e2b13ecff74beb17c32ef3c3267a (patch)
tree69b6516d55f5ff25a6c7ce7619b4042ea9834f1a /.local/bin/statusbar/moonphase
parentb8b9b420f9579174369c4eeecea99e545dfd24f6 (diff)
downloadeibhear-4dbff2873df8e2b13ecff74beb17c32ef3c3267a.tar.gz
eibhear-4dbff2873df8e2b13ecff74beb17c32ef3c3267a.tar.zst
eibhear-4dbff2873df8e2b13ecff74beb17c32ef3c3267a.zip
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.
Diffstat (limited to '.local/bin/statusbar/moonphase')
-rwxr-xr-x.local/bin/statusbar/moonphase38
1 files changed, 15 insertions, 23 deletions
diff --git a/.local/bin/statusbar/moonphase b/.local/bin/statusbar/moonphase
index fab8b4d..e90dc77 100755
--- a/.local/bin/statusbar/moonphase
+++ b/.local/bin/statusbar/moonphase
@@ -5,33 +5,25 @@
moonfile="${XDG_DATA_HOME:-$HOME/.local/share}/moonphase"
[ "$(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")"
-
-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 ;;
+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 ;;
esac
-echo "${icon-?}"
+echo ""$icon" "$prcnt"%"
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" ;;
+ 3) notify-send "🌜 Moon phase module" "$icon: $mnphs $prcnt" ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac