The core of this solution is thanks to https://www.gilesorr.com/blog/powermate-on-linux.html who modified the work of https://m0aws.co.uk/?p=2201
The Griffin Powermate is a USB knob that can be used for various purposes. Originally marketed as a volume knob, you can map it to any function you like. (I use it as a mouse scroll wheel for my non-mouse hand.)
This solution uses the evtest
program to read the input from the Powermate and then uses dotool
to simulate keyboard/mouse events.
This repo contains:
powermate.sh
- a script that reads the Powermate input usingevtest
and sends mouse/keyboard events viadotoolc
dotoold.service
- starts thedotoold
daemon that listens for commands from thedotoolc
client program.powermate.service
- starts thepowermate.sh
script as a user service.99-powermate.rules
- a udev rule that starts thepowermate.service
when the Powermate is plugged in.
I developed and tested this on Arch Linux with the Wayland display server.
If you're using Xorg, you can use xdotool instead of dotool.
Yeah. I don't love it either. You can do all of this from udev
.
Instead of starting the service with systemd, you can start the powermate.sh
script directly from the udev rule.
You'll also want to write a script that kills the powermate.sh
process when the Powermate is unplugged and run that script from the udev rule for the remove
action.
Install evtest
and dotool
(or xdotool
) for your distro.
Create the systemd user directory:
mkdir -p ~/.config/systemd/user
Copy the services to the systemd user directory:
cp *.service ~/.config/systemd/user/
Copy the powermate.sh script to ~/bin/
(or /usr/local/bin
or wherever you prefer):
cp powermate.sh ~/bin/
Copy the udev rule to /etc/udev/rules.d/
:
sudo cp 99-powermate.rules /etc/udev/rules.d/
Double check the idProduct
and idVendor
in the udev rule to make sure they match your Powermate. Use the following command to find the idProduct
and idVendor
:
udevadm info -a -p $(udevadm info -q path -n /dev/input/by-id/usb-Griffin_Technology__Inc._Griffin_PowerMate-event-if00)
Edit the .service
files to point to the correct paths for powermate.sh
and dotoold
.
Edit the udev rule and put your username in place of <your-username>
.
Reload the udev rules:
sudo udevadm control --reload-rules
sudo udevadm trigger
Enable and start the systemd services:
systemctl --user daemon-reload
systemctl --user enable dotoold.service
systemctl --user enable powermate.service
At this point, you can either:
- Manually start the services with
systemctl --user start dotoold.service
andsystemctl --user start powermate.service
- Log out and back in to start the services automatically
To see what's going on with the powermate.sh
script, you can run journalctl --user -u powermate.service -f
.
And to see what's going on with the udev rule, you can run sudo journalctl -f -u systemd-udevd
.