Bug 391578 - Have kded or plasmashell handle volume-related keyboard shortcuts so they don't stop working when all Audio Volume applet/widget instances are removed
Summary: Have kded or plasmashell handle volume-related keyboard shortcuts so they don...
Status: RESOLVED FIXED
Alias: None
Product: plasma-pa
Classification: Plasma
Component: general (show other bugs)
Version: 5.12.3
Platform: Other Linux
: NOR task
Target Milestone: ---
Assignee: David Rosca
URL:
Keywords: usability
: 449527 (view as bug list)
Depends on:
Blocks: 443036
  Show dependency treegraph
 
Reported: 2018-03-08 19:02 UTC by Nate Graham
Modified: 2024-03-16 07:39 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nate Graham 2018-03-08 19:02:19 UTC
By default, there is a little Audio Volume plasmoid in the System Tray that handles the volume keys on a laptop's keyboard.

If you add a standalone Audio Volume plasmoid, that one takes over the keys.

But then if you then delete it, the one in the System Tray doesn't regain control of the keys, so they stop working.

This is 100% reproducible for me in Plasma 5.12.3 on Kubuntu 17.10.
Comment 1 David Rosca 2018-03-08 20:10:36 UTC
Yes, that's how it works.

In general, applets shouldn't register global shortcuts exactly for this reason - there can be multiple instances of one applet, but only one can have global shortcut registered at time. But of course, in this case, it is needed because there have to be global shortcuts for volume control.

Proper way for global shortcuts is to handle them from daemon (eg. kded module), but plasma-pa doesn't have it.

To fix this, it would be needed to track the lifetime of GlobalActions, add a proxy object and route the triggered signal only to one applet at time.

I'm not sure if it is really worth fixing though. In 99.99% cases you won't hit this, only when you are playing with applets :D
Comment 2 Nate Graham 2018-03-08 20:15:02 UTC
I think it's a not-uncommon happenstance: you're playing around with the Widget Explorer because you're excited to see what Plasma has to offer and you try this one. You use it, realize it does exactly the same thing as the one in your system tray, so you remove it. Then your volume keys stop working. Gross.

These kinds of little minefields where system functionality becomes broken when a curious user plays around are a huge usability problem and a source of the sense that "KDE is unstable!!!!11!"

On another note, is there any way to make the keys work again without permanently re-adding the standalone plasmoid?
Comment 3 David Rosca 2018-03-08 20:47:04 UTC
What do you mean with standalone plasmoid? For shortcuts working there must be at least one volume plasmoid. If you add another volume plasmoid which will take over the shortcuts and then remove it, you need to either add another volume plasmoid (eh) or restart plasmashell to make the shortcuts work again.
Comment 4 Nate Graham 2018-03-08 20:49:45 UTC
Yes, there is always at least one in the System Tray.

And ah yes, killing and restarting plasmashell resolves the issue. Is there no sane and sensible way we can signal to plasmashell to reassign the keys after the second plasmoid is removed without killing and restarting it?
Comment 5 David Rosca 2018-03-08 21:02:30 UTC
You can disable it in system tray, it is just enabled by default.

plasmashell doesn't handle these shortcuts, it is done by applet itself with KGlobalAccel.
Comment 6 Nate Graham 2018-03-08 21:13:56 UTC
(In reply to David Rosca from comment #5)
> You can disable it in system tray, it is just enabled by default.

Right. The point is, if you add a second one, *something* should return the keys back to the first one without you having to restart plasmashell.
Comment 7 David Rosca 2018-03-08 21:29:12 UTC
The thing is, there is no correct solution to this issue. Which applet should receive shortcut events if there is multiple applets? All of them? Only one - which one?

If you say that the answer is "always send the shortcut event to one applet, doesn't matter which one", then it is incorrect. You can set maximum volume over 100% and this setting is separate for applet instances. Changing volumes with shortcut then honors this setting (and again, this can be different for each applet instance).

So the solution is to move some parts (including shortcuts handling) to kded module or enforce at most one instance of plasma-pa applet, but as far as i know that is not supported by plasmashell.
Comment 8 Nate Graham 2018-03-08 21:37:32 UTC
Tricky problem. The last-added instance, maybe? That's what seems to happen right now. The only bug is that control doesn't shift back without restarting plasmashell. To me that seems like a reasonable-enough solution until we can do a larger re-architecture of this.

Or just spitballing here: If you already have one instance and you add a second, could the second basically just act as a link to the first one, or use its configuration data? I'm not sure what the value is in having multiple volume plasmoids when they each have different settings. In fact I do set the maximum volume above 100%, and I was confused when I added the second one to see what it was and I found that it had the volume set back to 100% again. I expected it to inherit the configuration data from the original. Is there a use case for having multiple Plasmoids with different configuration data, or is this just a quirk of the implementation?
Comment 9 David Rosca 2018-03-08 22:22:02 UTC
> Is there a use case for having multiple Plasmoids with different configuration data, or is this just a quirk of the implementation?

Yes, pretty much all applets except plasma-pa wants this. That's how you can have launchers with different apps, clocks with different formatting, menus with different contents, etc...
Comment 10 Nate Graham 2018-03-08 22:35:34 UTC
Right right yeah. I should have written, "...for having multiple *Audio Volume* Plasmoids with different configuration data..."
Comment 11 Tino Lorenz 2020-06-01 12:03:02 UTC
Maybe just add a warning along the lines of 
"Disabling all Audio volume plasmoids will cause media- and volume keys to stop working, you might want to use 'Always hidden' instead." 
to the system tray configuration dialog until this works independently of the plasmoid?
Comment 12 Nate Graham 2022-02-03 20:14:39 UTC
*** Bug 449527 has been marked as a duplicate of this bug. ***
Comment 13 craig_jackson 2022-09-03 12:33:52 UTC
Is there a workaround for this? I'm using Kubuntu 22.04 LTS and probably went on the same journey as the OP whereby the volume control function keys stopped working. 

If I add an audio widget to my desktop then volume controls work again. But I don't want/need that widget because I already have a volume widget in the system tray.  And if i remove the audio widget from the desktop the volume keys stop working again.

Is there some way of tricking KGlobalAccel or whatever into handing / routing the audio function keys back to the system tray volume widget?

I've experienced this on several laptops over the past 5+ years.
Comment 14 craig_jackson 2022-09-03 12:51:08 UTC
For anyone else experiencing this, the fix for me was to add the audio widget to my panel *alongside* my system tray, then configured my system tray audio volume to be "always hidden". That way, I only see one audio volume widget in my panel (I'm using latte dock, but same applies to the plain old KDE panel I reckon).

So it seems the system tray audio volume widget was ignoring the audio control keyboard shortcuts.
Comment 15 craig_jackson 2022-09-03 12:51:42 UTC
For anyone else experiencing this, the fix for me was to add the audio widget to my panel *alongside* my system tray, then configured my system tray audio volume to be "always hidden". That way, I only see one audio volume widget in my panel (I'm using latte dock, but same applies to the plain old KDE panel I reckon).

So it seems the system tray audio volume widget was ignoring the audio control keyboard shortcuts.
Comment 16 Bug Janitor Service 2023-12-01 12:13:52 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-pa/-/merge_requests/221
Comment 17 Nate Graham 2024-02-21 16:09:33 UTC
*** Bug 478928 has been marked as a duplicate of this bug. ***
Comment 18 Bharadwaj Raju 2024-03-16 07:39:40 UTC
Git commit e7830539923c871243f07a055c6a8dd6dcc0fafd by Bharadwaj Raju.
Committed on 16/03/2024 at 07:39.
Pushed by bharadwaj-raju into branch 'master'.

Create KDED service to handle global shortcuts and OSDs

New KDED service which handles global shortcuts and OSDs, called
"audioshortcutsservice". Now these functions don't depend on an applet existing.

See plasma-desktop#113

M  +1    -0    CMakeLists.txt
D  +0    -64   applet/contents/code/icon.js
M  +3    -5    applet/contents/ui/ListItemBase.qml
M  +16   -301  applet/contents/ui/main.qml
M  +46   -7    src/CMakeLists.txt
A  +54   -0    src/audioicon.cpp     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
A  +28   -0    src/audioicon.h     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
R  +0    -0    src/dbus/osdService.xml [from: src/qml/dbus/osdService.xml - 100% similarity]
R  +0    -0    src/globalconfig.kcfg [from: src/qml/globalconfig.kcfg - 100% similarity]
R  +1    -1    src/globalconfig.kcfgc [from: src/qml/globalconfig.kcfgc - 086% similarity]
R  +0    -0    src/globalconfigskeleton.h [from: src/qml/globalconfigskeleton.h - 100% similarity]
M  +4    -4    src/kcm/ui/MuteButton.qml
D  +0    -27   src/kcm/ui/icon.js
A  +22   -0    src/kded/CMakeLists.txt
A  +367  -0    src/kded/audioshortcutsservice.cpp     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
A  +51   -0    src/kded/audioshortcutsservice.h     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
A  +7    -0    src/kded/audioshortcutsservice.json
A  +2    -0    src/kded/audioshortcutsservice.json.license
D  +0    -55   src/qml/globalactioncollection.cpp
D  +0    -48   src/qml/globalactioncollection.h
A  +59   -0    src/qml/globalservice.cpp     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
A  +29   -0    src/qml/globalservice.h     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
M  +1    -0    src/qml/listitemmenu.cpp
M  +1    -1    src/qml/listitemmenu.h
M  +6    -7    src/qml/microphoneindicator.cpp
M  +3    -3    src/qml/microphoneindicator.h
M  +12   -5    src/qml/plugin.cpp
D  +0    -36   src/qml/volumeosd.cpp
D  +0    -24   src/qml/volumeosd.h
R  +0    -0    src/volumefeedback.cpp [from: src/qml/volumefeedback.cpp - 100% similarity]
R  +0    -0    src/volumefeedback.h [from: src/qml/volumefeedback.h - 100% similarity]

https://invent.kde.org/plasma/plasma-pa/-/commit/e7830539923c871243f07a055c6a8dd6dcc0fafd