Last active
May 18, 2023 02:49
-
-
Save telescreen/b4e220839ba0dcdd8845f47ccd53a51f to your computer and use it in GitHub Desktop.
A simple script to send notify after a period of time passed
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 | |
DB=~/.pomodoro.db | |
if [ ! -f $DB ]; then | |
sqlite3 $DB "CREATE TABLE timerecord ( record_time text, duration text);" | |
fi | |
# Count down $1 number of seconds | |
countdown() { | |
start="$(( $(date +%s) + $1))" | |
while [ "$start" -ge $(date +%s) ]; do | |
days="$(($(($(( $start - $(date +%s) )) * 1 )) / 86400))" | |
time="$(( $start - `date +%s` ))" | |
sleep 0.1 | |
done | |
sqlite3 $DB "INSERT INTO timerecord VALUES (\"$(date +"%Y/%m/%d %H:%m:%S")\", \"$1\")" | |
notify-send -u critical -t 5 -i dialog-information "$(date)" "$2" | |
} | |
countdown $1 "Time to take a break" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment