Sunday, April 28, 2024
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 1884  / 2 Years ago, sun, november 21, 2021, 8:31:26

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!


More From » shortcut-keys

 Answers
3

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.


[#32905] Monday, November 22, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ularousand

Total Points: 380
Total Questions: 109
Total Answers: 101

Location: England
Member since Tue, Sep 8, 2020
4 Years ago
;