Skip to content

Instantly share code, notes, and snippets.

@joschka
Last active January 1, 2022 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joschka/d33fa2c6b7c45abbf9d4f432465b8573 to your computer and use it in GitHub Desktop.
Save joschka/d33fa2c6b7c45abbf9d4f432465b8573 to your computer and use it in GitHub Desktop.

Macropad with an old keyboard and actkbd on Arch Linux

Disable the regular keyboard behavior with xinput

  sudo pacman -Sy xorg-input
  xinput list
  xinput disable <ID>
  • find the keyboard in the list and take the id
  • disable that id, so key presses are no longer working (will still work with actkbd)

Run actkbd to map key presses to commands

  cat /proc/bus/input/devices
  • find the keyboard and take the eventXX from Handlers
  trizen -Sy actkbd
  actkbd -h
  actkbd -x -s -d /dev/input/eventXX
  • install actkbd from AUR and check the options
  • -s shows the typed key code
  • -x shows the executed command (there are none yet)

Edit /etc/actkbd.conf

Example:

79:::xdotool key super+Left
80:::xdotool key super+Down
81:::xdotool key super+Right
75:::xdotool key super+1
76:::xdotool key super+Up
77:::xdotool key super+2
71:::xdotool key super+3
72:::xdotool key super+4
73:::xdotool key super+5

82:::xdotool key Escape
83:::i3-msg exec i3-sensible-terminal
78:::i3-msg mode "move to workspace"
96:::i3-msg mode "move"

69:::i3-msg split v
98:::i3-msg split h
55:::i3-msg fullscreen
74:::i3-msg kill
  • key codes (e.g. 79 is the 1 on my numpad) mapped to shell commands
  • xdotool key presses the specified key or key combo

Setup automatically when plugging in keyboard

Start script /opt/start_actkbd:

#!/bin/bash

export DISPLAY=:0
export XAUTHORITY=/home/j/.Xauthority

event=`cat /proc/bus/input/devices | grep 046a -A 5 | grep -o -P 'event\d+'`

sleep 1

id=`/usr/bin/xinput list | grep 046a:0011 | grep -o -P 'id=\d+' | sed s/id=//`

/usr/bin/xinput disable $id

/usr/bin/actkbd -x -s -d /dev/input/$event
  • j is the user running xserver (adapt to your situation)
  • 046a is the vendor code from Cherry (adapt to your situation)
  • chmod +x /opt/start_actkbd
  • test it, next Systemd service

Systemd service unit /etc/systemd/system/macropad.service:

[Unit]
Description=Start actkbd when macropad connected

[Service]
ExecStart=/opt/start_actkbd
  • test it: systemctl start macropad.service and systemctl status macropad.service
  • next run the service when keyboard is plugged in

udev rule /etc/udev/rules.d/72-macropad.rules:

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="046a", ATTRS{idProduct}=="0011", OWNER="j", TAG+="systemd", ENV{SYSTEMD_WANTS}="macropad.service"
  • again adapt to your user and keyboard

Sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment