dotfiles

My dotfiles: zsh, lf, sxiv, i3, ranger, mpd and more
Log | Files | Refs | Submodules | README | LICENSE

moonphase (867B)


      1 #!/bin/sh
      2 
      3 # Shows the current moon phase.
      4 
      5 moonfile="${XDG_DATA_HOME:-$HOME/.local/share}/moonphase"
      6 
      7 [ "$(stat -c %y "$moonfile" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
      8 	{ curl -sf "wttr.in/?format=%m" > "$moonfile" || exit 1 ;}
      9 
     10 icon="$(cat "$moonfile")"
     11 
     12 case "$icon" in
     13 	🌑) name="New" ;;
     14 	🌒) name="Waxing Crescent" ;;
     15 	🌓) name="First Quarter" ;;
     16 	🌔) name="Waxing Gibbous" ;;
     17 	🌕) name="Full" ;;
     18 	🌖) name="Waning Gibbous" ;;
     19 	🌗) name="Last Quarter" ;;
     20 	🌘) name="Waning Crescent" ;;
     21 	*) exit 1 ;;
     22 esac
     23 
     24 echo "${icon-?}"
     25 
     26 case $BLOCK_BUTTON in
     27 	3) notify-send "🌜 Moon phase module" "Displays current moon phase.
     28 - 🌑: New
     29 - 🌒: Waxing Crescent
     30 - 🌓: First Quarter
     31 - 🌔: Waxing Gibbous
     32 - 🌕: Full
     33 - 🌖: Waning Gibbous
     34 - 🌗: Last Quarter
     35 - 🌘: Waning Crescent" ;;
     36 	6) "$TERMINAL" -e "$EDITOR" "$0" ;;
     37 esac