.dotfiles/linux/.config/polybar/rest_timer_module/rest_timer.sh
2024-11-15 11:25:55 +01:00

24 lines
534 B
Bash
Executable file

#!/usr/bin/env sh
source ~/.config/polybar/rest_timer_module/config.sh
if [[ ! -f "$STATE_REST_TIMER" ]]; then
echo $(("$TOTAL_MINUTES" * 60)) >"$STATE_REST_TIMER"
fi
# END_TIME=$(($(date +%s) + TIMER))
REMAINING=$(cat "$STATE_REST_TIMER")
if [[ $REMAINING -le 0 ]]; then
echo "%{F#FF0000}Time to rest!%{F-}"
# rm "$STAT_REST_TIMER"
exit 0
fi
MINUTES=$((REMAINING / 60))
SECONDS=$((REMAINING % 60))
printf "%02d:%02d\n" $MINUTES $SECONDS
REMAINING=$((REMAINING - 1))
echo $REMAINING >"$STATE_REST_TIMER"
sleep 1