Skip to content

Instantly share code, notes, and snippets.

@spjwebster
Created October 12, 2016 17:55
Show Gist options
  • Save spjwebster/0fe7d31ff7892ba21abddfa5437a6494 to your computer and use it in GitHub Desktop.
Save spjwebster/0fe7d31ff7892ba21abddfa5437a6494 to your computer and use it in GitHub Desktop.
Ridiculously contribed BitBar clock that displays rounded time as an emoji
#!/bin/sh
function clock_emoji {
time_hour=$1
time_minute=$2
# Round to 30-minute intervals
time_minute=$(( (time_minute + 15) / 30 * 30 ))
# If we've rounded up, move to next hour (checking for overflow)
if [ $time_minute == 60 ]; then
time_minute=0
time_hour=$(($time_hour+1))
if [ $time_hour = 13 ]; then
time_hour=1
fi
fi
# Empty minutes if minutes is zero
if [ $time_minute = 0 ]; then
time_minute=""
fi
printf ":clock%s%s:" $time_hour $time_minute
}
time_hour=$(( 0 + `date "+%l"` ))
time_minute=$(( 0 + `date "+%M"` ))
am_pm=$(date "+%p")
face=$(clock_emoji $time_hour $time_minute)
printf "%s %s:%02d %s\n" $face $time_hour $time_minute $am_pm
echo "---"
date "+%A, %e %B %Y"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment