Crontab, BASH and Audacious as a Wakeup Alarm

This one is actually very simple so let's dive into it right now. The first thing we need to do is create a crontab entry. Take notice that your system must allow this in order for crontab to execute your stuff.

$ crontab -e

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#

# m h  dom mon dow   command
0 9     *   *  1-5      /home/vlatko/bin/wakeup.sh

This will simply setup wakeup.sh script to be run every morning at 9:00. So what's the magic in the wakeup.sh? It's pretty awesome if you ask me:

#!/bin/bash

# If audacious is already started nothing will happen
/usr/bin/audacious
amixer set Master 0 > /dev/null
amixer set PCM 205 > /dev/null
audtool --playback-play

for i in {1..10}
do
        amixer set Master $i > /dev/null
        sleep 5
done

Clearly, you need to have audacious and alsa mixer installed to have this working. But the net effect is that you will wake up to sounds of your favorite music.

Your thoughts

No comments

Add comment

* - required field

*




*