alesya-h / linux_detect_tablet_mode

Detect if your laptop is in normal or tablet mode. Useful for Yoga laptops to disable keyboard/trackpoint/touchpad in a tablet mode
MIT License
137 stars 29 forks source link

permission denied? #18

Closed Adventure4Life closed 4 years ago

Adventure4Life commented 4 years ago

I can not work out how to get this script working... like others posted the command stdbuf -oL libinput debug-events|grep switch seems to do nothing.. it just sort of goes to a new line and runs... I get no outputs of any kind and have to ctrl+c out. If I run it without the grep I get a ton of info, but nothing seems to happen when I fold the laptop. The LS command seemed to return results I could use?

~ ❯❯❯ ls -lh /dev/input/by-path
total 0
lrwxrwxrwx 1 root root 10 Jul 21 14:50 pci-0000:00:14.0-usb-0:1:1.1-event-mouse -> ../event13
lrwxrwxrwx 1 root root  9 Jul 21 14:50 pci-0000:00:14.0-usb-0:1:1.1-mouse -> ../mouse2
lrwxrwxrwx 1 root root 10 Jul 21 14:50 pci-0000:00:14.0-usb-0:8:1.0-event -> ../event12
lrwxrwxrwx 1 root root  9 Jul 21 14:50 pci-0000:00:15.0-platform-i2c_designware.0-event-mouse -> ../event6
lrwxrwxrwx 1 root root  9 Jul 21 14:50 pci-0000:00:15.0-platform-i2c_designware.0-mouse -> ../mouse4
lrwxrwxrwx 1 root root  9 Jul 21 14:50 pci-0000:00:15.1-platform-i2c_designware.1-event -> ../event8
lrwxrwxrwx 1 root root  9 Jul 21 14:50 pci-0000:00:15.1-platform-i2c_designware.1-event-mouse -> ../event7
lrwxrwxrwx 1 root root  9 Jul 21 14:50 pci-0000:00:15.1-platform-i2c_designware.1-mouse -> ../mouse0
lrwxrwxrwx 1 root root  9 Jul 21 14:50 pci-0000:00:1f.0-platform-VPC2004:00-event -> ../event4
lrwxrwxrwx 1 root root  9 Jul 21 14:50 platform-i8042-serio-0-event-kbd -> ../event3

I assume that pci-0000:00:1f.0-platform-VPC2004:00-event is the correct event... so I made the config file.... (I also tried pci-0000:00:15.1-platform-i2c_designware.1-event)


input_device: /dev/input/by-path/pci-0000:00:1f.0-platform-VPC2004:00-event
modes:
  laptop:
     - xinput enable "AT Translated Set 2 keyboard"
  tablet:
     - xinput disable "AT Translated Set 2 keyboard"

but whenever I run the script I get....

Failed to open /dev/input/event4 (Permission denied)
Failed to initialize device /dev/input/by-path/pci-0000:00:1f.0-platform-VPC2004:00-event

I tried copying it into /root/.config and then running the script with sudo... but I got the same erorr...

I'd appreciate any advise you may have on this.. thanks.

alesya-h commented 4 years ago

If stdbuf -oL libinput debug-events|grep switch prints nothing when you convert your laptop, then most likely your device is not supported, and this script won't work for you. The script uses libinput debug-events internally, with input_device property being there to filter out irrelevant events, it just adds --device argument to libinput debug-events.

You may try to run sudo stdbuf -oL libinput debug-events|grep switch and see if it shows anything. If it works, check permissions for those input devices. On my machine they belong to user root and group input, so to have access you'd add yourself to the input group. This is distribution-dependent, so check it yourself. If running that command with sudo still doesn't show anything - you are out of luck here. You might try luck with the older version of this script, I put under old/ in the repository: https://github.com/alesguzik/linux_detect_tablet_mode/tree/master/old . It uses a pair of accelerometers instead of mode switch events.

Adventure4Life commented 4 years ago

ok thanks.. I see.. I still couldn't get it to work, but I appreciate you taking the time to respond.