my dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

18 lines
421 B

  1. #!/usr/bin/env bash
  2. future_file="$XDG_CACHE_HOME/timer_left"
  3. future="$(cat "$future_file" 2>/dev/null || date "+%s")"
  4. test $# -eq 1 \
  5. && echo "$(("$future" + "$1"))" >"$future_file" \
  6. && exit
  7. test ! -e "$future_file" && exit
  8. left="$(("$future" - $(date "+%s")))"
  9. test "$left" -le 0 \
  10. && notify-send.sh -t 600 "timer" "the time has passed" \
  11. && rm "$future_file" 2>/dev/null \
  12. && exit
  13. echo "$left"