Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to remap my workspace switcher shortcut to a single key, specifically the Page Up/Page Down keys for going to the top/bottom workspace. But Ubuntu will not let me do this using System settings > Keyboard > Shortcuts, giving the following warning:

The shortcut "Page up" cannot be used because it will become impossible to type using this key. Please try with a key such as Control, Alt or Shift at the same time.

Is there any other way to remap shortcuts to a single key? Help is appreciated!

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

This is actually quite easy using the xbindkeys Install xbindkeys and the xdotool Install xdotool packages. xdotool lets you emulate key presses, and xbindkeys lets you add custom shortcuts.

All the following steps are run in a terminal.

First we will kill the process

killall xbindkeys

Now we put our custom shortcuts in the ~/.xbindkeysrc file

gedit ~/.xbindkeysrc

and we put in the following lines

"xdotool keyup Next && xdotool key ctrl+alt+Down"
   Next

"xdotool keyup Prior && xdotool key ctrl+alt+Up"
   Prior

save and close, and start xbindkeys again by running

xbindkeys 

It should now work like you wanted, enjoy!


Explanation: Now what does it actually do? Say, you press Page Up, your computer recognizes this as the Prior key (you can check this using xev | grep key and pressing keys). Now before we simulate other keypresses, we should emulate a key release first, that's what the xdotool keyup Prior is for. If it is released successfully then we send the Ctrl+Alt+Up combination and this is what xdotool key ctrl+alt+Up is for.

share|improve this answer
    
I recommend using touch .xbindkeysrc && xbindkeys -f .xbindkeysrc to create the config file so you don't get any of xbindkeys default bindings. –  Seth Feb 1 '13 at 0:32
    
@Seth Thanks nice suggestion, updated the answer. You don't need the -f .xbindkeysrc though, since it is the default. –  Gerhard Burger Feb 1 '13 at 10:28
    
thanks! now it works as I like! –  Kristoffer Feb 6 '13 at 12:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.