Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global keyboard shortcut portal #624

Closed
cassidyjames opened this issue Sep 5, 2021 · 71 comments · Fixed by #711
Closed

Global keyboard shortcut portal #624

cassidyjames opened this issue Sep 5, 2021 · 71 comments · Fixed by #711
Labels
new portals This requires creating a new portal interface

Comments

@cassidyjames
Copy link
Contributor

We have received several requests from elementary AppCenter app developers for a way to set (or prompt a user to set) a global keyboard shortcut to launch their app or a specific feature of their app (e.g. an Application action).

Pre-sandbox, these developers would set the GSettings for the desktop itself to add their app to the global keyboard shortcuts. Obviously this is non-ideal and only reasonably worked because we human reviewed every app’s source upon submission and update.

Today in Flatpaks, we recommend developers direct users to System Settings > Keyboard > Shortcuts and tell users how to add a custom shortcut manually.

Ideally, however, apps could use a Portal to request a system-wide shortcut (along with a description/rationale of the feature), and then we could provide a UI to display the request, let the user pick a shortcut, avoid conflicts, etc.

@vchernin
Copy link

vchernin commented Sep 12, 2021

This also sounds like something particularly useful on Wayland, since apps can't arbitrarily access keyboard input whenever they want (no keyboard event polling). So traditional app-provided global shortcuts won't work on Wayland. On Wayland you'd need the Compositor to "capture" global shortcut usage on behalf of the app, but today that isn't very easy or accesible to manage.

Having a standard way of asking the host system/compositor to provide a global shortcut for the app sounds like a very clean solution.

@matthiasclasen
Copy link
Contributor

An api proposal (or even better: an implementation) would be appreciated.

@k3d3
Copy link

k3d3 commented Oct 1, 2021

This would definitely be necessary for things that have core functionality in global hotkeys, for example Mumble or Discord with push-to-talk.

Is the xdg-desktop-portal project open to API proposals for this, and/or somewhere to discuss and flesh out what an API would look like?

@TingPing TingPing added the new portals This requires creating a new portal interface label Oct 26, 2021
@rohmishra
Copy link

rohmishra commented Dec 6, 2021

I can write a rough draft of portal API proposal for this feature if anyone is interested, I do have a few (optional) features that I wanted to include:

  1. Common/generic shortcuts (eg. Push-to-Talk, a list of common shortcuts that are shared between apps. The first app to engage the shortcut gets to use it, Eg. if you are using a communication app, the app requests access to PTT and whichever key you have defined as PTT is used transparently. others can request a temporary shortcut for single use case, see. 3)
  2. Ability for the app to get the keyboard shortcut you decided to use. (useful if app wants to display the shortcuts in the settings menu.)
  3. Temporary shortcuts (are cleared when you exit the app. Useful for features users dont use much or are known to be rarely used or when primary key (if a common key) is used by a different app)

Let me know if anyone is would be interested in these optional features. If so, I can include them in the draft as well.

@cassidyjames
Copy link
Contributor Author

@rohmishra in my mind when proposing this idea, I was really thinking of limiting the scope to launching apps and FreeDesktop Actions, which as far as I know would cover most if not all of the uses by elementary AppCenter apps.

I feel like PTT is different in that it assumes the app is running and able to intercept/handle a specific key internally; are there other examples of these generic shortcuts? But off the top of my head I am not sure this is a good fit without inventing yet another standard of types of keyboard shortcuts. I don't feel strongly, I just fail to see the other potential uses and am not entirely convinced it's a good fit.

I think 2 makes sense and would be really convenient for in-app education!

I'm not sure I understand the use of 3.

@rohmishra
Copy link

rohmishra commented Dec 6, 2021

For one, push to talk and apps that display an overlay/menu when you press and hold apps are the only two use cases I can think of right now. I did have a different one in mind a few days ago but I failed to write it down 😅 so it's lost to history I guess.

That said, I do have a different use case in mind that I glossed over previously - for PTT the app needs to know if the keys are currently pressed or not. Do we want to support that use case? I feel like with the ubiquity of video conferencing these days, there might be a lot of request to support this regardless. In that case, Do we want that to be a seperate API?

As for the third one, the shortcuts are automatically cleared when you sign out (or quit the app, not really sure which one would be better). PTT actions are probably a good example of its use case. But a UI that dynamically changes a lot might wanna use this too. I personally don't care either way but just thought this might be something someone might be looking for. It was a valid feature to impliment on x after all.

Except for the PTT/overlay case, I do think most use cases can be solved by the current shortcut system of just executing a command with a flag/dbus-send to let the app know of an action. It would certainly be easier as except for a portal to trigger the add shortcut UI automatically and pre-filling the command, we already have everything else in place.

I'm on mobile right now, but GSConnect can trigger the action in its own UI, so unless it uses a weird hack, gnome already has most of the stuff in place.

Without 1 & 3, I have a simple structure in mind:

We store an invisible to user token for each app that has requested a global shortcut. The app can use that to request current key-binding, or clear it. We may also (optionally) consider passing it back to the app in argv/dbus so that if the app allows users to have some custom action on keypress (eg run a series of user defined actions or enter a custom text) it can simply identify against the unique token/UUID.

@jadahl
Copy link
Collaborator

jadahl commented Dec 6, 2021

PTT seems to me like one of the more common requests when it comes to global key bindings, and I imagine it cannot rely on executables or .desktop action entries since one would need both a start and a stop signal.

Would also be nice te know what actions exactly tends to be bound to global keys in Elementary Apps too to better understand what they are actually trying to solve.

As for storage in the permission store, I think it'd be good to take inspiration from the screen cast session storage method here; it solved a very similar issue; e.g. letting the portal backend provide the actual stored content, while using a x-d-p provided token to make it possible to restore.

@1player
Copy link

1player commented Dec 6, 2021

I have a use case for options 2 and 3. I am working on an application to calibrate mouse sensitivity between games. Without entering into technical details, you'd start the app, enter calibration mode, tab over to the video game and press a hotkey to start recording the mouse input and another hotkey to stop.

So my application would need a way to configuring a few global shortcuts that are active as long as it is running, and I'd like to make those hotkeys configurable by the user.

Since the app requires raw access to /dev/input/event*, I can already simulate some kind of global shortcut system, but I would prefer to use the actual portal, if there's one available.

@rohmishra
Copy link

rohmishra commented Dec 6, 2021

@jadahl PTT would require sending key-up and key-down flags as distinct signals which isn't something other apps wanna deal with and something we want to avoid sharing unless absolutely necessary.

And yes I was thinking of similar structure as screencast API. I was about to sleep while writing the previous comment and it shows.

@1player the plan is that apps won't be able to force a keyboard shortcut, rather the user gets to choose them. I'm thinking of allowing apps to suggest keybindings to be helpful but those still won't be binding on the user. That's why i want to include a way to read binding so that apps can dynamically update their documentation and help pages to reflect the right shortcuts.

Also we might actually want to explore hiding /dev/input behind a portal cause otherwise it defeats the purpose of apps can read keyboard anyways by adding a single line to their manifest. Permissions granted by the manifest are automatically granted when running the app and users shouldn't be expected to review them for every app.

@jadahl
Copy link
Collaborator

jadahl commented Dec 6, 2021

@jadahl PTT would require sending key-up and key-down flags as distinct signals which isn't something other apps wanna deal with and something we want to avoid sharing unless absolutely necessary.

True, but done right, they (the ones not caring about start/stop) could just ignore all but the start signal for example.

@rohmishra
Copy link

It would result in inconsistent behavior. Some apps react to key-up, others do to key-down. It is also a more complex API that would require more time to implement. You loose the ability for shortcuts to work even when the app isn't running yet (something other platforms don't really do and would result in a better experience if we can land that! We don't want users to have to check if the app is running yet or not.)

Having PTT tied to session only bindings may be a good idea too. The app can request key-binding the first time you enter a call for the day. Paired with suggested bindings it should be a one extra click/enter-key once a day/restart affair for most people. That said, people are not going to like it. But I don't think all bindings receiving key-down and key-up is a good idea.

@jadahl
Copy link
Collaborator

jadahl commented Dec 6, 2021

An alternative is for applications to ask for what type of event to receive, i.e. start/stop/cancel vs triggered. Anything that doesn't actually want the former would just receive the latter.

What makes PTT special in that it shouldn't be able to be saved more persistently?

@k3d3
Copy link

k3d3 commented Dec 6, 2021

I like your ideas @rohmishra , however I'd like to make one comment on this:

The first app to engage the shortcut gets to use it

I believe it should be possible for apps to simultaneously register the same keyboard shortcut. For example, I use both Mumble and Discord - I never use the voice capabilities of each at the same time, however I don't want to have to register different PTT shortcuts for each.

If I were a bit more insane and had friends scattered across Mumble, Discord, Ventrilo, Teamspeak, and Teams servers (granted I have no idea if Teams even does PTT), it would become very annoying very quickly to have to remember each one's individual PTT key depending on which app I'm using. Having 5 different push-to-talk keys could get unwieldy quickly.

Also, one comment on the idea of "temporary global shortcuts" - I like the idea of having them be unregistered after an app exits, however does this mean you will be prompted for the keyboard shortcut every time the app is opened? That could get annoying very quickly and might discourage people from using that functionality.

What if instead, you required that the prompt said something like "Application X would like to register key Y as a global shortcut", and then you could answer it with

  • Allow once
  • Allow forever
  • Deny

or something like that? I think that would solve the use cases for temporary shortcuts.

(As a bonus, it would be interesting to allow the user to change "key Y" from the prompt to something different, but not really necessary for an initial design.)

@k3d3
Copy link

k3d3 commented Dec 6, 2021

The only thing I'm not sure about is how annoying a prompt like that would be if an app wants to register several shortcuts. As a bad example, a screenshot tool that registers one key for fullscreen, one key for current window, and one key for selecting a rectangle. If a user only wants those shortcuts registered temporarily, they'd have to answer three prompts every time they open the program.

One solution to this would be to allow an app to register multiple shortcuts with a single prompt, but that gets rid of the option to allow some shortcuts but not others (at least, not without making the prompt quite a bit more complicated). I'm not a big fan of this, but I'm not wholly against it either - an app registering multiple shortcuts might be enough of an edge case that it's not worth going this route.

Any thoughts?

@rohmishra
Copy link

rohmishra commented Dec 6, 2021

@k3d3 that's the idea. All apps request access to "common-PTT-key" or something like that, and the first app that actually uses it gets to use it in call while others can request a temporary alternative. So for example if you are on a discord call and your PTT combo is ctrl+space, discord PaTT will be triggered by that, but if you open teams for a call WHILE on a call in discord, it will ask you for a temporary alternative.

Also, that is the idea behind temporary shortcuts. User will always be in control. The app can just ask for the shortcut to be temporarily assigned, or the use can force it on the assignment screen.

Temporary shortcuts are intended for apps that you know you don't use often or as discussed above, for apps that are meant to be used once/rarely so you don't want to pollute your shortcuts with them. They are optional.

Allow once doesn't really make sense so it's better to just skip that to minimise complexity.

And yes, the user gets to decide the key shortcut as mentioned above. Apps can purely just SUGGEST shortcuts to simplify the flow, not enforce them.

@k3d3
Copy link

k3d3 commented Dec 6, 2021

And yes, the user gets to decide the key shortcut as mentioned above. Apps can purely just SUGGEST shortcuts to simplify the flow, not enforce them.

Agreed - so long as the UX isn't too complex, that works. User choice is better.

Allow once doesn't really make sense so it's better to just skip that to minimise complexity.

What about it doesn't make sense? I feel like it would keep the API much simpler for an app to just say "register a key, preferably key X" and that's it, then let the user decide if that shortcut should be allowed forever (permanently) or once (temporarily) - the naming could certainly change if the terminology is what's bothering you. I think it's better for the user to decide if an app is commonly or uncommonly used, rather than the app developer having to guess.

So for example if you are on a discord call and your PTT combo is ctrl+space, discord PaTT will be triggered by that, but if you open teams for a call WHILE on a call in discord, it will ask you for a temporary alternative.

I have mixed opinions about this. While I do understand what you're getting at, this ends up being a bit of the same problem where now I have to remember multiple PTT keys. That said, I kinda like the idea of having a warning prompt when a keyboard shortcut is already in use.

What if, instead of only asking for a temporary alternative, it asked for a temporary alternative but also gave the option to use the same key?

@swick
Copy link
Contributor

swick commented Dec 6, 2021

My two cents: the request for global shortcuts should be as descriptive as possible making different solutions for the backend possible.

One request should be a list of all shortcuts the application wants to set, each shortcut consists of:

  • internal identifier
  • human readable description
  • type of event (start/stop/cancel vs triggered vs dbus activation)
  • binding suggestions (keyboard, touch gestures, … whatever we will need eventually)

That allows a backend to implement a UI where it's possible to:

  • bind or not bind each shortcut for one application
  • choose what action to bind to the shortcut
  • prevent the user from binding a shortcut to an action which is already used by the shell
  • show the other apps which are using the same action

For persistence we can reuse the screen cast session storage method like @jadahl suggested. If an action is bound to multiple shortcuts they all get triggered. This should be sufficient for all the use cases listed in this thread and give the user enough control.

e: a note about event types: dbus activation is the only type which can be triggered while the application is not running (but also when running).

@k3d3
Copy link

k3d3 commented Dec 6, 2021

@swick completely agreed, I think. I'm just curious what you mean by "type of event" - is this something that would be shown to and selected by the user, or just handled by an app via the desktop-portal API?

I'm not sure if that's all that important to show to a user (so long as it shows which key, just not necessarily if it's start/stop or just triggered), though I may be misunderstanding what you mean there. Also if an app expects a start/stop PTT-style binding and a user chooses triggered, that might break things.

Also since this is xdg-desktop-portal, wouldn't everything behind the scenes be handled by dbus?

Other than that, yeah, I like that a lot!

@swick
Copy link
Contributor

swick commented Dec 6, 2021

The type of event is an implementation detail that cannot be overwritten by the user. It can influence what action can be bound to it. For example a PTT can not be bound to a touch gesture.

Also since this is xdg-desktop-portal, wouldn't everything behind the scenes be handled by dbus?

Yes. I think you're confused because of the dbus activation type? The dbus activation mechanism allows shortcuts to be activated even if the application is not running (https://specifications.freedesktop.org/desktop-entry-spec/1.1/ar01s07.html).

@k3d3
Copy link

k3d3 commented Dec 6, 2021

Okay, thanks for the clarification. I completely understand and fully agree now. :)

@swick
Copy link
Contributor

swick commented Dec 6, 2021

One more thought: we might not even need a session storage mechanism if we send the events to a well-known dbus service just like with dbus activation. The portal would then basically only be responsible for configuring the shortcuts.

@cassidyjames
Copy link
Contributor Author

I think I'll stay out of the PTT discussion as that's just not the problem I was looking to solve (and not one I've put much thought into), but I trust you all to come to a solution. :)

Would also be nice te know what actions exactly tends to be bound to global keys in Elementary Apps too to better understand what they are actually trying to solve.

Sure! The two types of shortcuts that were in use pre-Flatpak that have been requested when an app is not in the foreground are just simply launching the app, and launching a specific mode of the app. The latter could be handled e.g. by passing a CLI flag, but for user presentation reasons, I think it makes sense to lean on the existing FreeDesktop additional application actions as these are in use today across FreeDesktop apps and desktops, and give us built-in niceties like translatable human-readable names for features, icons, and the actual command to be executed. It would mean not duplicating these actions across multiple places and encourage their continued use for desktop interoperability.

Specific examples

These two apps exemplify the two categories of requests we're getting from developers:

Clips

Clips screenshot

Clips is a rich graphical clipboard manager; it launches with a view of your recently copied items to help you recall and paste them. Since this is the whole function of the app, opening it from your applications launcher, dock, etc. always launches into this view, so they are just requesting a more streamlined way to configure a desktop-wide shortcut that would launch their app.

Currently, they use in-app messaging and a settings:// link on elementary OS to point the user in the right direction of configuring desktop keyboard shortcuts, but it requires more manual work from the user and is not cross-desktop friendly.

Planner

Planner is a to-do planner with a very full-featured UI, but it has a "quick add" feature intended to be launched from anywhere in your OS when an idea strikes you:

rtmrbs59xvi41

It is currently implemented by manually writing a custom command to the custom keyboard shortcut GSettings which does not work reliably across desktops and in a Flatpak (besides requiring a big Flatpak sandbox hole). It could be implemented as a .desktop action to be accessible from the app launcher in addition to this system-wide keyboard shortcut.

@jadahl
Copy link
Collaborator

jadahl commented Dec 7, 2021

Thanks a lot @cassidyjames, that's really useful information!

@rohmishra
Copy link

I think PTT/hold-for-action is something that might need further exploration. It is certainly a feature that we would want to have even if it is just for two use cases, one of which is rather niche.

For now we should just focus on just automating the existing global shortcuts methods that we have - allowing apps to request shortcut and set the command for execution. PTT is something that can be added in later probably.

For now call apps can work around this limitation by allowing a command to both enable and disable (toggle) mic. Not the most elegant solution but it is workable

Here is something we might want / what I have in mind:

  • registerShortcut(cb, suggestedKey) - returns token if key is set or 'null'. cb: command to execute (or dbus-send action).
  • getShortcutKey(token) - returns the assigned key combination to display in-app
  • unregisterShortcut(token) - returns boolean true or false to describe if action was successful.

We also might want to check and maybe limit what command or dbus the app is calling and limit it to itself or warn users if it is trying to set the shortcut to something else.

@slagiewka
Copy link

I see that this discussion is revolving around keyboard shortcuts. I've come across it while trying to see what can be used for projects that want to send key presses. An example is keepassxreboot/keepassxc#2281. Would this be connected or such functionality would require another API?

@swick
Copy link
Contributor

swick commented Dec 8, 2021

The issue you linked to should be solved with something similar to androids autofill feature. For emulating input libei is what you want to look at.

@aleixpol
Copy link
Contributor

We Plasma have also been looking into this problem and we mostly ran into very similar conclusions as the conversation in here before we reached this thread.

We need:

  • desktop-entry-spec keyboard-activatable actions
  • Push-To-Talk

The as you've all mentioned repeatedly, Push-To-Talk can't easily be addressed within the former point as we'd need handling the release.

Something we discussed too was the possibility of tackling Push-To-Talk using a dbus service like we do for MPRIS where applications get to implement an interface stating their information and expectations and another process (the compositor in this case, presumably) would handle the logic.

If you think that addressing either is something you are interested in, we can provide a proposal to discuss.

@jadahl
Copy link
Collaborator

jadahl commented Jan 18, 2022

Leaving out Push-To-Talk out of the keyboard shortcuts is perhaps the best idea; it'll make the keyboard-release issue less urgent, if needed at all, and with a more aware (about Push-To-Talk) interface, the system providing it can be more clever and e.g. force-mute the microphone when the button/key isn't pushed.

If separate, it should probably still be a portal, and not its own separate interface, so that it can more easily integrate with the permission store, have a libportal API etc.

@ssokolow
Copy link

ssokolow commented Feb 20, 2022

...not to mention that it'd be really nice if the API could be integrated into this unified control panel KDE has had for applications using KDE's own keybinding APIs since at least the early 2000s when I started using it.

Screenshot_20220220_040540

(One example of exactly the UX concern @rohmishra brought up is that, if you enter a keybinding in that dialog and it's already taken, it'll offer to reassign it from whatever else has it, across all applications using kglobalaccel to handle their global keybindings.)

Sure, there's the hazard that you want two things to have the same global hotkey because you never intend to run them at the same time, but then kglobalaccel is still the perfect place to handle that on a KDE desktop, because KDE is no stranger to user-configurable precedence lists. For example, with its handling of filetype associations, which is basically the same now as back in the early 2000s but now a GUI version of the ;-delimited lists that mimeapps files allow. A lot of KDE design decisions just got standardized through Freedesktop.org.)

...and that's another concern. Making sure that applications that expect the desktop to take responsibility for that don't become less functional when run sandboxed.

@aleixpol
Copy link
Contributor

I'm not sure where this is coming from. I've included a user-readable description so it can be listed in the system's UI as desired. It's the implementation (i.e. the DE's) who do the shortcut creation, so they remain in control.

Please make sure you understand the problem before adding a random rant.

@ssokolow
Copy link

ssokolow commented Feb 21, 2022

  1. Please don't call it a rant. None of the relevant emotions were present when I was writing it and, more generally, calling something a rant tends to cause the discourse to degrade by coming across as dismissive of the other party's concerns.

  2. I was responding to your "The parts I'm least convinced of are:" points by providing details that are important to take into consideration if applications and libraries from KDE are expected to implement support for the new portal. (As opposed to potentially continuing depend on proprietary KDE APIs to avoid regressing features their users have come to expect.)

    Otherwise, you run the risk of the situation we have with various applications on Flathub which have chosen to use filesystem=host and keep their customized file choosers while they wait to see if the file chooser portal gains more features to come more into line with what they want. (Heck, last I checked, GIMP and Inkscape were in a bit of a "Have we confirmed that the host file chooser will provide thumbnail preview support for us yet?" state.)

@swick
Copy link
Contributor

swick commented Feb 21, 2022

Whether we want to establish a string to keyboard shortcut standard within this proposal.

What's the alternative? If we don't define the format of the hints what are clients supposed to do? For example if a KDE app uses whatever format KDE expects the hint won't be useful to gnome.

I guess you could have multiple hints for multiple desktops but you would still need to define the format of each of them which doesn't seem like an improvement at all.

Whether we want to force implementations to be responsible for listing the shortcuts and do the actual configuration. My impression is that apps expect to be able to do it themselves.

Can you expand on what you mean by that? How should apps be in control of configuring the shortcuts if the system should be in control of that? Do you mean that apps want to be able to open a dialog to bind individual shortcuts? And if so, how would that be a better user experience than a system UI where the user can bind all shortcuts of the app?

@Pointedstick
Copy link

How should apps be in control of configuring the shortcuts if the system should be in control of that? Do you mean that apps want to be able to open a dialog to bind individual shortcuts? And if so, how would that be a better user experience than a system UI where the user can bind all shortcuts of the app?

To expand on this, KDE apps already have this feature and we're hoping to be able to continue supporting is. The way it works is that from within an app, a user can show a window with just the shortcuts used by that app. There is also a global location in our System Settings app that aggregates all shortcuts used by all apps on the system. So we have both, because this split makes sense to us and our users. It's user-friendly for users to be able to edit the shortcuts for the app they're currently using by seeing a window of all of that app's own shortcuts.

@swick
Copy link
Contributor

swick commented Feb 21, 2022

The way it works is that from within an app, a user can show a window with just the shortcuts used by that app

This window is part of the system?

It's user-friendly for users to be able to edit the shortcuts for the app they're currently using by seeing a window of all of that app's own shortcuts.

I agree with that but to me it seems to contradict what @aleixpol said before:

Whether we want to force implementations to be responsible for listing the shortcuts and do the actual configuration. My impression is that apps expect to be able to do it themselves.

So I feel like I'm missing something.

@Pointedstick
Copy link

This window is part of the system?

It's a library component provided by a KDE library, and KDE apps can use it if they want (most do).

I'll let Aleix answer your other questions; I just wanted to chime in that letting a sandboxed app show its own shortcuts to the user is something we would find desirable in KDE.

@swick
Copy link
Contributor

swick commented Feb 21, 2022

https://docs.kde.org/stable5/en/khelpcenter/fundamentals/shortcuts.html

That's what you're talking about? In that case I'm starting to understand where this is all coming from.

We still have to pop up some system window which does the actual binding part, right? Can't you use another entry for global shortcuts: Settings → Configure Global Shortcuts?

epetousis referenced this issue in SpacingBat3/WebCord Sep 11, 2022
Because Wayland forbids processes from listening to system-wide
keypresses, Discord and WebCord are unable to listen for a push-to-talk
key. This commit hacks onto WebCord's socket server and allows for
sending a payload to activate and deactivate push-to-talk. The delay
between sending the packet and push-to-talk state changing appears to be
low enough for daily use. You could activate push-to-talk like so:

`echo '{"pttAction": "activate"}' | websocat --origin https://127.0.0.1 ws://127.0.0.1:6463`

The two "actions" that are supported are `activate` and `deactivate`.

The "hack" part of this commit also refers to the activation method -
the F12 key is used to trigger push-to-talk. Make sure that F12 is bound
before triggering actions, otherwise nothing will happen.
@Rush
Copy link

Rush commented Sep 27, 2022

How about injecting the keypress events as XEvent from evdev?

@aleixpol
Copy link
Contributor

How about injecting the keypress events as XEvent from evdev?

A portal implementation can implement support for evdev events. This is covered by this spec.

@rpigott
Copy link

rpigott commented Dec 15, 2022

Are there any simple test clients available for this protocol?

@aleixpol
Copy link
Contributor

I've done two ports so far, for our test app and for mumble.

https://invent.kde.org/libraries/xdg-portal-test-kde/-/merge_requests/6
mumble-voip/mumble#5976

@hyuri
Copy link

hyuri commented Feb 17, 2023

To be clear, are we talking about only allowing Modifier Key(s) + Other Key shortcuts here? If that's the case, apart from being a really good way to kill keyloggers (which is great), it would also kill apps like AutoKey that provide very powerful shortcut capabilities that allows us to add Single Key shortcuts to customize the behaviour of certain creative apps such as Kdenlive, essentially allowing us to add new functionality to a given app that doesn't have it yet or never will.

For example: I can to set a shortcut Q, that only runs when Kdenlive is focused, and triggers a sequence of other shortcuts inside of Kdenlive to combine multiple actions into one step. These kinds of quick Single Key shortcuts are essential to professional video editors and other creatives who need to work fast, so allowing an app like AutoKey to provides us with that facility can make it easier for professionals to switch to Linux and Open Source apps. This is basically a necessity in some creative apps. I'm a video editor and have recently started experimenting with using Kdenlive in addition to Premiere Pro, and I was only able to do so because AutoKey allowed me to bound custom actions to Single Key shortcuts.

@jadahl
Copy link
Collaborator

jadahl commented Feb 17, 2023

To be clear, are we talking about only allowing Modifier Key(s) + Other Key shortcuts here?

The portal API is explicitly clear that it doesn't restrict what the portal backend can use to trigger a global shortcut. It can be a modifier+key combination, it can be just a key press, it can be a foot pedal, looking at the computer angrily, or anything else.

With that said, I'm not familiar AutoKey, so if there is something missing from portal API itself, I suggest opening an issue, describing what is missing.

@hyuri
Copy link

hyuri commented Feb 17, 2023

To be clear, are we talking about only allowing Modifier Key(s) + Other Key shortcuts here?

The portal API is explicitly clear that it doesn't restrict what the portal backend can use to trigger a global shortcut. It can be a modifier+key combination, it can be just a key press, it can be a foot pedal, looking at the computer angrily, or anything else.

With that said, I'm not familiar AutoKey, so if there is something missing from portal API itself, I suggest opening an issue, describing what is missing.

Awesome, so that should work for apps like AutoKey. Does the API include communicating whether the key/shortcut is pressed/held down or released?

The other missing part of the puzzle for AutoKey is knowing which app/window is in focus when the shortcut is triggered, but I imagine that's for another solution or portal, right? If true, is there any such portal I should look into? A "window in focus" kind of portal?

@ssokolow
Copy link

ssokolow commented Feb 17, 2023

If true, is there any such portal I should look into? A "window in focus" kind of portal?

At the moment, the state implementation embodies an earlier statement that it's either too big a security threat to allow 'remember this' and too irritating/impractical to prompt every time or "not everything needs to be a portal".

Here's the open issue requesting a portal for it for use in things like time tracking apps, joystick-to-keyboard event synthesizers, and so on: #304

(The argument I made there is that, if it's not a portal, then any implementer is almost certainly going to wind up needing to lobby for and bind to a separate API for each Wayland compositor now that X11 is on the wane.)

@jadahl
Copy link
Collaborator

jadahl commented Feb 17, 2023

Does the API include communicating whether the key/shortcut is pressed/held down or released?

It has two signals, one for when the trigger is activated, and another for when it's deactivated. It's meant to handle e.g. the press and release of a key, so yes.

If true, is there any such portal I should look into? A "window in focus" kind of portal?

Was going to link to #304 too, but perhaps it's less "track user activity and behavior" like to include what the focused application was when a global shortcut was activated; I don't know.

Edit: missed a "de"

@hyuri
Copy link

hyuri commented Feb 17, 2023

Excellent! All the pieces are already falling into place, then🙂 Thank you folks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new portals This requires creating a new portal interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.