събота, 24 март 2018 г.

Howto change key bindings

My space key is sadly broken. I need a new laptop but I'd like to wait for the new  i8-i9 processors to arrive.  Anyway, the point is that the space is a key nobody notices until it's gone and then you realise that's the most used key on your keyboard. And life sucks without it.
So after a week of struggle with external keyboard, I decided to do the things the linux way.
I found a program xkeybidings which does exactly this.  Here you can find its wiki  and archwiki .  At first it was a bit unclear how to make it function properly, but after reading this tutorial, it worked!
 So first install xkeybindings
$sudo equo install xkeybindings
After the installation is complete, you need to do
$xbindkeys --defaults > /home/your-user-name/.xbindkeysrc
to get the default config file
Open .xbindkeysrc with a text editor.
If you don't know the name of the key you need, run in terminal
xbindkeys -k
or
xbindkeys -mk
for one or more keys - basically, you press the key you need and its name is written in the third line of the terminal (you need only it)
Now you can add your commands to the  .xbindkeysrc
In my case,  I added:
#########################
"xvkbd -xsendevent -text " ""
Shift_L
 
"kwrite"
   Alt + Alt_L + period
 
"dolphin"
   Alt + Alt_L + D

##########################
The first line makes my left shift key to a space. For the moment this seems like the most convenient choice - I tried with "menu" but that seems difficult to hit as I never use this key. 
I also tried binding it to capslock but I couldn't figure how to unbind it first and that changed the case after it added the interval.
You can turn off capslock with:
setxkbmap -option ctrl:nocaps
(or to turn it on with $ setxkbmap -option) but that also doesn't help. I turned it off so that I don't press it by accident.

The second line allows me to start kwrite by holding Alt+.
The third line starts dolphin by holding alt+d
You can add as many commands as you like. Though that's not that much because there are already many predefined key shortcuts in KDE.
In any case, this program is a lifesaver as I have so much to do and I definitely don't want to buy a new laptop before the new processors are out.

Also, in order for your new bindings to take effect, you need to run
$xkeybindings
after each restart or change in the config file. I wrote a script:
#!/bin/bash 
killall xbindkeys
xbindkeys

which can be then executed with 
$sh script.sh
P.S. If you need the number of certain key, you can find them here.

Няма коментари:

Публикуване на коментар