Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions tomatoshell
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ write_to_log() {

total_hours_used() {
printf "$YELLOW Total hours spent focused: $FIN"
awk -F ',' '{sum+=$2 * $3;} END{printf "%d", int(sum / 3600);}' $LOG
awk -F ',' '{sum+=$2 * $3;} END{printf "%d", int(sum / 3600);}' "$LOG"
printf "h 🍅🤓\n"
}

Expand Down Expand Up @@ -83,7 +83,7 @@ find_sound_system() {
play_alarm() {
# when session is finished, start the alarm
printf "Press 's' to stop alarm"
[ $1 -eq -1 ] && echo " and start next session" || echo ""
[ "$1" -eq -1 ] && echo " and start next session" || echo ""

process_name="tomatoshell_alarm"

Expand Down Expand Up @@ -131,23 +131,23 @@ countdown() {
time=$1
session_number=$2
msg="🍅Time left of session $session_number/$SESSIONS:🍅"
[ $session_number -eq -1 ] && msg="🍅Time left of break:🍅"
[ "$session_number" -eq -1 ] && msg="🍅Time left of break:🍅"

# date in seconds when countdown will end
start=$(($(date +%s) + $1));

display_countdown $start
clear

[ $session_number -ne -1 ] && notify-send -t 10000 -u "normal" "Session number $session_number finished"
[ "$session_number" -ne -1 ] && notify-send -t 10000 -u "normal" "Session number $session_number finished"

# message when session is finished
if $FIGLET
then
[ $session_number -ne -1 ] && figlet -c -t "Session $session_number/$SESSIONS finished" || figlet -c -t "Break finished"
[ "$session_number" -ne -1 ] && figlet -c -t "Session $session_number/$SESSIONS finished" || figlet -c -t "Break finished"
else

[ $session_number -ne -1 ] && echo -e ""$GREEN"Session $session_number/$SESSIONS finished$FIN" || echo -e "$GREEN""Break finished$FIN"
[ "$session_number" -ne -1 ] && echo -e ""$GREEN"Session $session_number/$SESSIONS finished$FIN" || echo -e "$GREEN""Break finished$FIN"
fi

# turn on keypress so we can receive input from user as to when to stop the alarm
Expand Down Expand Up @@ -191,10 +191,10 @@ main() {
do
clear
echo "Time left of session $i/$SESSIONS:"
countdown $TIME $i
countdown "$TIME" "$i"

# don't want to have a break after last session
[ $i -ne $SESSIONS ] && clear && echo "Time left of break:" && countdown $DELAY -1
[ "$i" -ne "$SESSIONS" ] && clear && echo "Time left of break:" && countdown "$DELAY" -1
done
}

Expand Down