Mouse wheel as key on pocketchip keyboard
The PocketCHIP comes with a fully functional keyboard, touchscreen and a USB port. You can simply plug a mouse into the USB port. But I don't want to take a usb mouse with me. The tool xbindkeys allows it to bind the mouse button or the mouse wheel to a keyboard shortcut.
Alt + V: Mouse middle click (primary selection)
Alt + O: Mouse wheel up
Alt + ; (semicolon): Mouse wheel down
Install xdottol and xbindkeys
sudo apt install xdotool xbindkeys
xdottol allows to emulate keyboard and mouse events by shell commands. So you can "use" the mouse wheel by shell. xbindkeys allows you to bind a keyboard shortcut to a shell command.
Create default config
xbindkeys -d > ~/.xbindkeysrc
Get key codes
xbindkeys -k and hit a keyboard shortcut of your choice.
chip@chip:~$ xbindkeys -k Press combination of keys or/and click under the window. You can use one of the two lines after "NoCommand" in $HOME/.xbindkeysrc to bind a key. "(Scheme function)" m:0x8 + c:32 Alt + o
chip@chip:~$ xbindkeys -k Press combination of keys or/and click under the window. You can use one of the two lines after "NoCommand" in $HOME/.xbindkeysrc to bind a key. "(Scheme function)" m:0x8 + c:60 Alt + period
Add key bindings
Now open the
~/.xbindkeysrc config file with an editor of your choice and add the new key bindings.
"xdotool click --delay 5 --repeat 3 --clearmodifiers 4" m:0x8 + c:32 Alt + o "xdotool click --delay 5 --repeat 3 --clearmodifiers 5" m:0x8 + c:60 Alt + period
xbindkeys -n to test your configuration. The
-n option starts xbindkeys in foreground. You can stop xbindkeys with the keyboard shortcut
Create a shell script
~/.xsessionrc with the following content:
#!/bin/sh xbindkeys exit 0
Make it executable:
chmod a+x ~/.xsessionrc
~/.xsessionrc will be executed on every X11 launch. A handy solution to start userspace applications after PocketCHIP starts.