Created
April 16, 2017 07:43
-
-
Save diffficult/eabb2fd88befd79976d8fc14609e19f8 to your computer and use it in GitHub Desktop.
Moonphase blocklet for i3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
moonphase(){ | |
local lp=2551443 | |
local now=$(date -u +"%s") | |
local newmoon=592500 | |
local phase=$((($now - $newmoon) % $lp)) | |
local phase_number=$((((phase / 86400) + 1)*100000)) | |
# Multiply by 100000 so we can do integer comparison. Go Bash! | |
if [ $phase_number -lt 184566 ]; then phase_icon="○" # new | |
elif [ $phase_number -lt 553699 ]; then phase_icon="❩" # waxing crescent | |
elif [ $phase_number -lt 922831 ]; then phase_icon="◗" # first quarter | |
elif [ $phase_number -lt 1291963 ]; then phase_icon="◑" # first quarter | |
elif [ $phase_number -lt 1661096 ]; then phase_icon="●" # full | |
elif [ $phase_number -lt 2030228 ]; then phase_icon="◐" # waning gibbous | |
elif [ $phase_number -lt 2399361 ]; then phase_icon="◖" # last quarter | |
elif [ $phase_number -lt 2768493 ]; then phase_icon="❨" # waning crescent | |
else | |
phase_icon="○" # new | |
fi | |
echo $phase_icon | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment