5

I'm looking for an app to organize my daily tasks in different countdown timers similar to the one found at www.timeanddate.com/timer/

Features I'm looking for would be:

  • runs in terminal bash or zsh
  • multiple independent countdown timers
  • plays a sound or notification display once a timer runs out

Please note that timetracking is not an important feature, just the countdown is enough.

Thank you.


enter image description here

somethis
  • 974

4 Answers4

7

From terminal use the "at" command to set your timer, "at" is very flexible for it can be used with both absolute and relative time (for more info: man at):

at now + 1 minute <<<'notify-send ALARM'

"notify-send" will place a notification on your desktop
(feel free to replace it with i.e. "aplay" to make a sound instead of a notification).

thom
  • 7,742
1

There is a bash script here in Ask Ubuntu called multi-timer

multi-timer Progress bar display

peek wash cycle.png

Features

  • Retains configuration between uses.
  • Up to 19 timers run sequentially in a set.
  • Progress bar for each timer.
  • Set of timers can be run multiple times.
  • Progress bar for set.
  • Progress bar for all sets.
  • Optional prompt to start each timer and/or set.
  • Optional pop-up message when each timer and/or set ends.
  • Optional alarm when each timer and/or set ends.
  • Optional lock screen when each timer OR set OR all sets end.
  • Optional interface to Sysmonitor Indicator so Systray shows countdowns.
  • Optional close progress bar display when all sets of timers end.

Visit the link above for screenshots and bash code.

1

You can combine tmux or screen with termdown.

Termdown is an ncurses timer.

http://www.slashgeek.net/2016/10/25/termdown-cli-countdown-timer-stopwatch/ shows how termdown works.

tmux and screen allow you to run multiple countdowns at once.

I'd make scripts like

~/.bin/pomodoro:
#!/bin/sh
termdown 25:00 && mplayer /path/to/sound.mp3

~/.bin/5minbreak:
#!/bin/sh
termdown 05:00 && mplayer /path/to/break.mp3

And, I'll execute pomodoro in a tmux or screen window. That way, I can create multiple countdowns.

Do you want notifications? You can combine notification commands with termdown, too.

I'd set up multiple tmux windows for specific timers in advance.

0

Heres a shell function have come up with today to solve this exact problem for myself. I do happen to think that it works rather well. Full usage instructions are included in the comments.

updated:

Now requires a new dependancy, termdown, for displaying a countdown timer in the terminal.

If you want to use this shell function as a script, then just copy paste it into a new file with the #!/bin/sh shebang as line 1. And then at the end of the file call the function as timer "$@" to pass all the cmdline arguments into it.

Hopefully that addresses the previously raised criticism.

timer() {
  # tested on ubuntu 18.04
  # installation: copy-paste this shell function into your ~/.bashrc or ~/.profile

  # program dependencies
  # to install missing dependancies on ubuntu
  #  # sudo apt-get install -y xcowsay
  #  # sudo snap install -y termdown 
  # this shell function also uses `paplay` (for making a beep / ding sound)
  # and `pgrep` for checking when any xcowsay window was clicked on and dismissed
  # (however on ubuntu desktop 18.04, both `paplay` and `pgrep` are already installed by default)

  # usage examples
  # input string is parsed by the unux date command. tested with "date (GNU coreutils) 8.28"
  # ... this version of date seems able to understand and translate these human-readable strings

  # timer "1h1m30s"
  # timer "1h 1m 30s"
  # timer "1 minute 30 seconds"
  # timer "15 minutes"
  # timer "2 hours 30 minutes"

  # timer "00:45:00" # = "45 minutes"
  # timer "00:00:45" # = "45 seconds"
  # timer "1:1:1"    # = 1 hour, 1 minute and 1 second

  # begin
  _time="$1"
  _bell_repeat_delay="3"

  # convert input string to seconds, and sleep until time is up
  # _seconds="$(local epoch=$(date --utc -d @0 +%F); date --utc -d "$epoch $time" +%s.%09N)"



  if echo "$_time" | grep -q -E '^[0-9]+$'; then
      _seconds="$_time"
  else
    _date_flag="$(echo "$_time" | sed  -e "s/s/SECONDS/g"  -e "s/m/MINUTES/g"  -e "s/h/HOURS/g")"
    _seconds="$(date -d "1970-01-01 00:00:00 UTC ${_date_flag}" "+%s")"
  fi

  _critical="$(echo $_seconds / 10 | bc)"
  if [ $_seconds -lt 60 ]; then
    _critical=20

  elif [ $_seconds -lt 100 ]; then
    _critical=30

  elif [ $_seconds -lt 200 ]; then
    _critical=40

  elif [ $_seconds -lt 300 ]; then
    _critical=60
  fi

  # sleep _seconds && \
  termdown --critical $_critical --voice en $_seconds && \
  (
    # handle ctrl+c gracefully
    trap "killall -q xcowsay; exit 1" INT

    # display notifications on all monitors, 1 notification per monitor
    i=0; num_monitors="$(xrandr -q| grep " connected" | wc -l)"
    while [ "$i" -lt "$num_monitors" ]; do

      # this cmd displays the notification itself, and is further customizable
      xcowsay --monitor=$i --time=0 --cow-size=large "$time is up" &
      i="$(expr $i + 1)"
    done

    _sound_file_timer_expired="/usr/share/sounds/gnome/default/alerts/drip.ogg"
    _sound_file_remind_repeat="/usr/share/sounds/freedesktop/stereo/complete.oga"

    audacious --pause
    # play -v15 "$_sound_file_timer_expired"
    paplay "$_sound_file_timer_expired"

    while true; do
      # detect if any notifications were dismissed, then exit gracefully
      num_cows="$(pgrep -c xcowsay)"
      [ "$(expr $num_monitors - $num_cows)" -gt 0 ] && break
      # make a slowly repeating ding or beep audible alert sound
      paplay "$_sound_file_remind_repeat"
      sleep $_bell_repeat_delay || break
    done

    # dismiss all of the notifications, when displayed on multiple monitors
    killall -q xcowsay
    trap - INT
  )

}
Dreamcat4
  • 189