Fedora Linux Support Community & Resources Center
  #1  
Old 8th September 2010, 06:16 PM
SunlightRider Offline
Registered User
 
Join Date: Sep 2010
Posts: 4
linuxfedorafirefox
Macbook Backlight Keyboard Keybindings

I own a Macbook, and finally decided to quit the "advanced" distro's which the only thing i did was keep fixing small details, and chose Fedora mainly because It's elegant. But oh well, here goes the deal:

I have made a script to control the backlight keyboard, increasing or decreasing the light intensity. The scripts works flawlessly. As the script writes to a file in /sys/ it needed root permissions, so i made a line in sudoers for it to be executed using sudo wthout promting for a password. This also works.

The problem is I want to keybind it to the Mac Keys, which are named XF86KbdBrightnessUp & Down.

I have used gnome-keybinding-properties and no luck.

I have also tried the gconf-editor metacity approach, if the name of the keys do not change using gconf. (i set the commands using the names XF86KbdBrightnessUP & down. and still no luck.

This has probably been anwsered, but It's a hard search since It's very specific, so here goes the new thread.

Thank you all.

This is the script BTW just for the search engine index record.

Code:
#!/usr/bin/perl
#use warnings;

my $salto = 15;

open(ARCHIVO, "/sys/class/leds/smc::kbd_backlight/brightness") || die("No se encontro el Archivo de Brightness\n");
@intensidad = <ARCHIVO>;
close(ARCHIVO);
chomp(@intensidad[0]);


my $var = @intensidad[0];
my $mas = $var + $salto;
my $menos = $var - $salto;

if($ARGV[0] eq "up" && $mas <= 255){
	system("echo $mas > /sys/class/leds/smc::kbd_backlight/brightness");
}elsif($ARGV[0] eq "down" && $menos >= 0){
	system("echo $menos > /sys/class/leds/smc::kbd_backlight/brightness");
}
Reply With Quote
  #2  
Old 8th September 2010, 11:49 PM
Min Offline
Registered User
 
Join Date: Jun 2009
Location: Melbourne
Posts: 246
linuxmozilla
Re: Macbook Backlight Keyboard Keybindings

Hmm, interesting. The one that I know and use, instead of using

/sys/class/leds/smc::kbd_backlight/brightness

I use (for unibody macbook late 2008)

/sys/devices/platform/applesmc.768/leds/smc\:\:kbd_backlight/brightness
__________________
Macbook aluminum 5,1
Snow Leopard, Constantine, Seven
Reply With Quote
  #3  
Old 9th September 2010, 12:10 AM
bob's Avatar
bob Online
Administrator (yeah, back again)
 
Join Date: Jul 2004
Location: Colton, NY; Junction of Heaven & Earth (also Routes 56 & 68).
Age: 67
Posts: 21,225
linuxfirefox
Re: Macbook Backlight Keyboard Keybindings

(moved to Mac)
__________________
Linux & Beer - That TOTALLY Computes!
Registered Linux User #362651


Don't use any of my solutions on working computers or near small children.
Reply With Quote
  #4  
Old 9th September 2010, 02:28 AM
SunlightRider Offline
Registered User
 
Join Date: Sep 2010
Posts: 4
linuxfedorafirefox
Re: Macbook Backlight Keyboard Keybindings

Quote:
Originally Posted by Min View Post
Hmm, interesting. The one that I know and use, instead of using

/sys/class/leds/smc::kbd_backlight/brightness

I use (for unibody macbook late 2008)

/sys/devices/platform/applesmc.768/leds/smc\:\:kbd_backlight/brightness
It's the same file :P, those backslashes before the dots "\." the backslash is called an escape character, It's just for telling the terminal that the following character is an actual "." and not a dot part of some command.

The one you use, also works for me. I'm gonna try doing it by writing on that one, must be the same though, just hoping some magic appears.

Last edited by SunlightRider; 9th September 2010 at 02:31 AM. Reason: Lazy Reading
Reply With Quote
  #5  
Old 9th September 2010, 12:35 PM
Min Offline
Registered User
 
Join Date: Jun 2009
Location: Melbourne
Posts: 246
linuxfirefox
Re: Macbook Backlight Keyboard Keybindings

I thought that it was sysmlink-ed but it is not.

I binded mine to command+> or Command+<

Code:
#!/bin/sh

current=`cat /sys/devices/platform/applesmc.768/leds/smc\:\:kbd_backlight/brightness`

new=$[$current$1]
if [ $new -ge 255 ]; then
new=255
fi
if [ $new -lt 0 ]; then
new=0
fi
echo $new > /sys/devices/platform/applesmc.768/leds/smc\:\:kbd_backlight/brightness
That is mine. I invoke by those mentioned key to invoke "keyboard-brightness -64" and "keyboard-brightness +64"

EDIT: I usually "chmod a+rw /sys/devices/platform/applesmc.768/leds/smc\:\:kbd_backlight/brightness" to give the write access (not the best security practice though)
__________________
Macbook aluminum 5,1
Snow Leopard, Constantine, Seven

Last edited by Min; 9th September 2010 at 12:37 PM.
Reply With Quote
  #6  
Old 9th September 2010, 06:37 PM
SunlightRider Offline
Registered User
 
Join Date: Sep 2010
Posts: 4
linuxfedorafirefox
Re: Macbook Backlight Keyboard Keybindings

Thing is, the actual problem is happening inside Gnome. It's not running my keybinded script, no matter what the key is. I've also tried gconf editor, but no luck.
Reply With Quote
  #7  
Old 10th September 2010, 11:16 PM
Min Offline
Registered User
 
Join Date: Jun 2009
Location: Melbourne
Posts: 246
linuxfirefox
Re: Macbook Backlight Keyboard Keybindings

Quote:
Originally Posted by SunlightRider View Post
Thing is, the actual problem is happening inside Gnome. It's not running my keybinded script, no matter what the key is. I've also tried gconf editor, but no luck.
can you add
notify-send "run"

to make sure your script is really not executed? I use xbindkeys for binding my shortcut. I use it because it is DE independent. Most of the time i use xfce, but at time I do run gnome or kde.
__________________
Macbook aluminum 5,1
Snow Leopard, Constantine, Seven
Reply With Quote
  #8  
Old 11th September 2010, 01:07 AM
SunlightRider Offline
Registered User
 
Join Date: Sep 2010
Posts: 4
linuxfedorafirefox
Re: Macbook Backlight Keyboard Keybindings

Code:
Jsanchez[@]~/Scripts$notify-send run "/usr/bin/kb-backlight.pl up"
This was made on the console.

does notify, this means the script is executable by the user, and yes, gnome does popo that notify icon.

I Will check out some guide for XbindKeys when i have the time, probably in a little while.

Edit: I just added the notify into the binded command key. The following error goes on.

"Error While trying send-notify run sudo /usr/bin/kb-backlight which is binded to..."

Last edited by SunlightRider; 11th September 2010 at 01:11 AM. Reason: Anwsered too fast.
Reply With Quote
Reply

Tags
backlight, keybindings, keyboard, macbook

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Keyboard backlight xset led 3 fails JONOR Using Fedora 1 20th March 2010 12:34 PM
Live CD failed to run on MacBook, now MacBook won't boot noname Installation and Live Media 3 4th November 2009 03:19 PM
Macbook keyboard stone915 Hardware & Laptops 6 14th April 2009 03:54 PM
Macbook not Macbook pro - No sound and right click on the trackpad Andrew James Mac Chat 3 8th March 2009 05:33 PM
MacBook: keyboard layout scorpio2002 Hardware & Laptops 1 27th December 2006 04:20 AM


Current GMT-time: 21:54 (Friday, 24-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat