PeterCxy / evdev-right-click-emulation

Implement Long-Press-to-Right-Click on Touchscreen Linux Devices with Xorg or Wayland
Do What The F*ck You Want To Public License
91 stars 32 forks source link

Running As a Service in Kubuntu 20.04 #19

Open jaygotango opened 2 years ago

jaygotango commented 2 years ago

This may help someone.

It runs flawlessly as a service. After moving evdev-rce to /usr/local/sbin I created a evdev-rce.service file in /etc/systemd/system like this:

[Unit]
Description=Event Device Right Click Emulation
[Service]
ExecStart=/usr/local/sbin/evdev-rce
[Install]
WantedBy=multi-user.target

I had to do it because the program needed sudo to work.

I tested it with sudo systemctl start evdev-rce.service and noticed that long-press was also acting like a right click for the touchpad. I didn't want that, I only wanted it for the touchscreen so I stopped the service and added the environmental variable using:

sudo systemctl edit evdev-rce

and in the /etc/systemd/system/evdev-rce.service.d/override.conf created I added:

[Service]
Environment="TOUCH_DEVICE_WHITELIST=04F3:2A12"

To find the right ID to use for my device I ran this script found here: https://askubuntu.com/questions/520359/how-to-detect-touchscreen-devices-from-a-script

#!/bin/bash
tmp_dir=$(mktemp -d)
pushd $tmp_dir > /dev/null
# Export whole database 
udevadm info --export-db > udevdb.txt
csplit -s udevdb.txt /^$/ {*}

FILES=./xx*
for f in $FILES
do
  if [[ ! -z $(grep ID_INPUT_TOUCHSCREEN=1 $f) ]] && [[ ! -z $(grep " NAME=*" $f) ]]; 
  then
        # Extract touchscreen name
        grep " NAME=*" $f | cut -d "=" -f 2
  fi
done
popd > /dev/null
rm -rf $tmp_dir

Big thanks to artsin and Pablo Bianchi. The result gave me:

"CUST0000:00 04F3:2A12"

The first part, CUST0000:00 I didn't need. I used only the actual identifier, 04F3:2A12. This of course will be different for another machine. Then I tested again, and seeing it worked as I needed I installed it to run at startup with

sudo systemctl enable evdev-rce.service

It works flawlessly. This utility is a life-saver.

jaygotango commented 1 year ago

After a recent update I had to change the whitelist to:

[Service] Environment="TOUCH_DEVICE_WHITELIST=CUST0000:00 04F3:2A12"

for it to work. No idea why.