[SOLVED] How can I use my laptop as an Alarm Clock?
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Cry in your microphone "HEY, WAKE UP!", several times. Stop the recording with Ctrl-C. Then open your crontab with:
Code:
$ crontab -e
And write this line to run it at 7:00 AM:
Code:
0 7 * * * aplay /path/to/wakeUp.wav
(All of you should wake up.)
Nice, but, I don't like idea to leave working, one of my computers, all the night. It should automatically power-on from stand-by and boot at ... i.e. 7 A.M., then to make the required noises.
To make automatically power-on possible, we should have an chrono support in BIOS. Unix or NOT, you can't power-on the machine automatically, only with the operating system support (i.e. CRONTAB), because there is no operating system running when the computer is in STAND-BY.
On the topic of keeping the computer asleep and waking it up only when the alarm needs to sound, I can give some advice. Does anybody remember how there are a few tasks programmed by default to be run everyday at 4:40 from root's crontab? Specifically, the contents of /etc/cron.daily. Well, I thought it was a good idea to let them run as planned while I wasn't using the computer, so when booting up and as part of those tasks I schedule a wake up event for 4:38 the next day with:
Code:
#!/bin/sh
# Wake up tomorrow at 4:38
time=$( echo $(( $( date -d 00:00 +%s ) + 103080 )) )
exec /usr/sbin/rtcwake -u -m no -t $time >/dev/null
See the manpage for rtcwake and test if it works for you. And the last task in /etc/cron.daily sends the computer to sleep again with a call to pm-suspend.
Code:
$ ls -l /etc/cron.daily/zzz_pm-suspend
lrwxrwxrwx 1 root root 20 Mar 24 19:27 /etc/cron.daily/zzz_pm-suspend -> /usr/sbin/pm-suspend*
So I go to bed every night having suspended the computer and it wakes up at 4:38 (I should probably test waking up at 4:39), runs the tasks at 4:40 and goes to sleep again, all in its own. I'm sure some of this can be used to create a simple alarm clock that plays a random song from a song collection.
Some people let the machine up all night (i.e. with the mule), I assume that's your case, otherwise, following the Unix idea, that's no more and no less than common sense applied to computer use, you'd buy some alarm clock in a Chinese bazaar.
Any alternative to the cron job and the Chinese alarm clock means to be seriously perturbed by the dark side.
Any alternative to the cron job and the Chinese alarm clock means to be seriously perturbed by the dark side.
Still, your Chinese alarm clock can't play that inspirational song at 5:00 AM, in my 7.1 audio system. While one of my computers, that have the nice ability to program the BIOS, to wake-up the computer from stand-by at specified time, will do...
I should ask for a audience to our Glorious Emperor?
[schneidz@hyper ~]$ cat ./egg-timer.ksh
#!/bin/bash
# Filename: progbar-timer.sh
# Version: 110212
# Author: robz
# Improved from the "Egg Timer" script, a countdown timer with progress bar.
# This one has an indication of time remaining provided by Zenity's progress
# bar function. As usual you'll need to find a sound and icon for the variables
# below, you might find the icon variable is correct, check the directory.
ICON=/usr/share/app-install/icons/kalarm.png # Existing icon?
SOUND=/home/schneidz/music/Finding-Forever/01-Intro--Intro--Intro--Intro--Intro--Intro--Intro--Intro--Intro--Intro--Intro--Intro--Intro--Intro--Intro--Intro.mp3 # Your sound pref.
COUNT=$(zenity --title "Egg Timer" --window-icon $ICON --text "No decimals"\
--entry-text "eg. 10s or 5m or 2h" --entry) # Input dialogue.
if [ $? = 1 ]; then exit $?; fi
# Determine number of seconds to count down from depending on input suffix.
case "${COUNT: -1}" in
"S" | "s" ) COUNT=$(echo $COUNT | sed -s "s/[Ss]//") ;;
"M" | "m" ) COUNT=$(echo $COUNT | sed -s "s/[Mm]//"); ((COUNT*=60)) ;;
"H" | "h" ) COUNT=$(echo $COUNT | sed -s "s/[Hh]//"); ((COUNT*=3600)) ;;
* ) zenity --error --text "<span color=\"red\"><b>\
\nUse the form of 10s or 5m or 2h\nNo decimals allowed either.</b></span>"
sh -c "$0" # On error restart.
exit ;;
esac
START=$COUNT # Set a start point.
until [ "$COUNT" -eq "0" ]; do # Countdown loop.
((COUNT-=1)) # Decrement seconds.
PERCENT=$((100-100*COUNT/START)) # Calc percentage.
echo "#Time remaining$(echo "obase=60;$COUNT" | bc)" # Convert to H:M:S.
echo $PERCENT # Outut for progbar.
sleep 1
done | zenity --title "Egg Timer" --progress --percentage=0 --text=""\
--window-icon=$ICON --auto-close # Progbar/time left.
if [ $? = 1 ]; then exit $?; fi
notify-send -i $ICON "Egg Timer > ## TIMES UP ##" # Attention finish!
/usr/bin/canberra-gtk-play --volume 4 -f $SOUND # Ding-dong finish!
zenity --notification --window-icon="$ICON"\
--text "Egg Timer > ## TIMES UP ##" # Indicate finished!
Thanks for all of the suggestions. After some testing and more researching I discovered that Orage has an alarm function that seems to work pretty well. Now I have to install slack on the older laptop in question (with MLED + XFCE) and play around with music players. Looks like a task for this weekend. :-)
Installed slackware & MLED with the xfce desktop. For music players I installed rhythmbox as I am already familiar with starting it from the command line and works nicely with orage. Thanks for all of your help. Marking this as solved.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.