bulletmark / libinput-gestures

Actions gestures on your touchpad using libinput
3.93k stars 241 forks source link

Last update doesn't work anymore with my custom commands #259

Closed tanguyMichardiere closed 4 years ago

tanguyMichardiere commented 4 years ago

libinput-gestures -l output:

libinput-gestures: session unknown+tty on Linux-5.6.10-3-MANJARO-x86_64-with-glibc2.2.5, python 3.8.2, libinput 1.15.5
/sbin/libinput-gestures: hash b1fb733b08ae7c49c1660382dd44a5ed
Gestures configured in ~/.config/libinput-gestures.conf:
swipe left         desk next
swipe right        desk prev
libinput-gestures: device /dev/input/by-path/pci-0000:00:15.1-platform-i2c_designware.1-event-mouse(event10): ELAN1200:00 04F3:3022 Touchpad

desk is a utility I made in Rust, and it works fine when called in a terminal or from polybar, but since 2.50 it doesn't work anymore when called by libinput-gestures. It's a wrapper to wmctrl and it can't call it (simply says "no child processes") when called by libinput-gestures. Is there a change in groups or permissions in 2.50 that could have broken this ?

bulletmark commented 4 years ago

Are you saying it worked with version 2.49 but not with 2.50? If you look at the changes, there have been no actual code changes in libinput-gestures between those versions. All the changes were in documentation, icon design, and installation script.

BTW, as the instructions say, libinput-gestures does not run the configured command using any shell so at the very least you must specify the full path to the desk program/script. So I don't know how that would have worked, with any version of libinput-gestures? Please follow the trouble-shooting steps. Run your program by hand to ensure it works, then configure the full path in your configuration file, and see what errors are reported when libinput-gestures tries to run it.

tanguyMichardiere commented 4 years ago

About the version it worked with, i'm not sure since I use the Arch community package on Manjaro... For the trouble-shooting steps:

Running the program by hand in a terminal works, actually I also use it with Polybar and it works fine too. Configuring the full path in the configuration file changes nothing, actually libinput-gestures finds the program even without full path. The error reported by libinput-gestures when running desk is this:

thread 'main' panicked at 'failed to execute wmctrl, is it installed?: Os { code: 10, kind: Other, message: "No child processes" }', src/main.rs:6:18

but it's only the error reported by desk when it fails to call wmctrl, so what happens is: libinput-gestures ---> desk -x-> wmctrl whereas when I call it by hand: desk ---> wmctrl (works fine)

Though I understand that my problem is not 100% related to libinput-gestures, I was only hoping that you would know some particularity about how it calls the configured commands that would produce this result, so feel free to close the issue if you want

bulletmark commented 4 years ago

The bug is likely still related to $PATH though. Actually, my statement before was wrong. If your configured command does not specify a path then Python will at least look for the command in your $PATH and then invoke it. However $PATH is not passed on, so subsequently your called desk command can not find wmctrl (as the error message says).

Create a simple shell script, e.g. ~/bin/desk.sh:

#!/bin/bash
exec ~/bin/desk $*

This assumes you put your desk command in ~/bin/desk.

The configure your gestures as:

swipe left        ~/home/bin/desk next
swipe right       ~/home/bin/desk prev
tanguyMichardiere commented 4 years ago

I tried and it yields the same results. But I've also tried to print the environment inside desk and $PATH is actually here; calling "/sbin/wmctrl" instead of wmctrl also gives the same result, which made me think it wasn't a $PATH problem. "No child processes" sounds like a fork problem so I looked at how libinput-gestures runs external commands (Popen) and I found this: https://stackoverflow.com/questions/1008858/popen-communicate-throws-oserror-errno-10-no-child-processes I added

signal.signal(signal.SIGCHLD, signal.SIG_DFL)

at line 66 of libinput-gestures, right before the Popen call, and now it works. However they seem to say it can cause other problems.

bulletmark commented 4 years ago

Calling /sbin/wmctrl will give the same result because it should be /usr/bin/wmctrl.

tanguyMichardiere commented 4 years ago

Well I just tried whatever "which wmctrl" gave me, but anyway /sbin is just a symlink to /usr/bin and I tried that too but it didn't work without the "fix" I showed in my previous comment

bulletmark commented 4 years ago

Your opening description here states the bug was caused by the change to version 2.50 but now I realize you are experiencing a problem with commit feb768af1446c041663baa60b59b5b367d5016dd which was added in version 2.49. To be honest I was not entirely confident about that change when I accepted that PR so I will revert it, given it may break things as you have reported. There are probably others who have/will see this problem.

bulletmark commented 4 years ago

I've released version 2.51 which should fix this. Please confirm and I will close it.

tanguyMichardiere commented 4 years ago

Yes I confirm it works now! Thanks