Wekker

Please keep in mind that this post is about 9 years old.
Technology may have changed in the meantime.

M’n smartphone is stuk. Op zich geen probleem, want ik leef al anderhalf jaar zonder telefoon (en geniet ervan), maar hij deed wel dienst als wekker.

Gelukkig doet m’n laptop het nog wel, en dus schreef ik even vlug een wekker, zodat ik morgen toch bijtijds op kan.
(Uiteraard hebben we het over Linux.)

#!/usr/bin/env bash

# ~/bin/wekker.sh

# This script sets an alarm for the specified time.
# All command line parameters will be passed to `at' as timespec.

# Copyright (c) 2015 Rob la Lau <rob@ohreally.nl>
# This script is in the public domain.

#################################################################

# Config.

play=/home/rob/tingeling.wav
repeat=3

#################################################################

timespec=$@
[ -z "${timespec}" ] && {
    echo "No timespec given."
    exit
} 

AMIXER=`which amixer`
MPLAYER=`which mplayer`

(
cat <<EndOfCommands
${AMIXER} sset Master 100%
${MPLAYER} -quiet -loop ${repeat} ${play}
EndOfCommands
) | at -M ${timespec}

En nu kan ik mijn wekker zetten met het commando

./wekker.sh 07:00

Net zo makkelijk…

REPUBLISHING TERMS

You may republish this article online or in print under our Creative Commons license. You may not edit or shorten the text, you must attribute the article to OhReally.nl and you must include the author’s name in your republication.

If you have any questions, please email rob@ohreally.nl

License

Creative Commons License AttributionCreative Commons Attribution
Wekker