Hey,
I recently made a timer script for my waybar. Maybe someone else may want to use it, so here it is.
Also, is there maybe another way of doing it or does anyone have suggestions on how to make it a bit better?
Put this inside the waybar config file:
"custom/timer": {
"tooltip": false,
"min-length": 5,
"exec": "$HOME/.config/waybar/modules/timer.sh",
"on-click": "date --date='5 minutes' +%s > /var/tmp/waybar_timer",
"on-click-right": "echo READY > /var/tmp/waybar_timer",
"on-click-middle": "date --date='1 minute' +%s > /var/tmp/waybar_timer",
"on-scroll-up": "date --date='5 seconds' +%s > /var/tmp/waybar_timer",
"on-scroll-down": "date --date='30 minutes' +%s > /var/tmp/waybar_timer",
"interval": 1
}
Put this into $HOME/.config/waybar/modules/timer.sh
or make changes according to another path inside the waybar config file. Also you need a timer.wav sound file.
#!/bin/sh
CUR_TIME=$(date +%s)
STATUS=$(cat /var/tmp/waybar_timer)
if [ $STATUS == "READY" ]; then
echo ""
elif [ $STATUS == "FINISHED" ]; then
mpv $HOME/.config/waybar/modules/timer.wav &
echo "READY" > /var/tmp/waybar_timer
echo ""
elif [[ $STATUS > $CUR_TIME ]]; then
DIFF=$(( (STATUS - CUR_TIME) ))
echo $( date -d @$DIFF +%M:%S )
else
if [ -f "/var/tmp/waybar_timer" ]; then
echo "FINISHED" > /var/tmp/waybar_timer
echo ""
else
echo "READY" > /var/tmp/waybar_timer
echo ""
fi
fi