Backlight-Hack for Ubuntu on MacBooks

The Key-Backlights on the MacBook Pro are not properly working on Ubuntu, seems to be a quite nasty hack Apple produced there, as far as I read. They dont keep their state, when power-levels, etc., change.

You can turn them on and off, and switch different brightness-levels. But if the screensaver starts, or you restart the computer, or reconnect your power-supply, it will always go to the old state.

Well, in theory it is possible (even for me) to write a workaround that always sets the brightness to the level I wanted before. But I neither have time nor do I actually feel like doing that. So I did what a good hacker does, I just hacked something together.

I added the following line to my crontab (didnt <pre> them, because of the shitty stylesheed wordpress uses):

*/1 * * * * root if test -e /var/lock/nobacklight; then (echo 0 > /sys/class/leds/smc\:\:kbd_backlight/brightness ); fi;

It is executed every minute and turns the backlights off, if a file /var/lock/nobacklight exists. That is, if I want the backlights off, it turns it off after at most one minute. Which is enough for me. Then, I wrote a script with the following content:

#! /bin/bash
if test -e /var/lock/nobacklight; then
rm /var/lock/nobacklight;
notify-send „Allowing Backlights“;
else
touch /var/lock/nobacklight;
chmod a+rwx /var/lock/nobacklight;
notify-send „Blocking Backlights“;
fi

I put a starter for this script into the gnome-panel. By clicking it, I can toggle wether the ligths should be turned off or on. If I had the muse, I could add the possibility of periodically changing to an arbitrary desired light-level, rather than just turning it of, or I could even add event-scripts to apmd to rebind the function-keys for doing this. But actually, this is enough for me, and I just wait until pommed works properly on the new macbook.

Schreibe einen Kommentar

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s

%d Bloggern gefällt das: