Keys and mouse
5.1
How to change the mouse and touchpad, add your own keyboard shortcuts and make the extra keys of a keyboard or a mouse do something. The Handbook lists the shortcuts of the desktop; the keyboard layout is a system setting, see Screen, keyboard layout and Xorg.
Mouse, touchpad and key repeat
In the LXTaz session, open LXTaz Desktop Preferences from the Dash, page Mouse and keyboard:
- Mouse: pointer speed, and Left-handed to swap the left and right buttons;
- Touchpad: tap to click and natural scrolling (shown when the machine has a touchpad);
- Keyboard: how long a held key waits before it repeats, and how fast it repeats.
A change applies at once and comes back at each login. The same window
opens from a terminal with lxtaz-prefs input. In the classic LXDE
session, the same mouse and keyboard settings are in Keyboard and
Mouse (lxinput).
From the command line
Other window managers (JWM, Openbox alone) have no settings window.
xorg-xmodmap swaps the mouse buttons for a left-handed user:
# spk-add xorg-xmodmap
$ xmodmap -e "pointer = 3 2 1"
xmodmap -e "pointer = 1 2 3" sets it back and xmodmap -pp shows the
buttons. The touchpad is driven by synclient, for example to turn tap
to click on:
$ synclient TapButton1=1
synclient -l lists every option and its value. These commands last
until you log out: to run them at each login, put them in an autostart
file, see below.
Your own shortcuts with Openbox
The LXTaz and LXDE sessions run the Openbox window manager: it holds
the shortcuts, in the <keyboard> section of ~/.config/openbox/rc.xml.
If you have no such file yet, start from the system one:
$ mkdir -p ~/.config/openbox
$ cp /etc/xdg/openbox/rc.xml ~/.config/openbox/
Add a keybind inside <keyboard>, for example Super+B to open the web
browser:
<keybind key="W-b">
<action name="Execute">
<command>browser</command>
</action>
</keybind>
W is Super (the Windows key), C Ctrl, A Alt and S Shift. Then
reload the file:
$ openbox --reconfigure
The keys of the system file show how it is done: volume and brightness
keys call tazvolume and tazbacklight, Print calls lxtaz-shot.
Extra keys with xbindkeys
xbindkeys starts a command from a key or a mouse button, whatever the window manager: handy for the extra keys of a multimedia keyboard (home page, mail, calculator) or the side buttons of a mouse.
# spk-add xbindkeys
Find the code of a key
$ touch ~/.xbindkeysrc
$ xbindkeys -k
A small white window opens: press the key. The terminal shows three lines, for example:
"NoCommand"
m:0x10 + c:180
Mod2 + XF86HomePage
xbindkeys -mk does the same for a combination of keys, like Ctrl+F.
Bind a command
Open ~/.xbindkeysrc in a text editor and add the command between
quotes, then one of the two lines below it, the key name or its code:
# Home page key: the web browser
"browser"
XF86HomePage
# Calculator key
"galculator"
XF86Calculator
Start xbindkeys, or restart it after a change:
$ killall xbindkeys
$ xbindkeys
With xbindkeys -p, it reloads the file by itself when you save it.
The mouse buttons are b:1 to b:9. On many mice, b:8 and b:9 are
the side buttons. With xdotool installed, they can act as Back and
Forward in a web browser:
"xdotool key alt+Left"
b:8
"xdotool key alt+Right"
b:9
Start it at login
Create ~/.config/autostart/xbindkeys.desktop:
[Desktop Entry]
Type=Application
Name=xbindkeys
Exec=xbindkeys
Log out and in again. The same kind of file runs xmodmap or
synclient at login: put the command on the Exec line. A file in
/etc/xdg/autostart/ does it for every user.
Tips
- Volume, brightness, Print and the power key already work: Openbox holds them, and xbindkeys cannot take a key that Openbox already uses.
xbindkeys --defaults > ~/.xbindkeysrcwrites a sample file with comments and examples. Comment out the examples you do not want: they open an xterm with Ctrl+F or Ctrl+middle click.xev(packagexorg-xev) shows every key and button event, whenxbindkeys -kis not enough.
Troubleshooting
A key does nothing: check that X sees it, with xbindkeys -k. If no
code shows up, the kernel or X does not send this key: there is nothing
to bind.
xbindkeys says it cannot find its file: create it, even empty, with
touch ~/.xbindkeysrc.
The shortcut opens the wrong program: look for the same key in
~/.config/openbox/rc.xml and in ~/.xbindkeysrc: one key, one place.