[SOLVED] Bind certain keys to change screen brightness
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi - I am using Ubuntu linux, and I want fn + up key and fn + down key to change the brightness instead on fn + F4 and fn + F5. I've tried looking for something in the Keyboard Shortcuts menu, but there is no command or key specified to do that. I could make a custom key shortcut, but I can't find the command to change the brightness. Is there a way to make another key do this?
My laptop is a Dell Inspiron 1545.
Have you tried running the setkeycode commands illustrated in the linked page? There are similar commands on this Arch Linux Wiki page for a Samsung N150.
On a Samsung N150 running Slackware 13.1 Linux and Xfce desktop, I enabled brightness adjustment via Fn+Up and Fn+Dn by running the following commands from the boot scripts
Code:
setkeycodes e008 225 # Fn+Up maps to brightnessup
setkeycodes e009 224 # Fn+Dn maps to brightnessdown
These are made effective in the GUI by mapping XF86MonBrightnessDown (and Up) to call a custom script.
Have you tried running the setkeycode commands illustrated in the linked page? There are similar commands on this Arch Linux Wiki page for a Samsung N150.
On a Samsung N150 running Slackware 13.1 Linux and Xfce desktop, I enabled brightness adjustment via Fn+Up and Fn+Dn by running the following commands from the boot scripts
Code:
setkeycodes e008 225 # Fn+Up maps to brightnessup
setkeycodes e009 224 # Fn+Dn maps to brightnessdown
These are made effective in the GUI by mapping XF86MonBrightnessDown (and Up) to call a custom script.
When I try those commands, I get this:
Code:
Couldn't get a file descriptor referring to the console
I'm very confused here, and what's all this about Samsung N150? Do these keycodes still apply to me if I'm not using that? Also, I have no /usr/share/hotkey-setup directory. Why don't I have one?
Last edited by alquery; 08-23-2010 at 08:02 PM.
Reason: Got rid of obvious question
Couldn't get a file descriptor referring to the console
I'm very confused here, and what's all this about Samsung N150? Do these keycodes still apply to me if I'm not using that? Also, I have no /usr/share/hotkey-setup directory. Why don't I have one?
Were you root or an ordinary user?
Ideally you want someone answering who has got those keys working on the same laptop as yours, using the same distro but they haven't come along yet. Laptops/netbooks differ, distros differ (there's no /usr/share/hotkey-setup on my Slackware 13.1 system either) but some things work the same way (the distros are all Linux-based, manufacturers use the same chips) so it's worth trying things that have worked on dissimilar systems.
Okay, so I entered the commands as root and it didn't give me any errors. However, the arrow keys still don't work for changing brightness. I've tried finding out the keycodes with xev, but it returns the same code whether I'm holding down fn or not. I also tried mapping it using System > Preferences > Keyboard Shortcuts, but it wouldn't recognize fn + up as any different from just up either. It seems like the keyboard only recognizes key combinations with functions that came with the computer, not fn as a separate key, like I thought. Is there any way to change this, or is it set in stone?
It may be that the keycodes generated by Fn+Up/Dn on a Dell Inspiron 1545 are not the same as on a Samsung N10 or N150. Unfortunately IDK how you can find out what they are. xev output for Fn+Up/Dn on my system doesn't make much sense either.
It would make sense for the keyboard not to output anything unless the Fn modifier is used with a key "that came with the computer", usually marked in blue (all the arrow keys are marked in blue on the N150).
The Fn is a modifier key, as are like alt, ctrl, shift and super. I thought modifier keys alone did not generate keycodes but recently found that is wrong having been able to interactively set super alone (and super+e) as shortcut keys under Xfce.
There is thus some hope for being able to do what you want but I don't know the crucial next step of how to find out the keycodes generated by experimental key and key combination use. You could start a new topic asking that question.
It may be that the keycodes generated by Fn+Up/Dn on a Dell Inspiron 1545 are not the same as on a Samsung N10 or N150. Unfortunately IDK how you can find out what they are. xev output for Fn+Up/Dn on my system doesn't make much sense either.
It would make sense for the keyboard not to output anything unless the Fn modifier is used with a key "that came with the computer", usually marked in blue (all the arrow keys are marked in blue on the N150).
The Fn is a modifier key, as are like alt, ctrl, shift and super. I thought modifier keys alone did not generate keycodes but recently found that is wrong having been able to interactively set super alone (and super+e) as shortcut keys under Xfce.
There is thus some hope for being able to do what you want but I don't know the crucial next step of how to find out the keycodes generated by experimental key and key combination use. You could start a new topic asking that question.
This is getting a bit out of hand here, just to change a few keys
I'll just use the GUI to set the Control key instead, so ctrl + up and down to xbacklight -inc 10 and xbacklight -dec 10, respectively.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.