abstractwankery.com
taking it to the next level
Stupid Tricks: sleep_monitor
Posted by Nick at 2:38 PM
Some of you know that I'm a hackintosh user. I've been an Apple fan for a long time, but nothing in their lineup currently works for what I want out of a machine. My last Apple machine was a black MacBook with the original Intel Core Duo. It went in for service three times, and finally, Apple just denied anything was wrong with it. I ended up selling that machine, and the hard drive that was originally in it died a week later.

Huh.

Right now, I use a Lenovo/IBM ThinkPad T61 14" Widescreen edition, with a Core 2 Duo at 2.2GHz, 2gb RAM, a 100gb drive, and DVD-RW DL drive. The screen resolution is a comfortable 1440x900, I have some wireless, and life is good. I'm also running OS X 10.5, licensed but violating EULA, because it's one of the greatest operating systems we currently have available. There are a few little issues with running Leopard on this machine. Most things work, but I don't currently have a driver for the built in ethernet, the machine won't sleep if I have bluetooth enabled, the machine won't wake up if I enable the PC card slots, I can't control the brightness of the LCD, and when the laptop runs out of battery, it shuts off instead of going to sleep.

There are a few people working on two of the issues, namely the brightness issue with the Intel X3100 graphics controller, and a driver for the Intel 82566M Gigabit Ethernet controller. No sense in duplicating their efforts. The only kext I've ever written was a small driver to enable the tablet serial port on the X61 tablet that I had before this, so people could use TabletMagic and get full tablet functionality in OS X. Ethernet driver creator, I am not.

But, hey, I give you one little turd to make your life easier, and you may even find it useful if you're on a real Mac. This little package, 'sleep_monitor', installs a LaunchDaemon and a binary on your machine to keep track of how much battery you have left and put your machine to sleep at a certain threshold. It's a simple idea, but most Mac authors would charge $20 for the privilege. I give you it for free, but you don't get a GUI. Sorry.

When you install the package, it immediately starts. It will wait until you have 4% of your battery remaining, and puts your machine to sleep. On my T61 with the 4 cell battery, that usually kicks me into sleep when I have about 5 minutes of use left in the menu bar, and that will give me many hours of sleep to find an outlet to charge things up. Want to change the threshold? Edit /Library/LaunchDaemons/com.abstractwankery.sleep_monitor.plist and change the second ProgramArgument to the percentage you'd like to kill out at. Have an 8 cell battery? 2-3% is fine. Have a nearly dead battery? Maybe 15% is more your thing. Leave the % sign out of it, it will only cause problems.

SleepMonitor 0.1
Mac OS X 10.4, 10.5
316 comments
Do as I say, not as I do
Posted by Nick at 8:23 AM
Anyone who has been involved with the "forbidden" osx86 scene, or the ability to run Mac OS X on generic PC hardware, likely knows the name netkas. Netkas created the EFI firmware emulator that brings the osx86 distribution of OS X closer to the real thing by emulating the EFI Apple uses in their modern hardware. EFI is Intel's replacement for BIOS, closely resembling OpenFirmware, that allows both the interface to hardware from the software layer as well as providing direction and configuration for said hardware. The EFI emulation layer has opened the doors for more graphics hardware support, booting from GUID Partition Table hard disks, and more. It also allows osx86 users with compatible hardware (Intel chipsets and Core Solos or higher) to use Apple's OS X kernel, rather than waiting for a hacked and patched version from the community.

A company called Psystar recently exploded into the news by openly announcing a commercially sold "hackintosh". They're offering what is essentially a white box PC, with off the shelf parts that match or closely match what Apple is offering in their hardware, pre-installed with Mac OS X 10.5. Their sales pitch is that they're effectively selling an expandable Mac, with more power than an iMac, for less than half the cost. They're bundling a legal copy of Leopard, the Netkas EFI v8 emulator, and Apple's bundled software, as a complete package. It's a license violation to do this, as Apple's EULA specifically forbids using Leopard on hardware that is not Apple-branded.

The funny part to this story is that Netkas is all pissed off that Psystar is using his EFI emulator in a commercial product. He has since re-released EFI v8 with a new license forbidding the use of the software for commercial purposes. Now, if anyone just noticed that, Netkas is pissed off that Psystar is violating his license agreement by bundling software that allows people to violate Apple's license agreement.

Right, then.
1 comment