jbensmann / mouseless

A replacement for the mouse in Linux
MIT License
170 stars 16 forks source link

How can we use mouseless with kmonad? #4

Closed isaif closed 1 year ago

isaif commented 1 year ago

I am already using kmonad, but I want to know if i can use both kmonad and mouseless together.

Using debug mode I can see error "Failed to open /dev/input/by-id/usb-CHESEN_USB_Keyboard-event-kbd: device or resource busy". I guess it is because kmonad is already using it. Any fix for this?

jbensmann commented 1 year ago

Yeah that is actually possible, only one program can read the original device and the other has to read from the virtual device created by the first program, which is one of/dev/input/event*. For mouseless I think it is always the same, I can check it again when I am back from holidays. Note that the second program has to consider the remappings of the first program.

jbensmann commented 1 year ago

Ok it is not always the same, but one can see the device of mouseless or kmonad with libinput list-devices, maybe it is at least stable on the same PC. Another option would be to write a script that starts mouseless, finds out the device, replaces the device in the kmonad config and starts kmonad (or the other way around if you want to start kmonad first).

isaif commented 1 year ago

I am using linux and would like to start kmonad first. Any help regarding how to write the script will be most helpful.

jbensmann commented 1 year ago

Here is an example, it assumes that kmonad is running and that you have specified a device like /dev/input/event123 in the mouseless config, which is then replaced with the kmonad device. Note that you have to use sudo in case you did not add permissions.

#!/usr/bin/env sh
device=$(libinput list-devices | grep -i "kmonad" -A10 | grep "Kernel:" | sed 's_.*\(/dev/input/event[0-9]*\).*_\1_')
[ -z "$device" ] && echo "kmonad device not found" && exit 1
echo "kmonad device found: $device"
sed -i 's_- "/dev/input/event[0-9]*"_- "'"$device"'"_' ~/.config/mouseless/config.yaml
mouseless --config ~/.config/mouseless/config.yaml
isaif commented 1 year ago

It works!! Thanks for your patience and help.