#!/bin/bash # first required argument wake time (24h clock, will trigger at next occurrence), second optional argument alarm track # if no arguments are given, it will pop a dialogue to ask what time. you can't set alarm track this way though. if [ $# -lt 1 ] then input=`zenity --entry --title='set alarum time' --text='what time to wake up eh?' --entry-text='e.g. 0700 or 8:30pm'` if [ $? -gt 0 ]; then exit; fi else input=$1 fi rTime=`date -d $input +%s` cTime=`date +%s` # if wakeup time is earlier than now, add a day if [ $rTime -lt $cTime ] then aDay=$[ 60 * 60 * 24 ] wakeTime=$[ $rTime + $aDay ] else wakeTime=$rTime fi timediffS=$[ $wakeTime - $cTime ] timediffM=$[ $timediffS / 60 ] timediffH=$[ $timediffM / 60 ] sump=$[ $timediffH * 60 ] timediffM=$[ $timediffM - sump] alarmTrack='/home/blodgett/music/01 Sunrise.mp3' if [ $# -gt 1 ]; then alarmTrack="$2"; fi # print calculated wake time with countdown/opt-out, or confirm dialogue if [ $# -lt 1 ] then zenity --question --title='alarum time' --text="set alarm for:\n `date --date @$wakeTime`?\n(in $timediffH hours $timediffM mins)" if [ $? -gt 0 ] then exit else zenity --info --title='nap time' --text='ok, going to sleep now' fi else echo "alarm '${alarmTrack##*/}' set for:" echo "`date --date @$wakeTime` (in $timediffH hours $timediffM mins)" echo hit Ctrl-C if this is wrong... echo 3; sleep 1 echo 2; sleep 1 echo 1; sleep 1 echo sleeping now fi # make sure sound is on and loud amixer -q set Master unmute amixer -q set Master 100% sudo rtcwake -t $wakeTime -m mem > /dev/null xine -S volume=100 -pw "$alarmTrack" > /dev/null &