Last active
June 5, 2018 06:35
-
-
Save 4np/5421296 to your computer and use it in GitHub Desktop.
Calculate the number of seconds until weekend :) Works especially well together with Geektools and bash geeklet that runs every second... Shows a party hat (π) when it's weekend :)
This file contains hidden or 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/sh | |
NOW=`date +"%s"` | |
NEXT_FRIDAY=`date -v+fri +"%m%d"` | |
FRIDAY_5PM=`date -j $NEXT_FRIDAY"1700" +"%s"` | |
SECONDS_LEFT=$[$FRIDAY_5PM - $NOW] | |
DAY_OF_THE_WEEK=`date +"%u"` | |
# is it weekend yet? | |
if [[ ( $SECONDS_LEFT -lt 0 || $DAY_OF_THE_WEEK > 5 ) ]]; then | |
# yes! It's weekend | |
if [ $SECONDS_LEFT -gt -2 && $SECONDS_LEFT -lt 0 ]; then | |
# weekend just started, say it! | |
say "Oh yeah! It is weekend!" | |
fi | |
echo "ππ»πΈ" | |
else | |
# output the number of seconds until it's weekend | |
echo "β° $SECONDS_LEFT" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
counting down to Friday 17:00...
it's weekend!