Timer program

Could someone please recommend a simple CLI timer program? That accepts a number of minutes, and plays a sound. Or perhaps the same someone could comment on why this script which works with other OS’es fails here.

#!/bin/bash


#Author: Rossana Motta -  email: rossana.hell.no.127.0.0.1@gmail.com - http://ww2.cs.fsu.edu/~motta
#Version: 1
#Date: June 23rd 2007

VALUE=`kdialog --inputbox "How many minutes do you want to set?" 5`;

SNDFILE="$HOME/bin/timer.wav"


if [[ $VALUE == "" ]]
then
    exit;
fi

VALUEMIN=$(echo "$VALUE*60" | bc)

sleep $VALUEMIN

if [ -s $SNDFILE ]
	then 
		aplay $SNDFILE $SNDFILE $SNDFILE $SNDFILE
	else
		(kdialog --msgbox "Error: file $SNDFILE does not exist. Modify the source code setting a valid full path to a supported file (.wav or .au for example)" --title "Not existing file"; exit)
fi




Do you have the packages alsa-utils, bc and kdialog installed?

For working with the CLI, I still use good old at, as in

$ echo "aplay timer.wav" | at now + 5 minutes

(Substitute your audio player for aplay and your file for timer.wav.)

You might need to install and activate at and the atd first:

$ pacman -Syu at
$ systemctl enable --now atd

(EDIT: Forgot the “echo” above, edited.)

I like the simplicity of you suggestion, but unfortunately aplay produces white noise trying to play any sound file. I’ll work on a solution.

I do now thanks to your sharp eye and everything works.

1 Like

You need to use a wav file. It can’t play an mp3

Using aplay was just an example, you could use almost any audio player you’ve installed, like maybe paplay, mpd or others.

You should have marked @dalto’ s answer as the solution. Give credit where credit is due.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.