Create Simple Countdown Timer for Debian with Xfce

Case: You use Debian with Xfce Desktop Environment, you need a simple countdown timer and no package convinces you.

Requisites: Packages libnotify and pulseaudio are installed.

Steps:
  • Open a text editor and copy this code:


    #!/bin/bash

    hour=$1
    min=$2
    sec=$3

    while [ $hour -ge 0 ]; do
             while [ $min -ge 0 ]; do
                     while [ $sec -ge 0 ]; do
                             echo -ne "$hour:$min:$sec\r"
                             let "sec=sec-1"
                             sleep 1
                     done
                     sec=59
                     let "min=min-1"
             done
             min=59
             let "hour=hour-1"
    done

    notify-send --urgency CRITICAL "Countdown is over!"
    paplay /usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga



  • Customize the message by editing "Countdown is over!" (don't remove the ") and the sound by changing the audio file path (/usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga).

  • Save the file with an easy name, e.g. countdownApp.

  • You can run the file by opening a terminal, going to the directory file and running ./file_name <hours> <minutes> <seconds> :

    Run countdown in terminal

  • If you want to run it from any directory, put the file in /usr/local/bin and run it without ./ :

    Run countdown from any folder
Results: The countdown timer will start showing the time moving:

And it will notify you when it's over with a message and a sound:
 
Countdown starts


Comments

Popular posts from this blog

I Need to Send an Automatic Email with Lotus Notes

Turn Horizontal Visio Swimlanes into Vertical Ones

Install TWRP Recovery in Xiaomi Redmi 6A