-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.sh
More file actions
executable file
·41 lines (32 loc) · 786 Bytes
/
Copy pathtimer.sh
File metadata and controls
executable file
·41 lines (32 loc) · 786 Bytes
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
# TODO: handle adding hours
function quitter {
echo ""
echo "incorrect number of arguments"
echo "this script requires between 0 and 2 inclusive arguments"
echo "use --help if you need details of what are valid inputs"
exit 1
}
seconds=0
function add_minutes {
seconds=$(($seconds + $1*60))
}
function add_seconds {
seconds=$(($seconds + $1))
}
if [[ $# -gt 2 ]];then
# incorrect number of arguments
quitter
fi
if [[ $# -eq 1 ]];then
# only minutes added
add_minutes $1
fi
if [[ $# -eq 2 ]];then
# minutes and seconds passed
add_minutes $1
add_seconds $2
echo
fi
echo "timer set for $seconds seconds"
osascript -e "delay $seconds" -e 'display notification "Please take a break" with title "TIME IS UP" sound name "Sosumi.aiff"' 2>/dev/null & disown