View Single Post
Old 11-22-2006, 03:57 PM   #1
design256
Connoisseur
design256 doesn't litterdesign256 doesn't litter
 
Posts: 78
Karma: 103
Join Date: Aug 2006
Location: Ipswich, UK
Device: Irex Iliad
Watchdog - automatically shut down your Iliad

Hi everyone,

Watchdog is my first attempt to write a useful utility for the Iliad.

It runs as a daemon, and if the Iliad has been idle for more than a certain amount of time (default 30 minutes), it shuts it down, thus saving batteries.

Version 0.1 is for those who can run it from the command line. If we're happy that it's working, then I'll ask Yokos if he can work his packaging magic with it.

Usage

watchdog [idle_time]

Watches the Iliad and will shutdown the Iliad if it has been idle for more than idle_time minutes (minimum 5). Will default to 30 minutes if you don't specify a time


stopwatchdog

Will stop a running watchdog. May take up to 2 minutes before watchdog quits (as it spends most of its time asleep).


How it works

I noticed that the syslog file is written to each time the screen is updated with an eink marker. Watchdog forks into the background then wakes up every minute and tails this file. If it doesn't find any eink markers within the specified period then it shuts the machine down.

Stopwatchdog simply sends it a quit message by way of the syslog file.


Caveats

I'm using /sbin/shutdown which will not perform some of the nice quit stuff you get if you push the power button. Maybe there's an event I can send everything to tell it to save and quit nicely (Ideas Scotty???)


Enjoy!

ps.. Source code is included in the zipfile. It compiles out of the box.
Attached Files
File Type: zip watchdog-0.1.zip (5.2 KB, 303 views)
design256 is offline   Reply With Quote