Bug 409190 - Have kded or plasmashell handle media-related keyboard shortcuts so they don't stop working when all Audio Volume applet/widget instances are removed or when more than one is present
Summary: Have kded or plasmashell handle media-related keyboard shortcuts so they don'...
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Media Player (show other bugs)
Version: 5.16.5
Platform: Manjaro Linux
: NOR task
Target Milestone: 1.0
Assignee: Kai Uwe Broulik
URL:
Keywords:
: 395444 416841 460436 (view as bug list)
Depends on:
Blocks: 485384 443036
  Show dependency treegraph
 
Reported: 2019-06-25 22:23 UTC by 8192
Modified: 2024-08-21 02:15 UTC (History)
11 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description 8192 2019-06-25 22:23:06 UTC
SUMMARY
Elisa doesn't react to media key input, whether the window is in or out of focus.

For reference, my keyboard's media keys register

in showkey as
STOP: keycode 166
PREV: keycode 165
PLAY/PAUSE: keycode 164
NEXT: keycode 163

and in xev as
STOP: keysym 0x1008ff15, XF86AudioStop
PREV: keysym 0x1008ff16, XF86AudioPrev
PLAY/PAUSE: keysym 0x1008ff14, XF86AudioPlay
NEXT: keysym 0x1008ff17, XF86AudioNext

and these keys work with other programs like Clementine.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Manjaro 18.0.4
KDE Plasma Version: 5.15.5
KDE Frameworks Version: 5.59.0
Qt Version: 5.12.3
Comment 1 Nate Graham 2019-06-26 13:16:36 UTC
Works for me, FWIW.
Comment 2 8192 2019-08-15 17:57:02 UTC
Does Elisa not use the Application Media Controller?

If I go into Configure Elisa > set Media Play for Play-Pause, I see the dialog,

"The shortcut 'Media Play' conflicts with the following key combination: Shortcut 'Media Play' in Application Media Controller for action Play/Pause media playback"
Comment 3 8192 2019-08-15 17:58:13 UTC
Not to mention that Elisa would only respond to this key if raised (in focus), unlike any other player (Clementine, mpv, etc.).
Comment 4 Nate Graham 2019-08-17 19:32:59 UTC
I just experienced this today, and discovered the issue was that plasma-browser-integration has grabbed the media keys for a YouTube video. You can check this by showing the Media Player system applet item and seeing what it shows. If Elisa is playing music, but another app/audio source is listed in the Media Player applet, that's the problem.

Can you see if this is what's happening?
Comment 5 8192 2019-08-17 21:17:29 UTC
I have Clementine and a YouTube video playing in the background. I started Elisa and play a song. 

I see Elisa and the song it's playing in the Media Player tray widget: https://i.imgur.com/5P82Eq6.png


I also see the same in the default Media Player plasmoid:
https://i.imgur.com/a6qq3S0.png

However, while I'm seeing this, my media keys still only manipulate Clementine. This is whether Elisa is in or out of focus.
Comment 6 8192 2019-08-17 21:19:12 UTC
If I close Clementine, the "Choose player automatically" dropdown disappears from both the Media Player tray widget and the plasmoid, and now media keys don't do anything because Elisa doesn't respond to them.
Comment 7 8192 2019-08-17 21:25:39 UTC
... And now, Elisa suddenly responds to them! I have no idea what changed. 

With Clementine closed, it still wouldn't respond to media keys for a little there. Then I clicked on Elisa to focus on it again, and now the media keys work, in and out of focus!

It's a mixed bag as to who (between Clementine and Elisa) gets the keys when they're both open, but, until now, Elisa didn't respond no matter what. So... Yay!
Comment 8 Nate Graham 2019-08-17 22:12:08 UTC
I guess that wasn't it. Thanks for the info!
Comment 9 Nate Graham 2019-09-11 18:19:13 UTC
Is it still working for you?

I'm getting the feeling that this is related to how the Media Player plasmoid handles multiple MPRIS data sources. Moving there for further comment.
Comment 10 8192 2019-09-11 18:46:17 UTC
It's still working.

You may be right about the plasmoid -- a while ago, I think I discovered another clue, but regretfully didn't report in and may be mistaken now: 

if I booted with the Media Player thingy in my tray (the "plasmoid"?) disabled from "Configure System Tray...", Elisa would start and not respond to media controls until the Media Player in the tray was re-enabled. Maybe this is why I initially ran into the issue because, usually, I always had it disabled since I never needed it.

Of course, I can't try to replicate; I have way too many tabs open and things. :3
Comment 11 8192 2019-09-11 18:48:15 UTC
Currently, I'm on a boot in which the Media Player was left enabled. If I disable the Media Player, Elisa's media keys still work, and I *believe* this was also the case back then. It just needed to be enabled once for media keys to work.
Comment 12 Nate Graham 2019-09-11 18:57:17 UTC
(In reply to 8192 from comment #10)
> You may be right about the plasmoid -- a while ago, I think I discovered
> another clue, but regretfully didn't report in and may be mistaken now: 
> 
> if I booted with the Media Player thingy in my tray (the "plasmoid"?)
> disabled from "Configure System Tray...", Elisa would start and not respond
> to media controls until the Media Player in the tray was re-enabled. Maybe
> this is why I initially ran into the issue because, usually, I always had it
> disabled since I never needed it.
Yep, it sounds like this is exactly the issue, which I can both reproduce and explain: it's because the Media Player applet/widget is what handles media keys. If you remove all of them, nothing is left to handle the media keys. The same thing happens to your volume keys if you remove or disable all instances of the Audio Volume applet/widget (See Bug 391578).

A solution might be to have the kded deamon or even plasmashell itself register these keys so you don't lose functionality if you opt to disable system tray applets without adding their widget versions.

Kai, would it be feasible to move media key handling out of the Media Player applet/widget and into kded or plasmashell or somewhere else? Though then I suppose the downside would be that in the KGlobalAccel KCM, the shortcuts would show up under "KDE Daemon" rather than "Media Controller" or Audio Volume". I wonder if there's a way to have the best of both worlds...
Comment 13 David Edmundson 2019-09-11 21:51:10 UTC
>the shortcuts would show up under "KDE Daemon" 

That's a non-issue. Any component name can be set.

Downside is the fact that now we have to load and track everything twice, especially if it's in kded. There's an overhead cost.
Comment 14 Nate Graham 2020-01-28 19:17:20 UTC
*** Bug 416841 has been marked as a duplicate of this bug. ***
Comment 15 Riccardo Robecchi 2020-01-30 17:37:49 UTC
(In reply to Nate Graham from comment #14)
> *** Bug 416841 has been marked as a duplicate of this bug. ***

It seems like the hypothesis of this bug only occurring when there's no widget at all is not correct, or that the bug I opened (and which Nate closed) is not related to this one. In my case, I always use the widget on my panel (not in the tray). So there is in fact a widget which could register the keys, but it doesn't work. I would therefore say that the issue is not about the key presses not being registered when there's no tray applet or widget, at least as far as the bug I reported is concerned.
Comment 16 Nate Graham 2021-02-24 19:07:28 UTC
*** Bug 395444 has been marked as a duplicate of this bug. ***
Comment 17 Nate Graham 2022-12-23 22:10:30 UTC
*** Bug 460436 has been marked as a duplicate of this bug. ***
Comment 18 Nate Graham 2023-02-21 20:49:38 UTC
*** Bug 460771 has been marked as a duplicate of this bug. ***
Comment 19 Bharadwaj Raju 2023-12-01 18:08:12 UTC
Seems fixed with https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2895