forked from ruanyf/simple-bash-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pomodoro.sh
executable file
·44 lines (41 loc) · 1.78 KB
/
pomodoro.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
42
43
44
#!/bin/bash
# A simple shell script to use as a pomodoro app.
# The first argument is the focus time length.
# The second argument is the break length.
# Made by Kiailandi (https://github.com/kiailandi)
wseconds=${1:-25}*60;
pseconds=${2:-wseconds/300}*60;
# Check os and behave accordingly
if [ "$(uname)" == "Darwin" ]; then
while true; do
date1=$((`date +%s` + $wseconds));
while [ "$date1" -ge `date +%s` ]; do
echo -ne "$(date -u -j -f %s $(($date1 - `date +%s`)) +%H:%M:%S)\r";
done
osascript -e 'display notification "Time to walk and rest!" with title "Break"';
read -n1 -rsp $'Press any key to continue or Ctrl+C to exit...\n';
date2=$((`date +%s` + $pseconds));
while [ "$date2" -gt `date +%s` ]; do
echo -ne "$(date -u -j -f %s $(($date2 - `date +%s`)) +%H:%M:%S)\r";
done
osascript -e 'display notification "Time to get back to work" with title "Work"';
read -n1 -rsp $'Press any key to continue or Ctrl+C to exit...\n';
done
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
while true; do
date1=$((`date +%s` + $wseconds));
while [ "$date1" -ge `date +%s` ]; do
echo -ne "$(date -u --date @$(($date1 - `date +%s` )) +%H:%M:%S)\r";
done
notify-send "Break" "Time to walk and rest";
read -n1 -rsp $'Press any key to continue or Ctrl+C to exit...\n';
date2=$((`date +%s` + $pseconds));
while [ "$date2" -ge `date +%s` ]; do
echo -ne "$(date -u --date @$(($date2 - `date +%s` )) +%H:%M:%S)\r";
done
notify-send "Work" "Time to get back to work";
read -n1 -rsp $'Press any key to continue or Ctrl+C to exit...\n';
done
else
echo -ne "Your OS is currently not supported\n";
fi