Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Countdown timer alarm script


  • Please log in to reply
4 replies to this topic

#1 Al1000

Al1000

  • Global Moderator
  • 7,198 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Scotland
  • Local time:05:53 PM

Posted 13 October 2016 - 08:55 AM

Here's a simple bash script for a countdown timer alarm which runs in a terminal, that you can use with an existing media player and sound file on your computer. It uses the echo, read and sleep commands.
  • Copy and paste the script into a file.
  • Change "name_of_media_player" to the name of a media player on your computer.
  • Change "path_to_sound_file" to a path to a sound file on your computer.
#!/bin/bash
echo enter hours
read hours
echo enter minutes
read minutes
sleep ${hours}h && sleep ${minutes}m && name_of_media_player path_to_sound_file
For example if I use Amarok media player and 04.Turn!_Turn!_Turn!_.ogg for a sound file which is in my user's Music directory, the script looks like this:
 
#!/bin/bash
echo enter hours
read hours
echo enter minutes
read minutes
sleep ${hours}h && sleep ${minutes}m && amarok ~/Music/"04.Turn!_Turn!_Turn!_.ogg"
To set the timer:
  • In a terminal type the following, changing "name_of_file" to whatever you named the file that contains the script
    bash name_of_file
  • You will now be asked how many hours you want to set the timer for. Type the number of hours (type 0 to set timer for less than one hour), then press Enter on your keyboard.
  • Then you will be asked to enter minutes. Type the number of minutes you want to set the timer for, then press Enter on your keyboard.
The timer is now set.

To cancel the timer, press Ctrl^c on your keyboard (hold down Ctrl and press c).

Please let me know if you have any questions. :)

Edited by Al1000, 14 October 2016 - 02:14 AM.
format and clarity


BC AdBot (Login to Remove)

 


#2 Guest_hollowface_*

Guest_hollowface_*

  • Guests
  • OFFLINE
  •  

Posted 13 October 2016 - 12:50 PM

Nice work AI1000 :)



#3 Al1000

Al1000
  • Topic Starter

  • Global Moderator
  • 7,198 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Scotland

Posted 14 October 2016 - 01:45 AM

Thanks hollowface!

I had been looking for a lightweight alarm clock that would work in AntiX without having to install a bunch of extra packages, and had tried a couple without success.

While this isn't quite an alarm clock, with a little mental arithmetic it does the same job, and you don't get much lighter than this. :)

#4 DeimosChaos

DeimosChaos

  • BC Advisor
  • 1,418 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:United States, Delaware
  • Local time:05:53 PM

Posted 14 October 2016 - 08:47 AM

All you need to do know is adapt this into a Tcl GUI script and attach a small LED screen to a Raspberry Pi! Your own handmade clock! I've actually thought about doing this (I have two Pi devices) just haven't gotten to it....


OS - Ubuntu 14.04/16.04 & Windows 10
Custom Desktop PC / Lenovo Y580 / Sager NP8258 / Dell XPS 13 (9350)
_____________________________________________________
Bachelor of Science in Computing Security from Drexel University
Security +


#5 Al1000

Al1000
  • Topic Starter

  • Global Moderator
  • 7,198 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Scotland
  • Local time:12:53 PM

Posted 14 October 2016 - 09:11 AM

At last! Something useful that can be done with a Raspberry Pi! :)

---------------------------------

Here's a site I found that has free downloadable sound effects in mp3 and wav format which are ideal for the alarm.

http://soundbible.com/tags-bell.html




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users