You can remap the key using ~/.Xmodmap
. Use xev
(in a terminal) to find the offending keycode, then assign a different keysym, e.g. XF86WakeUp. Append this line to ~/.Xmodmap
(create that file if it does not yet exist):
keycode 150 = XF86WakeUp
After logging out and logging in again your key should be mapped. If you don't want to log out, you can also use xmodmap ~/.Xmodmap
to reload the key mappings.
Using xev
to actually find the keycode of the key that you want to remap might be not so easy: if the key is already bound to an action (e.g. in the Gnome keyboard properties), xev
does not show the keycode. As an example, this is the kind of xev
output that you want to see:
KeyPress event, serial 41, synthetic NO, window 0x5800001,
root 0xb3, subw 0x0, time 312883, (737,182), root:(946,647),
state 0x0, keycode 180 (keysym 0x1008ff18, XF86HomePage), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
You can see the keycode (180) in the third line after the word "keycode". If you don't get such a block that starts with "KeyPress event", your key probably is already bound. You can try to use a non-Gnome desktop like LXDE or KDE and use xev
there.
Ok, In Xubuntu it is a bit different, first when you hit Add It comes up with this screen-
Which is exactly as you described, First put the command you want in, from the link you were flowing after installing powermanagement-interface
you put in the command box pmi action suspend
then hit OK The next screen will let you Key in the Shortcut you want to use, Press the key combo you want to use then release-
If you accidentally hit a wrong button, or want to edit the shortcut, just double click on the shortcut area of the command-
Best Answer
You can do that by using the following:
In a keyboard shortcut you need to put
sh -c "<command>"
replacing<command>
with the command above, like:If the above command does not work, you can also try using a shell script file (for example
suspend_lockscreen.sh
). First create the file call the following commands in a console:That will create a file named suspend_lockscreen.sh in the user home folder. Then, in the shortcut just call:
./suspend_lockscreen.sh
.Note:
gnome-screensaver-command
can be replaced byxscreensaver-command
, as pointed out in one comment.