News for hackers. Stuff that matters.
Re:Why Is It So Hard to Detect Keyup Event on Linux? by chrisseaton on Monday May 17, 2021 @11:59AM (#27184947)
> Unless you're suggesting that the DE comes with a preconfigured set of global hotkeys and cannot be altered or extended

Yes that's what I'm suggesting. Works fine for almost all use-cases like on macOS.

I guess it's just not a popular opinion lol!

Re:Why Is It So Hard to Detect Keyup Event on Linux? by eropple on Monday May 17, 2021 @12:12PM (#27185112)
I've had custom global hotkeys for stuff in MacOS for over a decade.
Re:Why Is It So Hard to Detect Keyup Event on Linux? by chrisseaton on Monday May 17, 2021 @12:13PM (#27185124)
But that's not how things like playback controls are implemented - they have non-extensible separate APIs for that. That's the point.
Re:Why Is It So Hard to Detect Keyup Event on Linux? by eropple on Monday May 17, 2021 @12:30PM (#27185288)
You've also been given a raft of other functions that depend on them in this thread.

I'm not sure what your hangup here actually is.

Re:Why Is It So Hard to Detect Keyup Event on Linux? by zxzax on Monday May 17, 2021 @04:34PM (#27188105)
IME, most of those functions tend to get implemented in the DE when it turns out they're actually useful, or some other mechanism can be used to activate them. So no reason to get hung up on that particular method to do it either.
Re:Why Is It So Hard to Detect Keyup Event on Linux? by reificator on Monday May 17, 2021 @12:16PM (#27185164)
I did edit the post you responsed to a few times in the last few minutes, so heads up there.

> > Unless you're suggesting that the DE comes with a preconfigured set of global hotkeys and cannot be altered or extended

> Yes that's what I'm suggesting.

Okay, let's use the example of music playback. If your DE handles music playback controls, how does it tell the music player when to stop and start, or skip to next track?

Does it hardcode a list of music players, each of which provides its own bespoke API, and the DE calls into the application?

Or does it provide a way for any music player to call into the DE, and listen for those play/pause/skip events?

And if it does that, then why are the list of events hardcoded? Why not allow the music player to say "I also play podcasts, and I want to provide a hotkey to speed up/slow down the playback speed, or provide a separate hotkey to skip ahead 30 seconds that's distinct from skipping the entire episode."? Why not allow Discord to provide a push-to-talk hotkey so that people on a group call can actually hear each other without dogs barking and keys clacking and people coughing?

---

Look at the VSCode Extension API for instance:

* Extensions are at least partially isolated from the main process and each other. I don't know how far this goes or how secure, but for our purposes they could be as isolated as you want.

* They can register a command which when activated, performs some action from within the extension.

* Those commands show up in the command list at the top of the screen when you hit "Control + Shift + P" (which is itself a command subject to all the same rules) and users can select whichever command they want to run.

* Those commands can also be assigned to a hotkey.

* Extensions can suggest a default binding for this hotkey, but users can go into the VSCode settings page and assign whatever keycombo they desire.

* Users can remove keybindings for commands that have them by default.

* Users can assign keybindings to commands that don't have them by default.

* All keybind editing is performed through the same UI, which is owned by VSCode and not the extension.

* VSCode itself is the thing listening to those key events, and it calls into the extension to activate it.

* There is a concept of context for when these keybinds apply, such as when a markdown document is active in the editor. Extensions provide these contexts by default and users can override them as they choose.

* Extensions themselves don't even start up until an activation event is met. These can be opening a file of a certain language, running a command, etc...

What about this model is objectionable in your mind? Who benefits from the lockdown you propose where no new ideas can be tried until the DE authority deigns to allow it?

Re:Why Is It So Hard to Detect Keyup Event on Linux? by zxzax on Monday May 17, 2021 @04:05PM (#27187777)
All of your concerns regarding music players are actually already addressed by the MPRIS spec: https://specifications.freedesktop.org/mpris-spec/latest/

This problem has been solved in the DEs for quite some time now, global hotkeys is probably the very last thing you want to reach for, when all other options are exhausted.

And when that happens, I don't know about other DEs, but the way you're describing with extensions is mostly how GNOME Wayland already works. If you want to intercept a key, you ship an extension for that, and display a UI to rebind the keys, or you can place additional entries in the system's keyboard settings panel. What you can't do is have random unprivileged processes intercept keys without the user's permission.