forked from raycast/script-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpomodoro-status.sh
executable file
·41 lines (34 loc) · 1.13 KB
/
pomodoro-status.sh
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
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Status
# @raycast.mode inline
# Conditional parameters:
# @raycast.refreshTime 30s
# Optional parameters:
# @raycast.icon 🍅
# @raycast.packageName Pomodoro
# Documentation:
# @raycast.description Status of a Pomodoro timer
# @raycast.author Thomas Paul Mann
# @raycast.authorURL https://github.com/thomaspaulmann
FILENAME="pomodoro_timer_end.txt"
if [ -f "$FILENAME" ]; then
END=$(cat $FILENAME)
NOW=$(date +"%s")
TIME_REMAINING_IN_MINUTES=$(( ($END - $NOW) / 60 ))
if [ "$TIME_REMAINING_IN_MINUTES" -lt "-5" ]; then
rm $FILENAME
echo -e "\\033[31mTimer ended\\033[0m"
elif [ "$TIME_REMAINING_IN_MINUTES" -lt "0" ]; then
echo -e "\\033[31mTimer ended\\033[0m"
elif [ "$TIME_REMAINING_IN_MINUTES" -lt "3" ]; then
echo -e "\\033[31m$TIME_REMAINING_IN_MINUTES minutes remaining\\033[0m"
elif [ "$TIME_REMAINING_IN_MINUTES" -lt "10" ]; then
echo -e "\\033[33m$TIME_REMAINING_IN_MINUTES minutes remaining\\033[0m"
else
echo -e "\\033[32m$TIME_REMAINING_IN_MINUTES minutes remaining\\033[0m"
fi
else
echo "No active timer"
fi