Created
December 23, 2018 12:53
-
-
Save kuniyoshi/e9765b1755b41cc445203b99ee6861f4 to your computer and use it in GitHub Desktop.
This script alerts pomodoro timer. `play_utc_voice.sh` plays unity chan's voice to announce it is time to switch pomodoro.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
project="$1" | |
title="$*" | |
log_file=~/logs/pomodoro.log | |
notification_interval_seconds=10 | |
lock_file=/tmp/pomodoro.is_notifying | |
interval_lock_file=/tmp/pomodoro.is_in_interval | |
pomodoro_seconds=$((25 * 60)) | |
pomodoro_interval_seconds=$((5 * 60)) | |
started_at=$(date +%FT%T) | |
echo -e "$started_at\t$project\t$title" >>"$log_file" | |
sleep "$pomodoro_seconds" | |
started_at=$(date +%s) | |
touch "$lock_file" | |
while [ -e "$lock_file" ] | |
do | |
elapsed=$(($(date +%s) - started_at)) | |
terminal-notifier -title "START INTERVAL" \ | |
-message "$title - $project, elapsed: $elapsed" \ | |
-execute "rm $lock_file" | |
play_utc_voice.sh | |
sleep "$notification_interval_seconds" | |
done | |
sleep "$pomodoro_interval_seconds" | |
started_at=$(date +%s) | |
touch "$interval_lock_file" | |
while [ -e "$interval_lock_file" ] | |
do | |
elapsed=$(($(date +%s) - started_at)) | |
terminal-notifier -title "DONE POMODORO" \ | |
-message "$title - $project, elapsed: $elapsed" \ | |
-execute "rm $interval_lock_file" | |
play_utc_voice.sh | |
sleep "$notification_interval_seconds" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment