<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Hard to predict blog</title>
	<atom:link href="http://justrandom.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://justrandom.wordpress.com</link>
	<description>Random programming, linux and personal stuff.</description>
	<lastBuildDate>Mon, 03 Sep 2007 06:44:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='justrandom.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Hard to predict blog</title>
		<link>http://justrandom.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://justrandom.wordpress.com/osd.xml" title="Hard to predict blog" />
	<atom:link rel='hub' href='http://justrandom.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Daily music alarm using cron</title>
		<link>http://justrandom.wordpress.com/2007/09/02/daily-music-alarm-using-cron/</link>
		<comments>http://justrandom.wordpress.com/2007/09/02/daily-music-alarm-using-cron/#comments</comments>
		<pubDate>Sun, 02 Sep 2007 17:17:51 +0000</pubDate>
		<dc:creator>dkomlen</dc:creator>
				<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://justrandom.wordpress.com/2007/09/02/daily-music-alarm-using-cron/</guid>
		<description><![CDATA[This is my first guide and here I will show how to make a daily alarm that will wake up computer from standby and start playing music. The additional feature will be increasing volume level as time passes. I&#8217;ve done all this on Ubuntu Dapper Drake but it should work on other distributions too. First is to create a python script that will update /proc/acpi/alarm with date and time when to wake up the computer. Since this is the daily alarm this script will put the tomorrow date and will be called every time when computer wakes up from standby. Here is the script code: import time import datetime import sysday = (24*60)*60 tomorrow = datetime.datetime.fromtimestamp(time.time() + day) #setting wake [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justrandom.wordpress.com&amp;blog=1616953&amp;post=4&amp;subd=justrandom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is my first guide and here I will show how to make a daily alarm that will wake up computer from standby and start playing music. The additional feature will be increasing volume level as time passes. I&#8217;ve done all this on Ubuntu Dapper Drake but it should work on other distributions too.</p>
<p><span id="more-4"></span><br />
First is to create a python script that will update /proc/acpi/alarm<br />
with date and time when to wake up the computer.<br />
Since this is the daily alarm this script will put the tomorrow date and<br />
will be called every time when computer wakes up from standby.</p>
<p>Here is the script code:</p>
<blockquote><p><code><font COLOR="#999999"><br />
import time<br />
import datetime<br />
import sysday = (24*60)*60<br />
tomorrow = datetime.datetime.fromtimestamp(time.time() + day)</p>
<p>#setting wake up time<br />
output =  tomorrow.strftime("%Y-%m-%d") + " 06:59:50"</p>
<p>print output<br />
try: alarm = file('/proc/acpi/alarm','w')<br />
except:<br />
&nbsp;&nbsp;&nbsp;print ('Failed to open "/proc/acpi/alarm"!')</p>
<p>sys.exit()alarm.write(output)<br />
</font><br />
</code></p></blockquote>
<p>All this script does is increasing the date in /proc/acpi/alarm.<br />
You can run the script to see the output that will be put in the file.<br />
If run as a non root user the script will fail to write the line to file, so it will<br />
be neccesery to run it each time as root.</p>
<p>In this is example alarm will start in 07:00 so I decided to wake up<br />
my machine 10 seconds earlyer (06:59:50).</p>
<p>Next thing is to create cron file that will inform cron when to run the<br />
script and start playing music.<br />
Content of alarm.cron file:</p>
<blockquote><p><code><font COLOR="#999999"><br />
0 7 * * * /usr/bin/tomorrow.py<br />
0 7 * * * mpg321 --random /data/Music/*<br />
</font></code></p></blockquote>
<p>First line tells cron to run tomorrow.py (above python script) every day in 7:00.<br />
The second one starts playing random songs from music folder using mp321 player.</p>
<p>Since the tomorrow.py requires root privileges we will have to use root&#8217;s cron.<br />
To do this we just use sudo when running crontab:</p>
<blockquote><p><code><font COLOR="#999999"><br />
sudo crontab alarm.cron<br />
</font><code></p></blockquote>
<p>To see if the crontab has been updated use:</p>
<blockquote><p><code><font COLOR="#999999"><br />
sudo crontab -l<br />
</font></code></p></blockquote>
<p>Additionaly we can make sound volume to increase each minute.<br />
I have done this using amixer. See 'man amixer' for more info.<br />
So all you need is to add next lines to your alarm.cron file:</p>
<blockquote><p><code><font COLOR="#999999"><br />
0 7 * * * amixer -c 0 sset Master,0 30%,30%<br />
1 7 * * * amixer -c 0 sset Master,0 40%,40%<br />
2 7 * * * amixer -c 0 sset Master,0 50%,50%<br />
</font></code></p></blockquote>
<p>Note that to start the wake up alarm loop you will first have to run the python<br />
script with sudo. You will have to do this each time when the cron didn't do it.<br />
For example if you forget to leave computer on standby.</p>
<p>I hope you learned something from this little guide.<br />
Your feedback is always welcome.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/justrandom.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/justrandom.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/justrandom.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/justrandom.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/justrandom.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/justrandom.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/justrandom.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/justrandom.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/justrandom.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/justrandom.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/justrandom.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/justrandom.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/justrandom.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/justrandom.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/justrandom.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/justrandom.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justrandom.wordpress.com&amp;blog=1616953&amp;post=4&amp;subd=justrandom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://justrandom.wordpress.com/2007/09/02/daily-music-alarm-using-cron/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/abe1656f417b6e8550cd2a6b1bc8ce06?s=96&#38;d=identicon" medium="image">
			<media:title type="html">dkomlen</media:title>
		</media:content>
	</item>
		<item>
		<title>Hello universe!</title>
		<link>http://justrandom.wordpress.com/2007/08/30/hello-world/</link>
		<comments>http://justrandom.wordpress.com/2007/08/30/hello-world/#comments</comments>
		<pubDate>Thu, 30 Aug 2007 21:00:00 +0000</pubDate>
		<dc:creator>dkomlen</dc:creator>
				<category><![CDATA[JustRandom]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[justrandom.wordpress.com has just been lunched in the wordpress unverse. I plan to write random stuff about programming under linux, Ubuntu and other interesting things. Maybe I&#8217;ll try making some tutorials later on.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justrandom.wordpress.com&amp;blog=1616953&amp;post=1&amp;subd=justrandom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>justrandom.wordpress.com has just been lunched in the wordpress unverse. I plan to write random stuff about programming under linux, Ubuntu and other interesting things. Maybe I&#8217;ll try making some tutorials later on.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/justrandom.wordpress.com/1/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/justrandom.wordpress.com/1/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/justrandom.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/justrandom.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/justrandom.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/justrandom.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/justrandom.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/justrandom.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/justrandom.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/justrandom.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/justrandom.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/justrandom.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/justrandom.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/justrandom.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/justrandom.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/justrandom.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justrandom.wordpress.com&amp;blog=1616953&amp;post=1&amp;subd=justrandom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://justrandom.wordpress.com/2007/08/30/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/abe1656f417b6e8550cd2a6b1bc8ce06?s=96&#38;d=identicon" medium="image">
			<media:title type="html">dkomlen</media:title>
		</media:content>
	</item>
	</channel>
</rss>
