Skip to content

Instantly share code, notes, and snippets.

@telescreen
Last active May 18, 2023 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save telescreen/b4e220839ba0dcdd8845f47ccd53a51f to your computer and use it in GitHub Desktop.
Save telescreen/b4e220839ba0dcdd8845f47ccd53a51f to your computer and use it in GitHub Desktop.
A simple script to send notify after a period of time passed
#!/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