RehabMan
Moderator
- Joined
- May 2, 2012
- Messages
- 181,058
- Motherboard
- Intel DH67BL
- CPU
- i7-2600K
- Graphics
- HD 3000
- Mac
- Mobile Phone
I've been using this for a bit here and it seems to work pretty well... I wouldn't call it a fix, but rather a work around.
As you know, the 4x30s series brightness does not work correctly except after a 'display sleep'. What I describe here will allow a display sleep/wake to happen just after logging in. It is based on code originally posted by rybarkam here: http://www.tonymacx86.com/hp-probook/77058-faq-mountain-lion-hp-probook-2.html#post536702
The problem with rybarkam's solution is that it was buried in an app bundle instead of just a command line app, and it didn't work reliably. Probably because there was no control over the timing. So... I did a little tweaking. It involves several files/components:
1. blinkscreen binary, installed to /usr/bin
It is this code (blinkscreen.c):
Compiled with: gcc -Wall -mmacosx-version-min=10.6 -o blinkscreen blinkscreen.c -framework IOKit -framework Foundation
2. Plist to register a LaunchAgent, installed to /Library/LaunchAgents
org.rehabman.autoexec.plist:
3. autoexec.sh script that runs per-user script in ~/autoexec.sh, installed to /usr/bin/autoexec.sh
/usr/bin/autoexec.sh
Make it executable with:
4. autoexec.sh script that does the actual work, installed to ~/autoexec.sh
Note: this is a generic mechanism... You can put anything you want in here. I also establish connections to my SMB shares on my WHS 2011 server, for example...
Note: If you wanted the blinkscreen to be run for all users, you could also enter this code into the /usr/bin/autoexec.sh. This might, in fact, be the best option were this to be placed in the ProBook Installer.
~/autoexec.sh
Make it executable with:
This is a 'translation' of the code I'm using on my own machine, so hopefully I didn't create any errors with it here...
Maybe a possible option in the ProBook Installer v6.1??
Note: This solution is now available from the ProBook Installer v6.1b8 (and later). Easy checkbox to install!
Edit 2013-04-26: Updated binary below. Built with tools on Snow Leopard. Should be compatible now with all three SL, Lion, and ML.
blinkscreen binary is attached below:
As you know, the 4x30s series brightness does not work correctly except after a 'display sleep'. What I describe here will allow a display sleep/wake to happen just after logging in. It is based on code originally posted by rybarkam here: http://www.tonymacx86.com/hp-probook/77058-faq-mountain-lion-hp-probook-2.html#post536702
The problem with rybarkam's solution is that it was buried in an app bundle instead of just a command line app, and it didn't work reliably. Probably because there was no control over the timing. So... I did a little tweaking. It involves several files/components:
1. blinkscreen binary, installed to /usr/bin
It is this code (blinkscreen.c):
Code:
/** GPL **/
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOKitLib.h>
#include <unistd.h>
int main() {
io_registry_entry_t entry = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/IOResources/IODisplayWrangler");
if (entry) {
IORegistryEntrySetCFProperty(entry, CFSTR("IORequestIdle"), kCFBooleanTrue);
usleep(100*1000); // sleep 100 ms
IORegistryEntrySetCFProperty(entry, CFSTR("IORequestIdle"), kCFBooleanFalse);
IOObjectRelease(entry);
}
return 0;
}
Compiled with: gcc -Wall -mmacosx-version-min=10.6 -o blinkscreen blinkscreen.c -framework IOKit -framework Foundation
2. Plist to register a LaunchAgent, installed to /Library/LaunchAgents
org.rehabman.autoexec.plist:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.rehabman.autoexec</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>Program</key>
<string>/usr/bin/autoexec.sh</string>
</dict>
</plist>
3. autoexec.sh script that runs per-user script in ~/autoexec.sh, installed to /usr/bin/autoexec.sh
/usr/bin/autoexec.sh
Code:
#!/bin/sh
# install to /usr/bin/autoexec.sh
# run ~/autoexec.sh if it exists
if [ -e ~/autoexec.sh ]; then
~/autoexec.sh
fi
Make it executable with:
Code:
chmod +x /usr/bin/autoexec.sh
4. autoexec.sh script that does the actual work, installed to ~/autoexec.sh
Note: this is a generic mechanism... You can put anything you want in here. I also establish connections to my SMB shares on my WHS 2011 server, for example...
Note: If you wanted the blinkscreen to be run for all users, you could also enter this code into the /usr/bin/autoexec.sh. This might, in fact, be the best option were this to be placed in the ProBook Installer.
~/autoexec.sh
Code:
#!/bin/sh
# install to ~/autoexec.sh
# might not be necessary to sleep for a second, you can experiment with/without it...
sleep 1
# blink the screen, fixing the brightness issue...
/usr/bin/blinkscreen
Make it executable with:
Code:
chmod +x ~/autoexec.sh
This is a 'translation' of the code I'm using on my own machine, so hopefully I didn't create any errors with it here...
Maybe a possible option in the ProBook Installer v6.1??
Note: This solution is now available from the ProBook Installer v6.1b8 (and later). Easy checkbox to install!
Edit 2013-04-26: Updated binary below. Built with tools on Snow Leopard. Should be compatible now with all three SL, Lion, and ML.
blinkscreen binary is attached below: