Repository navigation
Expand file tree
/
Copy pathtimewizard.sh
More file actions
executable file
·124 lines (109 loc) · 3.01 KB
/
Copy pathtimewizard.sh
File metadata and controls
executable file
·124 lines (109 loc) · 3.01 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
# shellcheck source=/dev/null
# Usage timewizard "task name" duration(mins) interval(seconds)
trap handler INT QUIT KILL
CONFIG_FOLDER="/home/$USER/.config/timewizard"
CONFIG_HISTORY="$CONFIG_FOLDER/history.csv"
CONFIG_TAGS="$CONFIG_FOLDER/tags"
CONFIG_TIMER="$CONFIG_FOLDER/timer"
if [ ! -d "$CONFIG_FOLDER" ]; then
mkdir $CONFIG_FOLDER
fi
if [ ! -f "$CONFIG_HISTORY" ]; then
touch $CONFIG_HISTORY
fi
if [ ! -f "$CONFIG_TAGS" ]; then
touch $CONFIG_TAGS
fi
# Empty initialization just to make shellcheck stop complaining
mins=""
interval=""
task=""
source "${CONFIG_FOLDER}/timewizard.conf"
chooseTag (){
TAG=$(echo "Add new tag" | cat $CONFIG_TAGS - | gum choose --ordered --selected=45 )
if [ "$TAG" = "Add new tag" ];then
TAG=$(gum input)
echo $TAG >> $CONFIG_TAGS
fi
}
chooseTimer (){
TIMER=$(echo "Add new timer" | cat $CONFIG_TIMER - | gum choose)
if [ "$TIMER" = "Add new timer" ];then
TIMER=$(gum input)
echo $TIMER >> $CONFIG_TIMER
fi
}
saveStartHistory(){
echo $TAG,$TIMER,$(date +%d/%m/%Y),$(date +%A),$(date +%H:%M),$(date +%H:%M) >> $CONFIG_HISTORY
}
countdown() {
notify-send "${APP_NAME}" "Start: ${task}"
SECS=$1*60
start="$(( $(date '+%s') + $SECS))"
while [ $start -ge $(date +%s) ]; do
time="$(( $start - $(date +%s) ))"
printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)"
sleep 0.1
done
}
handler(){
echo "Saving and exiting!"
saveStartHistory
exit 1
}
chooseTag
chooseTimer
countdown $TIMER
saveStartHistory
# Pomodoro time start: notify user
#SECS=$(($TIMER * 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;