Where / how are the Fn keymappings stored?


Emnasut

Member
Joined
Apr 26, 2010
Messages
357
So I wanted to adjust how Fn+U and Fn+I (brightness up and down) work. I found the scripts on /usr/pandora/scripts and edited op_bright_down.sh, mainly adjusting the values of brightness which are set to prevent flickering and make it dim faster. In the final if-clause where it checks if the lowest value is reached I added the line:



Code:
notify-send -u normal "Display" "Minimum Brightness reached."



Now if I run the script:



Code:
sudo op_bright_down.sh

it works as intended, that is the brightness gows down and at the lowest value a message pops up.

The problem is, it doesn't work by using Fn+U. The script seems to be called as the brightness doesn't get as low as before, but there ist not notification and it seems to be a bit different than calling the script directly. Also happens afer a reboot.

Then I used Settings -> Keyboard -> Application Shortcuts to map the script op_wifi.sh to SHIFT+CTRL+W so I could toggle Wifi without the menu. In this case, *only* the message pops up, saying "WLAN is being enabled..." (or disabled, depending on the state), but Wifi never actually does get enabled.



I used sudo showkey to get the keycodes of Fn+U:



Code:
keycode 0 press

keycode 1 release

keycode 96 release

And Fn+I:



Code:
keycode 0 press

keycode 1 release

keycode 97 release



But according to xmodmap -pke:



Code:
keycode 96 = F12 NoSymbol F12

keycode 97 =


So... I really have no idea what to try next... Anyone got an idea?
 
op_wifi.sh needs to be called by super user. Prepend your shortcut with sudo if you aren't already. If you are then I'm at a loss as to why it wouldn't work.
 
Hm I was calling the script directly in Application Shortcuts. Of course I could wrap the call in another .sh with sudo in it, but wouldn't that force me to always enter my root password (if it would work at all) whenever toggling wifi? Where does xfce store its menu entries and how can it execute stuff as root?


Edit: Ok, now it's working for Wifi; I really had to create another script with just the entry



Code:
sudo /usr/pandora/scripts/op_wifi.sh
and now SHIFT+CTRL+W works. I still don't understand why though; if XFCE is root why would I need sudo, and if it *isn't* root, than how come I don't have to enter the root password? Would this mean anyone could execute any sudo script without the password just by making a keyboard shortcut?
 
Last edited by a moderator:
xfce4-session is run as the user who is logging in. I'm pretty sure all other window managers do this as well: they have the login program, whatever it may be, running as root which confirms the login credentials and launches a user specific manager.


op_wifi, I believe, is in the sudoers file as not needing a password. It needs to be super user because it starts and stops kernel modules, but a super user (ie, opt) has said "users are ok to do this in this specific case". It needs to be explicitly specified to not require a password. Try it on the command line, you'll see it doesn't ask for a password, but other sudo commands still do.


And the thing I remember about XFCE and shortcuts now is that it runs the entire command as a command. That is, if you put "sudo /usr/pandora/scripts/op_wifi.sh", it doesn't run sudo with op_wifi as an argument, it tries to run the entire thing, as if "sudo " (complete with space) were just some directory. I had to create a similar script when I changed my default browser to Firefox because of command line arguments.
 
Back
Top