LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Bind certain keys to change screen brightness (https://www.linuxquestions.org/questions/linux-general-1/bind-certain-keys-to-change-screen-brightness-820875/)

alquery 07-19-2010 09:23 PM

Bind certain keys to change screen brightness
 
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.

smoker 07-20-2010 10:46 PM

Is there a file relating to your laptop in /usr/share/hotkey-setup/ ?

If so, you may be able to edit that to use the keys you want.

This is the example for a samsung laptop.

alquery 07-29-2010 06:48 PM

No, there's not... Any other ideas?

alquery 08-19-2010 09:17 AM

bump

alquery 08-22-2010 04:07 PM

bump
 
bump

catkin 08-23-2010 09:51 AM

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.

alquery 08-23-2010 08:01 PM

Quote:

Originally Posted by catkin (Post 4075113)
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?

catkin 08-23-2010 09:08 PM

Quote:

Originally Posted by alquery (Post 4075581)
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?

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.

alquery 08-24-2010 02:26 PM

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?

catkin 08-24-2010 05:56 PM

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.

alquery 08-24-2010 06:38 PM

Quote:

Originally Posted by catkin (Post 4076636)
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.


All times are GMT -5. The time now is 03:45 PM.