Setting up the Weather Display on the Kindle
Find the "kindle" folder in the master.zip file you downloaded previously, or get the files from the "kindle" folder on GitHub.
Copy the "init-weather.sh" file into the "kite" folder on the Kindle. Then create a new folder called "weather" and copy both "display-weather.sh" and "weather-image-error.png" into it.
Open up the "weather\display-weather.sh" in a text editor (the same one that understands Unix line endings from above) and change the line that contains "http://server/path/to/weather-script-output.png" to the web server and file location that you set your weather script up on. When you save the file, make sure that you select Unix style line endings (this will probably be an option on the Save As dialog). Safely Remove and unplug your Kindle.
Now you're ready to test everything, you should see a new "PDF book" on your Kindle's screen called "init-weather.sh" if you don't, then switch your Kindle off and back on again. Select that and your screen should flash a few times and then either show your current weather, or show a warning sign and "Weather Image Unavailable".
Either of those mean that everything's working on your Kindle and you've succesfully run a custom script on it, if you get the image unavailable message then check the web address you've put in for the picture is correct.
One other possibility here is that when you click the init-weather.sh your Kindle puts a loading circle in the top-left corner for a moment, and then flashes back to the Home screen, this probably means that either init-weather or display-weather have been saved with Windows line endings (some decompression/un-zipper apps "helpfully" translate the line-endings for you when you extract text files, yours may have done this) just open the files up in a text editor and make sure that they're saved with the Unix line endings option select and try again.
One thing you'll notice when you've successfully got the weather scipt running is that there's only one way to exit it, and that's to hold down the power button on your Kindle for 20 seconds or so and wait for it to reboot. While that's fine when everything's up and running it can get a bit annoying while you're just testing things (like getting connected to your web server, or playing around with the look of the weather page), one alternative is to drop a test-weather.sh file into the "kite" folder containing:
#!/bin/sh /mnt/us/weather/display-weather.sh
This should show the weather display on the screen for a moment, and then dump you back to the Kindle's home screen.
Set up Cron On the Kindle
This is it, we're nearly there now, just need to set the Kindle up to regularly check back with the server for an updated weather picture. Cron is how we do that.Firstly, if you've never used Cron before, read up on Cron at wikipedia and follow links to further info if needed. I can also recommend searching for something like "crontab calculator" or "crontab generator" and using one of those to help build up your cron line, or running a search for "cron" on SuperUser.com.
Now you need to SSH into the Kindle again, you know the drill by now, switch on USB networking on the Kindle, plug it in and reconnect to it with Putty.
Once you're SSH'd into your Kindle, mount the file system for editing:
mntroot rwEdit the CRON file in vi (a command line, text mode, text editor) (unbelievably *nix people like this thing and even fight religious wars over how much better it is than other text mode editors, like it's still 1980)(Wikipedia - Vi).
vi /etc/crontab/rootA list of the jobs in the root cron file should appear:
*/15 * * * * /usr/sbin/checkpmond */15 * * * * /usr/sbin/tinyrot */60 * * * * /usr/sbin/loginfo tmpfs */60 * * * * /usr/sbin/loginfo localVars */60 * * * * /usr/sbin/loginfo memusedump */15 * * * * /usr/sbin/loginfo powerdcheckAll we need to do now is add the display-weather.sh script onto the end, mine's set to run every 6 hours, starting at just after midnight.
Try 10 */6 * * * /mnt/us/weather/display-weather.sh
Move the cursor to the end of the final line (using the arrow keys), press "i" to switch into "insert" mode, press Enter for a new line, and then type in your cron line, (if you make a mistake, press Escape to exit editing mode, move the cursor over the text to delete using tyhe arrow keys, and then press "x") press Escape to leave Insert mode, and then press ":w" to save the file, and then ":q!" to exit vi. There, wasn't that straightforward and obvious! For more help with vi commands and a tutorial, consult your favourite search engine.
Your crontab file should now look something like:
*/15 * * * * /usr/sbin/checkpmond */15 * * * * /usr/sbin/tinyrot */60 * * * * /usr/sbin/loginfo tmpfs */60 * * * * /usr/sbin/loginfo localVars */60 * * * * /usr/sbin/loginfo memusedump */15 * * * * /usr/sbin/loginfo powerdcheck 10 */6 * * * /mnt/us/weather/display-weather.sh
And then you restart Cron, to read the new job details, by entering:
/etc/init.d/cron restart
Which should give an output like:
[root@kindle root]# /etc/init.d/cron restart system: I cron:def:stopping crond system: I cron:def:starting crond [root@kindle root]#
Note: while you can set the Cron repeat interval to very small amounts of time when testing, I really wouldn't advise setting it to repeat any more often than every 5 minutes, as to get in there and change Cron's settings you need to wait for the Kindle to come on, turn on debug mode, turn on USB networking mode, SSH in and adjust the timings, all before the weather job kicks in again. That's not a quick process, you'll want to give yourself a few minutes.
Unplug, switch USB Networking off again, run init-weather.sh and enjoy your weather display.
And we're there!
Some atypical English weather, showing on my Kindle.
Useful references and acknowledgements:
Thanks to Matthew Petroff for the inspiration and for putting in all the hard work to get all of the original scripts together and get this working on a Kindle in the first place.- Matthew Petroff's original Kindle Weather Display blog post
Be sure to read through the comments on there as well as the main article, contrary to usual expectations many of the comments are actually quite useful. - Jennifer's 365 Project: 1347/365 - Kindle Weather Display (and the followup post 1356/365 - Days For All The Forecasts, also the post 1337/365 - SSH on the Kindle 4 (USBNetwork Hack) was handy)
For filling in some of the blanks in Matthew's post, and giving some ideas for expanding on the idea and modifying it. - The MobileRead forums
Particularly the Kindle 4 wiki page, the Kindle 4 jailbreak instructions, the USB Networking hack and the Kite installation.
Todo
Thoughts for future changes to this:- Wind - being a sailor, the wind conditions can be a useful thing to know, a couple of the weather feeds include this, either by default or as an option, so it should be possible to include it with some tweaks to the vbscripts, a tweak of the SVG template, and some new icons.
- New icons - while the icons included in Matthew Petroff's original collection are clean and clear, I'm quite fond of the old BBC weather icons - they're what I grew up with - a member of the design team for the BBC's new visual style has made a set of icons in the style of the old classics, available here, it shouldn't be much work to swap these in.
- Two other personal projects that I'm planning to do at some point are learn PowerShell and rebuild my 2003R2 based home server into Server 2012 whilst recreating most of WHS's functionality, as part of this I may rewrite the server-side VBscripts as PowerShell scripts.
Update 07/2016: download links updated now that project files have been moved to GitHub
- Introduction
- Setting up the server
- Weather Services
- Getting the Image Tools
- Scheduled Tasks
- Download the Scripts
- Setting up the Kindle
- Jailbreak your Kindle
- Setting up USB Networking (1)
- Setting up USB Networking (2)
- Installing Kite on the Kindle
- Putting it all together
- Setting up the Weather Display on the Kindle
- Setting up Cron on the Kindle
- Useful References and acknowledgments
- Todo