dotfiles/polybar/.config/polybar/scripts/poly-date

32 lines
561 B
Bash
Executable File

#!/usr/bin/env sh
update_time=5
mode=${1:-0}
separator='  '
short_date_string='%d/%m'"${separator}"'%H:%M'
long_date_string='%A, %d %B %Y (CW %V)'"${separator}"'%H:%M:%S'
modetoggle() {
mode=$(((mode + 1) % 2))
}
trap "modetoggle" USR1
display_date() {
if [ "$1" = "long" ]; then
date +"${long_date_string}"
else
date +"${short_date_string}"
fi
}
while true; do
if [ $mode -eq 0 ]; then
display_date short
elif [ $mode -eq 1 ]; then
display_date long
fi
sleep $update_time &
wait
done