hyprwm / xdg-desktop-portal-hyprland

xdg-desktop-portal backend for Hyprland
BSD 3-Clause "New" or "Revised" License
273 stars 47 forks source link

Are Global Shortcuts functioning? #56

Closed gdiShun closed 1 year ago

gdiShun commented 1 year ago

I'll preface this by saying I am a newb to dbus in general, and honestly don't know what I'm doing. lol. So this is may be more a question than a real 'bug report'.

So the problem I'm having is that while CreateSession seems to work no problem, BindShortcuts and ListShortcuts does not appear to. The Response signal I get is only 2 {} when trying to use either.

This is the error in journalctl that I see most of the time when trying to BindShortcuts: xdg-desktop-por[48879]: A backend call failed: No such device or address And when trying to ListShortcuts: xdg-desktop-por[51137]: A backend call failed: Unknown method ListShortcuts or interface org.freedesktop.impl.portal.GlobalShortcuts.

And here's the log of xdg-desktop-portal-hyprland during a session:

2023/05/03 13:03:33 [INFO] - dbus: create session method invoked
2023/05/03 13:03:33 [INFO] - dbus: request_handle: /org/freedesktop/portal/desktop/request/1_647/pyscreenshot
2023/05/03 13:03:33 [INFO] - dbus: session_handle: /org/freedesktop/portal/desktop/session/1_647/pyscreenshot
2023/05/03 13:03:33 [INFO] - dbus: app_id: 
2023/05/03 13:03:33 [WARN] - dbus: unknown option: handle_token
2023/05/03 13:03:33 [INFO] - dbus: option token: pyscreenshot
2023/05/03 13:03:33 [INFO] - dbus: list shortcuts invoked
2023/05/03 13:03:33 [INFO] - dbus: request_handle: /org/freedesktop/portal/desktop/request/1_647/pyscreenshot
2023/05/03 13:03:33 [INFO] - dbus: session_handle: /org/freedesktop/portal/desktop/session/1_647/pyscreenshot
2023/05/03 13:03:35 [INFO] - dbus: session closed
2023/05/03 13:03:35 [DEBUG] - dbus: destroying session 0x55b0d232c980

Occasionally, a ListShortcuts will 'slip through' and work. It will show the new shortcut bound, despite the No such device or address error. However, it does not show up in hyprctl globalshortcuts at all.

Very much would believe there's some user-error on my part. So this very much could be less a bug report, more an I'm an idiot report.

vaxerski commented 1 year ago

So, the thing with xdp, is that unlike wayland-protocols, where the protocol is well documented and its improper use will just make your app not work at all, is that xdp has a spec (which you seem to be using) but NOBODY FUCKING FOLLOWS IT

my test client was mumble's GS PR and I assume that's how people are gonna use it.

No fucking portal in xdp is used how the fucking spec declares it. Even better, the spec fucking changes randomly every 2 months.

Another thing I was coding support for was the "restore token" for screensharing. There is a spec for that. Nobody fucking uses it. Everyone uses a seemingly undocumented method.

That's why, to me, the spec makes no fucking sense and I have no idea how it even should work. I recommend just taking a look at how it's read in xdph, xdpk (kde) or the mumble pr and just going with that.

It's an absolute shitfest, but I can't do much about it.

gdiShun commented 1 year ago

Okay, so, just for confirmation. It looks like instead of using BindShortcuts, you just send the shortcuts in through the CreateSession options?

So instead of it looking something like this(in python w/ jeepney):

options = { 'session_handle_token': ('s', token) 
            'handle_token': ('s', token) }

It'll look like this:

options = { 'handle_token': ('s', token),
            'shortcuts': ('a(sa{sv})', [( 
                        'deez', {
                        'id': ('s', 'nah'),
                        'app_id': ('s', token),
                        'description': ('s','Nothing'),
                        'trigger_description': ('s','SHIFT+a') } )] ) }

This at least works to get it to show up properly in hyprctl globalshortcuts. I haven't tested beyond that, and probably won't for at least a few days. I want to get back to what I was doing before I fell down this rabbit hole. lol

vaxerski commented 1 year ago

yeah, that's how it works atm.