Turn your computer into a digital radio alarm clock

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
Pilosopong Tasyo
Level 6
Level 6
Posts: 1432
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines

Turn your computer into a digital radio alarm clock

Post by Pilosopong Tasyo »

Ok, this post is a result of this previous thread. I made a few refinements vis-a-vis to the originating thread. To those who are interested, you might want to try this out. Edit wherever appropriate (i.e., filenames, locations, etc.).

/home/administrator/scripts/radio-alarm.sh

Code: Select all

#!/bin/sh

# Turn your computer into a digital radio alarm clock.
# Use cron to schedule the script to trigger at the designated
# date and time of your choosing.

# Change the following URL to your choice of online stream
STREAMING_ADDRESS=http://eradioportal.com/monsterRx.asx

# Mute the speakers.  You don't want to be rudely awakened
# by a sudden rush of sound from the speakers now, do you? 
amixer -q set Master 0

# Let's use VLC to stream content.
DISPLAY=:0 vlc $STREAMING_ADDRESS &
sleep 10  # A 10-second wait should be enough time to fill up the buffer.

# Gradually turn the volume up in 5% increments every 2 seconds
for STEP in `seq 5 5 100`
do
  amixer -q set Master $STEP%
  sleep 2
done

# EOF
Edit your cron table in terminal:

Code: Select all

crontab -e
And add a new entry at the end of the file (the following as an example):

Code: Select all

# m h  dom mon dow   command

# Wake me up every 6:30 am, Monday through Saturday, all year round
30 6 * * 1-6 /home/administrator/scripts/radio-alarm.sh
Save the new cron table and you're done.

Here's an online cron job generator you can use: http://www.generateit.net/cron-job/
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
Habitual

Re: Turn your computer into a digital radio alarm clock

Post by Habitual »

You are my new Best Friend. 8)
User avatar
Pilosopong Tasyo
Level 6
Level 6
Posts: 1432
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines

Re: Turn your computer into a digital radio alarm clock

Post by Pilosopong Tasyo »

Habitual wrote:You are my new Best Friend. 8)
This new section in the forum is quite inspiring. :D

I'm glad you made a request to create a section specifically for shell scripting. It's a fantastic idea and anybody can contribute solutions to questions posted in the forum that only require a shell script instead of a full-blown application.

Come to think of it, there's another thread somewhere in the forum that can be addressed using a shell script. I'll have to dig in my posts sometime later and write a tutorial about it. :twisted:

Regards! :mrgreen:
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
Habitual

Re: Turn your computer into a digital radio alarm clock

Post by Habitual »

Well, I am glad that we can come together and hopefully inspire others to take up the craft.
You got skills and good style too, # comments everywhere. :)
User avatar
dritzominous
Level 3
Level 3
Posts: 161
Joined: Sat Nov 14, 2009 12:49 am

Re: Turn your computer into a digital radio alarm clock

Post by dritzominous »

Excellent idea to raise the volume gradually.

Never thought of that.
Locked

Return to “Scripts & Bash”