Ulauncher: Hotkey doesn't work in Wayland when is triggered from certain apps

Created on 10 Dec 2017  Â·  28Comments  Â·  Source: Ulauncher/Ulauncher

For example, when I press Ctrl Space when in Ubuntu terminal, Ulauncher app won't show up.
However, the hotkey works fine when triggered from Firefox.

I think this has something to do with Ulauncher running in XWayland mode.

bug severity-high

Most helpful comment

@mickael83 thanks for the screencast. Looks like trick with sleep 5 works.

Let's try this, open sudo vi `which ulauncher-toggle` and insert sleep 0.05 before wmctrl line.
You can try different sleep number, but it has to be as close to 0 as possible.
That's obviously a workaround. I'm not sure what else I can do to help you fix this issue.

My guess is that Ulauncher can't process dbus-send event fast enough so wmctrl doesn't notice that window. Maybe you have limited CPU resources or something?

All 28 comments

I experience the same issue on a Fedora 27. Oddly I see the issue only on one of my machine, although I'm running the same setup.

I think this has something to do with Ulauncher running in XWayland mode.

Considering that Wayland can't do hotkeys, it makes sense. Ulauncher running in XWayland should be able to grab hotkey over any other XWayland window, but as soon as Wayland window is activated, compositor sends keyboard events only to that window.

Thanks for this insight @kozec
Now it makes sense for me.
I'm in progress of fixing this issue by allowing user to set Ulauncher hotkey from OS Keyboard Settings.

I'm stuck on another issue. I cannot figure out why GTK in Wayland doesn't move app window to specified coordinates. Ulauncher always appears close to left top corner

@kozec thanks for the hint. I have checked on the device that is working and for whatever reason this was using the X.org session instead of Wayland.

Okay, I think I put sufficient amount of time into this issue and still don't have a solution.

There is a workaround with assigning a hotkey from OS Settings > Hardware > Keyboard to run ulauncher command, but that adds a noticeable delay between hotkey is pressed and window is shown.

AFAIK, this is not a bug, but feature from Wayland side. You could do something crazy, like gnome extension that registers hotkey in compositor and sends you signal through d-bus, but nothing will work universally right now.

like gnome extension that registers hotkey in compositor and sends you signal through d-bus

hmm I didn't think of that. That should work.
Ulauncher already registers d-bus service and can accept method call to show itself.

gnome extension though... I don't really want to dig into that

Ulauncher already registers d-bus service and can accept method call to show itself.

Interesting, I was not aware of that.

Looking at code, registering hotkey in that Hardware > Keyboard thing that "launches"

dbus-send --session --print-reply --dest='net.launchpad.ulauncher' '/net/launchpad/ulauncher' "net.launchpad.ulauncher.show_window"

should work as well, and it will most likely be much faster than just starting ulauncher, as dbus-send binary is tiny.

Plus, it should work with KDE as well.

@kozec I followed your suggestion and added a new command that runs dbus-send

To all, please try dev release v4.0.5 and let me know if you have any issues.

See how to add a hotkey: https://github.com/Ulauncher/Ulauncher/wiki/Hotkey-In-Wayland

I am using Fedora 27 with wayland session, installed ULauncher v4.0.5.r1 and added the keyboard hotkey to run the command "ulauncher-toggle" like described here. It seems to work however when pressing the hot key above another app such as nautilus or google chrome, ulauncher does not gain focus which makes it unusable until I click on it.

Hmm, weird. It was working for me.
Could you send last 20 lines from journalctl -ex once you reproduce this
issue?

On Thu, Jan 25, 2018, 01:14 Michael Pinheiro notifications@github.com
wrote:

I am using Fedora 27, installed ULauncher v4.0.5.r1 and added the keyboard
hotkey to run the command "ulauncher-toggle" like described here
https://github.com/Ulauncher/Ulauncher/wiki/Hotkey-In-Wayland. It seems
to work however when pressing the hot key above another app such as
nautilus or google chrome, ulauncher does not gain focus which makes it
unusable until I click on it.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/Ulauncher/Ulauncher/issues/183#issuecomment-360306560,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABJZb602H4zpejfBR4beJ5tp9T-2DnjYks5tN7lmgaJpZM4Q8f9r
.

@mickael83, @gornostal I'm also running a Fedora 27 and it works like a charm.

My wild guess is that window still can't give itself focus in Wayland and @eremit is most still using X :)

@kozec actually I'm not - I have checked back prior to adding up my comment.

My wild guess is that window still can't give itself focus in Wayland

@kozec That's why you have to install wmctrl as outlined on the Wiki page

@mickael83 did you install it?

@gornostal Indeed, I installed wmctrl as you can see below:

$ sudo dnf list wmctrl
[sudo] password for mickael: 
Last metadata expiration check: 2:50:00 ago on Thu 25 Jan 2018 07:12:07 AM WET.
Installed Packages
wmctrl.x86_64                               1.07-22.fc27                               @fedora

And the logs after the issue:

Jan 25 10:07:36 bunker gnome-shell[4431]: Object Meta.WindowActor (0x55d9c42c7760), has been already finalized. Impossible to get any property from it.
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: == Stack trace for context 0x55d9bf78d000 ==
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #0 0x7ffc73b45fd0 b   resource:///org/gnome/shell/ui/tweener.js:73 (0x7f2fd02ddef0 @ 9)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #1 0x7ffc73b46070 b   resource:///org/gnome/shell/ui/tweener.js:105 (0x7f2fd02df230 @ 36)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #2 0x7ffc73b46110 b   resource:///org/gnome/shell/ui/tweener.js:92 (0x7f2fd02df098 @ 52)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #3 0x7ffc73b46190 I   resource:///org/gnome/gjs/modules/tweener/tweener.js:203 (0x7f2fd02e9cd0 @ 54)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #4 0x7ffc73b462e0 b   resource:///org/gnome/gjs/modules/tweener/tweener.js:332 (0x7f2fd02e9d58 @ 1626)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #5 0x7ffc73b46390 b   resource:///org/gnome/gjs/modules/tweener/tweener.js:345 (0x7f2fd02e9de0 @ 100)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #6 0x7ffc73b46420 b   resource:///org/gnome/gjs/modules/tweener/tweener.js:360 (0x7f2fd02e9e68 @ 10)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #7 0x7ffc73b464a0 I   resource:///org/gnome/gjs/modules/signals.js:126 (0x7f2fd02e2b38 @ 386)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #8 0x7ffc73b46550 b   resource:///org/gnome/shell/ui/tweener.js:208 (0x7f2fd02df808 @ 159)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #9 0x7ffc73b465b0 I   resource:///org/gnome/gjs/modules/_legacy.js:82 (0x7f2fd02c2bc0 @ 71)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #10 0x7ffc73b465b0 I   resource:///org/gnome/shell/ui/tweener.js:183 (0x7f2fd02df780 @ 20)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #11 0x7ffc73b46640 I   self-hosted:917 (0x7f2fd02ee5e8 @ 394)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: == Stack trace for context 0x55d9bf78d000 ==
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #0 0x7ffc73b45fd0 b   resource:///org/gnome/shell/ui/tweener.js:80 (0x7f2fd02ddef0 @ 82)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #1 0x7ffc73b46070 b   resource:///org/gnome/shell/ui/tweener.js:105 (0x7f2fd02df230 @ 36)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #2 0x7ffc73b46110 b   resource:///org/gnome/shell/ui/tweener.js:92 (0x7f2fd02df098 @ 52)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #3 0x7ffc73b46190 I   resource:///org/gnome/gjs/modules/tweener/tweener.js:203 (0x7f2fd02e9cd0 @ 54)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #4 0x7ffc73b462e0 b   resource:///org/gnome/gjs/modules/tweener/tweener.js:332 (0x7f2fd02e9d58 @ 1626)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #5 0x7ffc73b46390 b   resource:///org/gnome/gjs/modules/tweener/tweener.js:345 (0x7f2fd02e9de0 @ 100)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #6 0x7ffc73b46420 b   resource:///org/gnome/gjs/modules/tweener/tweener.js:360 (0x7f2fd02e9e68 @ 10)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #7 0x7ffc73b464a0 I   resource:///org/gnome/gjs/modules/signals.js:126 (0x7f2fd02e2b38 @ 386)
Jan 25 10:07:36 bunker gnome-shell[4431]: Object Meta.WindowActor (0x55d9c42c7760), has been already finalized. Impossible to set any property to it.
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #8 0x7ffc73b46550 b   resource:///org/gnome/shell/ui/tweener.js:208 (0x7f2fd02df808 @ 159)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #9 0x7ffc73b465b0 I   resource:///org/gnome/gjs/modules/_legacy.js:82 (0x7f2fd02c2bc0 @ 71)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #10 0x7ffc73b465b0 I   resource:///org/gnome/shell/ui/tweener.js:183 (0x7f2fd02df780 @ 20)
Jan 25 10:07:36 bunker org.gnome.Shell.desktop[4431]: #11 0x7ffc73b46640 I   self-hosted:917 (0x7f2fd02ee5e8 @ 394)

Nothing suspicious in the logs.

Try this:

  • start ulauncher
  • run sleep 5 && wmctrl -a "Ulauncher window title"
  • then press hotkey, and see if Ulauncher window will get focus in 5 seconds

@gornostal I made a short screencast to demonstrate the issue and what happens when running the commands you told me.

@mickael83 probably a stupid question, but did you stop the ulauncher instance after installing the new RPM?

@mickael83 thanks for the screencast. Looks like trick with sleep 5 works.

Let's try this, open sudo vi `which ulauncher-toggle` and insert sleep 0.05 before wmctrl line.
You can try different sleep number, but it has to be as close to 0 as possible.
That's obviously a workaround. I'm not sure what else I can do to help you fix this issue.

My guess is that Ulauncher can't process dbus-send event fast enough so wmctrl doesn't notice that window. Maybe you have limited CPU resources or something?

Thanks @gornostal.. Your workaround solved the issue. I inserted sleep 0.01 and it was enough to make it work.

Thanks again for your time!

@mickael83 cool :+1:

Is this issue common enough to warrant updating the default ulauncher-toggle to include sleep 0.01?

Just upgraded to the most recent release and had to search for the fix again...

I'm reopening this one. Will add the sleep into the next release.

I created a wrapper that used sleep 0.01, but it failed me a few times (very rare, but annoying). So I made it sleep 0.03, which has been working without fault, and still doesn't make a noticable difference for the experience.

Please, just make sure that you don't include that delay when normal environment is used.

@kozec It doesn't affect the time until Ulauncher starts, just the focus. You would have to type at a speed of 33 characters per seconds for the delay to affect you. I'm pretty sure no human or keyboard is capable of that.

I've forgotten that I had created #327 for this issue.
Let's move the conversation there

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jbriales picture jbriales  Â·  6Comments

jonhoo picture jonhoo  Â·  3Comments

andersfylling picture andersfylling  Â·  5Comments

Warmuser picture Warmuser  Â·  3Comments

BartWillems picture BartWillems  Â·  6Comments