bulletmark / libinput-gestures

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

Command delay #151

Closed stefanocirici closed 6 years ago

stefanocirici commented 6 years ago

Running libinput-gestures -d I can see that the command is recognized very quickly but the action is done with 1.5-2 second of delay.

This happen for all xdotool key action (eg. xdotool key super+Left, xdotool key control+Tab etc) Only xdotool set_desktop --relative 1 is responsive. Command like gesture swipe up 4 dbus-send --session --type=method_call --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval string:'Main.overview.toggle();' are responsive too.

bulletmark commented 6 years ago

Can you please be clear on what delay you are quoting? What is the exact start point you are timing from? This utility simply invokes the configured command when libinput signals the end of a gesture so if you take 1.5 secs to move your fingers up then the command will only get executed when you finally lift your fingers off the touchpad. E.g. if you swipe up but then decide to cancel the gesture you can move sideways off the touchpad or move back to the start point then libinput will "cancel" the gesture and libnput-gestures will do nothing.

In practice people just do a short quick flick up or down (e.g. to change their workspace) and the speed s fine. Note that Mac and Windows do the same thing and only action the gesture at the end when you lift your fingers (although in those cases they show you an animation/preview of what is about to happen which is admittedly very nice).

stefanocirici commented 6 years ago

The delay I was talking is (hand calculated) from when I see the end of gesture (in libinput-gestures -r log) to when the gesture action is performed. The gesture is recognized very quickly (e.g. from GESTURE_SWIPE_BEGIN to GESTURE_SWIPE_END) but the action has some delay.

bulletmark commented 6 years ago

Please paste output of libinput-gestures -l here so I can see your environment and configuration. This is a simple and lightweight utility so there should be no delay.

stefanocirici commented 6 years ago
$ libinput-gestures -l
libinput-gestures: session ubuntu+x11 on Linux-4.15.0-20-generic-x86_64-with-Ubuntu-18.04-bionic, python 3.6.5, libinput 1.10.4
Gestures configured in ~/.config/libinput-gestures.conf:
swipe up         3 xdotool set_desktop --relative 1
swipe down       3 xdotool set_desktop --relative -- -1
swipe left       3 xdotool key super+Left
swipe right      3 xdotool key super+Right
swipe left       4 xdotool key alt+Escape
swipe right      4 xdotool key shift+alt+Escape
swipe up         4 dbus-send --session --type=method_call --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval string:Main.overview.toggle();
swipe down       4 xdotool key super+x
swipe right_up   3 xdotool key control+Tab
swipe left_up    3 xdotool key control+shift+Tab
swipe left_down  3 xdotool key control+w
swipe right_down 3 xdotool key control+shift+t
pinch in           xdotool key ctrl+minus
pinch out          xdotool key ctrl+plus
libinput-gestures: device /dev/input/event19: ELAN1300:00 04F3:3059 Touchpad

EDIT: I think the delay is caused by xdotool. Executing a single command (e.g xdotool key super) has the same delay I was talking above. Is there an alternative of using xdotool?

bulletmark commented 6 years ago

Always test your xdotool command before you configure it in libinput-gestures.conf.

xdotool does not delay at all on my system and I have never heard of anybody else saying it so there is likely a configuration error on your system. Play around with other tools which query your X server (e.g. xdpyinfo and see if they have a delay).

stefanocirici commented 6 years ago

I found the problem. It seems that when you use two or more keyboard layout, xdotool has this delay in all layouts but the main one. I am not sure while this happen.

bianchinirick commented 6 years ago

When I use gnome-shell (ubuntu-18.04), I have the exactly same problem. I'm surprised that no one else commented about this problem. I really think that it's a gnome-shell problem. The same occurs on HDMI monitors when press the volume up shortcut. That is an annoing problem.

ddnexus commented 6 years ago

Same annoying problem here (ubuntu-18.04). I almost never use the second layout and I discovered this only accidentally by switching it. The problem is very easily reproducible.

It looks like it is a problem of the xdotool command and it has nothing to do with libinput-gestures. You get it also by running the command directly in the terminal.

Ospeto commented 5 years ago

How to solve this problem with two keyboard layout? I must use two keyboard layout for my mother language and English.

Ospeto commented 5 years ago

Same annoying problem here (ubuntu-18.04). I almost never use the second layout and I discovered this only accidentally by switching it. The problem is very easily reproducible.

It looks like it is a problem of the xdotool command and it has nothing to do with libinput-gestures. You get it also by running the command directly in the terminal.

How to solve this problem with two keyboard layout? I must use two keyboard layout for my mother language and English.

ddnexus commented 5 years ago

It is a bug still open after many years: https://github.com/jordansissel/xdotool/issues/10

Nikolay-Kha commented 5 years ago

I found a workaround for this issue. I replaced xdotool with xte.

gesture: swipe up   3   xte "keydown Alt_L" "keydown Control_L" "key Down" "keyup Control_L" "keyup Alt_L"
gesture: swipe down 3   xte "keydown Alt_L" "keydown Control_L" "key Up" "keyup Control_L" "keyup Alt_L"
gesture: swipe right    4   xte "keydown Shift_L" "keydown Control_L" "key Tab" "keyup Control_L" "keyup Shift_L"
gesture: swipe left 4   xte "keydown Alt_L" "key Tab" "keyup Alt_L"
gesture: swipe left 3   xte "keydown Alt_L" "key Right" "keyup Alt_L"
gesture: swipe right    3   xte "keydown Alt_L" "key Left" "keyup Alt_L"
gesture: pinch out  xte "keydown Shift_L" "keydown Control_L" "key plus" "keyup Control_L" "keyup Shift_L"
gesture: pinch in   xte "keydown Control_L" "key minus" "keyup Control_L"
gesture: swipe up   4   dbus-send --session --type=method_call --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval string:'Main.overview.toggle();'
gesture: swipe down 4   xte "keydown Super_L" "key A" "keyup Super_L"

I also posted my config here - https://github.com/bulletmark/libinput-gestures/wiki/Custom-config-for-xte-instead-xdotool

Ospeto commented 5 years ago

I found a workaround for this issue. I replaced xdotool with xte.

gesture: swipe up 3   xte "keydown Alt_L" "keydown Control_L" "key Down" "keyup Control_L" "keyup Alt_L"
gesture: swipe down   3   xte "keydown Alt_L" "keydown Control_L" "key Up" "keyup Control_L" "keyup Alt_L"
gesture: swipe right  4   xte "keydown Shift_L" "keydown Control_L" "key Tab" "keyup Control_L" "keyup Shift_L"
gesture: swipe left   4   xte "keydown Alt_L" "key Tab" "keyup Alt_L"
gesture: swipe left   3   xte "keydown Alt_L" "key Right" "keyup Alt_L"
gesture: swipe right  3   xte "keydown Alt_L" "key Left" "keyup Alt_L"
gesture: pinch out    xte "keydown Shift_L" "keydown Control_L" "key plus" "keyup Control_L" "keyup Shift_L"
gesture: pinch in xte "keydown Control_L" "key minus" "keyup Control_L"
gesture: swipe up 4   dbus-send --session --type=method_call --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval string:'Main.overview.toggle();'
gesture: swipe down   4   xte "keydown Super_L" "key A" "keyup Super_L"

I also posted my config here - https://github.com/bulletmark/libinput-gestures/wiki/Custom-config-for-xte-instead-xdotool

i replaced my config with yours and it is not working at all, can u please enlighten me how to properly do it. Thanks u so much.

Nikolay-Kha commented 5 years ago

try to run:

xte "keydown Super_L" "key A" "keyup Super_L"

any output? Can you see OS menu? Have you installed xte?

sudo apt install xautomation
Ospeto commented 5 years ago

try to run:

xte "keydown Super_L" "key A" "keyup Super_L"

any output? Can you see OS menu? Have you installed xte?

sudo apt install xautomation

its working after installing xautomation, thanks u so much.

zegrisi commented 5 years ago

I found a workaround for this issue. I replaced xdotool with xte.

gesture: swipe up 3   xte "keydown Alt_L" "keydown Control_L" "key Down" "keyup Control_L" "keyup Alt_L"
gesture: swipe down   3   xte "keydown Alt_L" "keydown Control_L" "key Up" "keyup Control_L" "keyup Alt_L"
gesture: swipe right  4   xte "keydown Shift_L" "keydown Control_L" "key Tab" "keyup Control_L" "keyup Shift_L"
gesture: swipe left   4   xte "keydown Alt_L" "key Tab" "keyup Alt_L"
gesture: swipe left   3   xte "keydown Alt_L" "key Right" "keyup Alt_L"
gesture: swipe right  3   xte "keydown Alt_L" "key Left" "keyup Alt_L"
gesture: pinch out    xte "keydown Shift_L" "keydown Control_L" "key plus" "keyup Control_L" "keyup Shift_L"
gesture: pinch in xte "keydown Control_L" "key minus" "keyup Control_L"
gesture: swipe up 4   dbus-send --session --type=method_call --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval string:'Main.overview.toggle();'
gesture: swipe down   4   xte "keydown Super_L" "key A" "keyup Super_L"

I also posted my config here - https://github.com/bulletmark/libinput-gestures/wiki/Custom-config-for-xte-instead-xdotool

Thank you very very much

OliverPerssonB commented 4 years ago

EDIT: I stumble onto this thread while having lag issues using Fusuma for multitouch gestures, so this may not be relevant to this thread. My problem was that as soon as I did zoom gestures, i.e pinch then all input would freeze for 2-5 seconds. My fix is described below for this

I have found that removing the "pinch" gesture fixes all the lagging problem for me.

This is sub optimal, but at least you get great speed on the other commands.

I am using Ubuntu 18.04, Gnome. Screenshot from 2020-06-13 13-08-48

ddnexus commented 4 years ago

I have no pinch gesture but that doesn't fix the problem.

vitor84 commented 3 years ago

The problem is that xdotool depends on the settings of X, so you have to select your default keyboard map to speed up the process you can run the following command:

setxkbmap -layout <keyboard of your choice>

or setup the default keyboard map like explained here: https://askubuntu.com/questions/968980/how-to-prevent-xkbmap-reset