iberianpig / fusuma-plugin-sendkey

Fusuma plugin that sending virtual keyboard events
MIT License
72 stars 2 forks source link

Key combinations sometimes do not work in Ubuntu 21.04 #23

Closed drnguyenn closed 3 years ago

drnguyenn commented 3 years ago

Hi. I have successfully installed fusuma along with fusuma-plugin-sendkey on my Ubuntu 21.04 by following the instruction in the documentation. They work pretty well on some applications, however, when I tried with the Terminal, the key combinations seem not to work. I have tried executing this command in my Terminal

$ fusuma-sendkey 'LEFTCTRL+T'

and was expecting that a new tab was opened, but I only received the letter t printed out:

$ t

Can you please tell me what should I do to work around this? Thanks a lot.

PS: I have configured the Terminal's shortcuts like this so I can open a new tab with Ctrl+T, not Ctrl+Shift+T as default. image

iberianpig commented 3 years ago

PS: I have configured the Terminal's shortcuts like this so I can open a new tab with Ctrl+T, not Ctrl+Shift+T as default.

OK :+1:

For now, it works fine in my Ubuntu 20.04 X11 environment. Let's try to isolate the cause.

  1. Please paste the output of fusuma --version.
  2. Is the problem only with the CTRL key combination? Or does it also occur with other modifier keys?
    • Try fusuma-sendkey LEFTSHIFT+T to see if it prints a capital T.
  3. Does it happen in other applications than Gnome-terminal?
    • Can you open a tab with fusuma-sendkey LEFTCTRL+T in Google Chrome or Firefox?
drnguyenn commented 3 years ago

1.

Please paste the output of fusuma --version.

I, [2021-08-15T08:34:08.946644 #31386]  INFO -- : reload config: /home/long/.config/fusuma/config.yml
I, [2021-08-15T08:34:09.027505 #31386]  INFO -- : ---------------------------------------------
I, [2021-08-15T08:34:09.027913 #31386]  INFO -- : Fusuma: 2.0.5
I, [2021-08-15T08:34:09.029937 #31386]  INFO -- : libinput: 1.16.4
I, [2021-08-15T08:34:09.029979 #31386]  INFO -- : ruby 2.7.2p137
I, [2021-08-15T08:34:09.030580 #31386]  INFO -- : OS: Linux 5.11.0-25-generic #27-Ubuntu SMP Fri Jul 9 23:06:29 UTC 2021
I, [2021-08-15T08:34:09.031182 #31386]  INFO -- : Distribution: Ubuntu 21.04 \n \l
I, [2021-08-15T08:34:09.031724 #31386]  INFO -- : Desktop session: ubuntu wayland
I, [2021-08-15T08:34:09.031747 #31386]  INFO -- : ---------------------------------------------
I, [2021-08-15T08:34:09.031757 #31386]  INFO -- : Enabled Plugins: 
I, [2021-08-15T08:34:09.031810 #31386]  INFO -- :   Fusuma::Plugin::Buffers::GestureBuffer
I, [2021-08-15T08:34:09.031821 #31386]  INFO -- :   Fusuma::Plugin::Buffers::TimerBuffer
I, [2021-08-15T08:34:09.031828 #31386]  INFO -- :   Fusuma::Plugin::Detectors::PinchDetector
I, [2021-08-15T08:34:09.031835 #31386]  INFO -- :   Fusuma::Plugin::Detectors::RotateDetector
I, [2021-08-15T08:34:09.031842 #31386]  INFO -- :   Fusuma::Plugin::Detectors::SwipeDetector
I, [2021-08-15T08:34:09.031849 #31386]  INFO -- :   Fusuma::Plugin::Events::Records::ContextRecord
I, [2021-08-15T08:34:09.031856 #31386]  INFO -- :   Fusuma::Plugin::Events::Records::GestureRecord
I, [2021-08-15T08:34:09.031862 #31386]  INFO -- :   Fusuma::Plugin::Events::Records::IndexRecord
I, [2021-08-15T08:34:09.031875 #31386]  INFO -- :   Fusuma::Plugin::Events::Records::TextRecord
I, [2021-08-15T08:34:09.031887 #31386]  INFO -- :   Fusuma::Plugin::Executors::CommandExecutor
I, [2021-08-15T08:34:09.031898 #31386]  INFO -- :   Fusuma::Plugin::Executors::SendkeyExecutor
I, [2021-08-15T08:34:09.031908 #31386]  INFO -- :   Fusuma::Plugin::Filters::LibinputDeviceFilter
I, [2021-08-15T08:34:09.031916 #31386]  INFO -- :   Fusuma::Plugin::Filters::LibinputTimeoutFilter
I, [2021-08-15T08:34:09.031924 #31386]  INFO -- :   Fusuma::Plugin::Inputs::LibinputCommandInput
I, [2021-08-15T08:34:09.031931 #31386]  INFO -- :   Fusuma::Plugin::Inputs::TimerInput
I, [2021-08-15T08:34:09.031942 #31386]  INFO -- :   Fusuma::Plugin::Parsers::LibinputGestureParser
I, [2021-08-15T08:34:09.031953 #31386]  INFO -- : ---------------------------------------------

Is the problem only with the CTRL key combination? Or does it also occur with other modifier keys?

It seems to happen with other key combinations, too.

Try fusuma-sendkey LEFTSHIFT+T to see if it prints a capital T.

It does not print a capital T at all, just a normal t.

Does it happen in other applications than Gnome-terminal?

Yes, it does, for instance, in Gedit. I tried to open a new tab in Gedit by swiping 3 fingers up but only a letter t appears in the current tab.

Can you open a tab with fusuma-sendkey LEFTCTRL+T in Google Chrome or Firefox

Yes, it does work seamlessly with my browsers.

For now, it works fine in my Ubuntu 20.04 X11 environment.

By the way, I think one of the causes is here. As mentioned in the title, I am using Ubuntu 21.04, and as far as I know, Ubuntu 21.04 uses Wayland as the default display server instead of X11. Though fusuma-plugin-sendkey is an alternative to xdotool available for X11 and Wayland as written in the documentation, I think there must be something that we are missing to make it work properly with Wayland. And finally, I have just discovered one thing that seems helpful. fusuma-plugin-sendkey seems to work in my gnome-terminal when I tried to not focus on the text editor. For example, while I kept the menu of the terminal opened (just to make the text pointer not focused on the console) as shown in the figure below and then swiped 3 fingers up, a new tab is actually opened as expected. A similar thing also occurs when I tried with Gedit. I think there must be some differences between the text processing module of X11 and Wayland. image

BirsanStefan commented 3 years ago

Any new development on this issue? It behaves the same for me on 21.10.

Also I noticed that "fusuma-appmatcher -l" does not detect gnome-terminal running. And it ignores the "context: application: gnome-terminal" and applies default.

Maybe on wayland native apps (is there such a thing?) it only types. It behaves weirdly on Sublime text, on Gedit, on Firefox (partially: in new tab firefox, ctrl+w does not close the tab, but writes instead.)

drnguyenn commented 3 years ago

I had to switch back to X11 in order to make fusuma work as expected. Can't figure out any other solution yet.

BirsanStefan commented 3 years ago

It can be helped then. No gestures in terminal. Gnome 40 has really nice native 1:1 gestures tough so I will use fusuma only in browser with three fingers. Nice work for the author.

iberianpig commented 3 years ago

In Ubuntu 20.04 Wayland session, it works fusuma-appmatcher and fusuma-plugin-sendkey on gnome-terminal.

---
context:
  application:  gnome-terminal-server

swipe:
  3:
    up:
      sendkey: 'LEFTSHIFT+LEFTCTRL+T'
    down:
      sendkey: 'LEFTSHIFT+LEFTCTRL+W'
iberianpig@iberianpig-XPS-13-9310:~/fusuma_dev$ fusuma-appmatcher
gnome-terminal-server
iberianpig@iberianpig-XPS-13-9310:~/fusuma_dev$ fusuma --version
I, [2021-10-29T00:26:06.211253 #12101]  INFO -- : reload config: /home/iberianpig/.config/fusuma/config.yml
I, [2021-10-29T00:26:06.329109 #12101]  INFO -- : ---------------------------------------------
I, [2021-10-29T00:26:06.329419 #12101]  INFO -- : Fusuma: 2.1.0
I, [2021-10-29T00:26:06.330489 #12101]  INFO -- : libinput: 1.19.0
I, [2021-10-29T00:26:06.330509 #12101]  INFO -- : ruby 3.0.1p64
I, [2021-10-29T00:26:06.331099 #12101]  INFO -- : OS: Linux 5.10.0-1050-oem #52-Ubuntu SMP Wed Oct 6 12:58:49 UTC 2021
I, [2021-10-29T00:26:06.331633 #12101]  INFO -- : Distribution: Ubuntu 20.04.3 LTS \n \l
I, [2021-10-29T00:26:06.332185 #12101]  INFO -- : Desktop session: ubuntu-wayland wayland
I, [2021-10-29T00:26:06.332198 #12101]  INFO -- : ---------------------------------------------
I, [2021-10-29T00:26:06.332212 #12101]  INFO -- : Enabled Plugins:
I, [2021-10-29T00:26:06.332289 #12101]  INFO -- :   Fusuma::Plugin::Buffers::AppmatcherBuffer
iberianpig@iberianpig-XPS-13-9310:~/fusuma_dev$ gnome-shell --version
GNOME Shell 3.36.9
BirsanStefan commented 3 years ago

Here is what happens on my machine screenshot

I see you're using dell xps. Nice! Do you have issues with fan noise firing too often?

iberianpig commented 3 years ago

Could you paste the output of the following dbus script?

gdbus call -e -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval "const actor = global.get_window_actors().find(a=>a.meta_window.has_focus()===true); actor && actor.get_meta_window().get_wm_class();
# My result on Ubuntu 20.04 Wayland with GNOME Shell 3.36.9

iberianpig@iberianpig-XPS-13-9310:~/fusuma_dev$ gdbus call -e -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval "const actor = global.get_window_actors().find(a=>a.meta_window.has_focus()===true); actor && actor.get_meta_window().get_wm_class();"
(true, '"gnome-terminal-server"')
iberianpig commented 3 years ago

I see you're using dell xps. Nice! Do you have issues with fan noise firing too often?

No, I don't have fan noise issue on XPS 13 9310. When I used XPS 13 9360 before, there was a little coil noise.

BirsanStefan commented 3 years ago
# It seems to return nothing
stefan@stefan-xps-13-9300:~$ gdbus call -e -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval "const actor = global.get_window_actors().find(a=>a.meta_window.has_focus()===true); actor && actor.get_meta_window().get_wm_class();
> 
iberianpig commented 3 years ago

I reproduced these issues on Ubuntu 21.10 using Gnome Boxes.

Image from Gyazo

  1. fusuma-sendkey doesn't work on Gnome Terminal 3.38.1(but works fine on Firefox and Nautilus
  2. fusuma-appmatcher doesn't work on Gnome Shell 40.05
BirsanStefan commented 3 years ago

Indeed, fusuma-sendkey works fine in browsers, which is actually 99% of usecases, so I'm fine with it. Feel free to solve these issues when you'll have the time.

One thing I noticed is that when there is an active window with a focused text input(a place where you can write), sometimes, fusuma-sendkey results in writing those letters instead of applying the action that is bound to the shortcut.

For example when the focus is active on Firefox address bar, LEFTCTRL+T will write a "t" instead of applying the action of opening a new tab. It will do it properly though when the address bar does not have an active focus. The same behaviour I suspect happens in Sublime Text, Gedit, and perhaps on the Gnome Terminal.

Maybe these apps are more integrated into Wayland way of doing things. I suspect that because xdotool works on browsers even in Wayland. But not on Nautilus.

Anyway, hopefully these observations may be of help for you.

iberianpig commented 3 years ago

@BirsanStefan Thank you. Your insights will help us! BTW, I fixed fusuma-plugin-appmatcher. It works on GNOME Shell 40.5(Ubuntu 21.10 Wayland).