Terminal multiple countdown timer app for Bash / Zsh

5,612

Solution 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.

Solution 2

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).

Solution 3

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.

Share:
5,612
somethis
Author by

somethis

Just a regular Ubuntu/Linux user - so no Windows here :) I like jamming on my guitar. Looking forward to exchanging some experience here.

Updated on September 18, 2022

Comments

  • somethis
    somethis almost 2 years

    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
    somethis over 7 years
    Great answer, I like the simplicity. Is there any way to display the time left (like a countdown), too?
  • thom
    thom over 7 years
    no, not with "at". if you would like to have a shell-window constantly open to be able to check the countdown time, you're probably better of with a while loop and the sleep command.
  • wjandrea
    wjandrea about 6 years
    This doesn't need to be a function, so it should be a script. But if you do want to leave it as a function, you should run it in a subshell to prevent affecting the variables in the interactive shell.
  • Dreamcat4
    Dreamcat4 almost 5 years
    Hey there @crocket. Have just found termdown today. If you look at my answer I have now updated it to include the running termdown for that functionality. Just a bit more creature comforts for a more pleasant user experience.
  • Paul Rougieux
    Paul Rougieux over 3 years
    A superuser question superuser.com/questions/611538/… gives a basic loop N=100; while [[ $((--N)) > 0 ]]; do echo $N && sleep 1 ; done many more elaborate answers under that question.
  • somethis
    somethis over 3 years
    Thank you, just discovered your answer and love the solution!
  • somethis
    somethis over 3 years
    Can anyone confirm this solution?
  • WinEunuuchs2Unix
    WinEunuuchs2Unix over 3 years
    @somethis I wrote the script. It's been working every Wednesday night for two years. If you have any questions don't hesitate to ask.
  • somethis
    somethis over 3 years
    Nice, thank you! Runs perfectly and I marked it as a solution to the question. Very nice script, carefully crafted.