blob: 5f3a8702187f3756334049a0bc0b96691bae9f51 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/usr/bin/env bash
# Displays current pomodoro status
# When clicked, brings up `newsboat`.
case $BLOCK_BUTTON in
1) setsid -f pomodoro start >/dev/null ; pkill -RTMIN+26 dwmblocks ;;
2)
setsid -f pomodoro finish >/dev/null
sh -c 'pomodoro break >/dev/null; notify-send -t 100000 "Breaktime over" "Fight against time compression. Build psychic depth. Remember."' &
pkill -RTMIN+26 dwmblocks
;;
3) notify-send "🍅 Pomodoro module" "\- Shows current pomodoro status
- Shows ⏱ if a Pomodoro is running
- Left click starts a new Pomodoro
- Middle click finishes a Pomodoro early
- Shift click opens ~/.pomodoro in editor" ; pkill -RTMIN+26 dwmblocks ;;
6) "$TERMINAL" -e "lf" "$HOME/.pomodoro" ;;
esac
if ! status=$(pomodoro status); then
exit 0
fi
if [ -z "$status" ]; then
daily_completed=$(grep -c "^$(date --iso-8601)" ~/.pomodoro/history)
daily_total="$(grep daily_goal ~/.pomodoro/settings | cut -f2 -d'=')"
msg="$daily_completed/$daily_total🍅"
if [ "$daily_completed" -ne "0" ]; then
seconds_since_last_started="$(( $(date +%s -u) - $(tail -n1 ~/.pomodoro/history | cut -f1 -d' ' | xargs -I{} date -d"{}" +%s -u) ))"
duration="$(tail -n1 ~/.pomodoro/history | cut -f2 -d' ' | cut -f2 -d'=')"
seconds_since_last="$(( "$seconds_since_last_started" - 60*${duration:-0} ))"
if [ "$seconds_since_last" -lt 0 ]; then
seconds_since_last=0
fi
msg="$(date -d@"$seconds_since_last" +"%H:%M" -u)min ago $msg"
fi
echo "$msg"
exit 0
fi
echo "$status"
|