Repository navigation
Expand file tree
/
Copy pathtimewizard.sh.backup
More file actions
executable file
·67 lines (55 loc) · 1.73 KB
/
Copy pathtimewizard.sh.backup
File metadata and controls
executable file
·67 lines (55 loc) · 1.73 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# shellcheck source=/dev/null
# Usage timewizard "task name" duration(mins) interval(seconds)
CONFIG_FOLDER="/home/$USER/.timewizard"
# Empty initialization just to make shellcheck stop complaining
mins=""
interval=""
task=""
source "${CONFIG_FOLDER}/timewizard.conf"
# Pomodoro time start: notify user
secs=$(( mins * 60 ))
loops=$((secs / interval))
notify-send "${APP_NAME}" "Start: ${task}"
# Progress bar loop
if [ "${BAR_PROGRESS}" == "yes" ]; then
SECONDS=0
for ((i=0; i<loops; i++))
do
duration=$SECONDS;
percentage="$(( 100 - 100*(secs - duration) / secs ))";
bar1_w=$(( percentage * BAR_WIDTH / 100 ));
bar2_w=$(( BAR_WIDTH - bar1_w ));
bar1_s=$(printf "%${bar1_w}s" | tr " " "|")
bar2_s=$(printf "%${bar2_w}s" | tr " " ".")
progress="${bar1_s}${bar2_s}"
time_left_str="$(( (secs - duration) / 60 )):$(( (secs - duration) % 60 ))";
percentage_str="${percentage}%"
printf "\r%s Time left %s (%s) " "${task}: $progress" "$time_left_str" "$percentage_str"
# Did time pass?
if (( duration > secs )); then
printf "\r\033[K%s: Done! \n" "${task}"
break;
fi
sleep "$interval";
[ "${TICKS}" == "yes" ] && ${PLAYER} "${SOUND_CLICK_FILE}" 2> /dev/null
done
else
# Sleep for the time specified
sleep "$secs";
fi
# Time end:
# Play sound
[ "${SOUND}" == "yes" ] && ${PLAYER} "${SOUND_FILE}" 2> /dev/null
notify-send "${APP_NAME}" "End: ${task}"
# Verify and call the screen locker
if [[ -n "${locker}" ]]; then
if ! command -v ${locker} &> /dev/null
then
notify-send "${APP_NAME}" "Display locker ${locker} not found"
fi
sleep 5;
${locker}
exit;
fi
exit;