strawberrymusicplayer / strawberry

:strawberry: Strawberry Music Player
https://www.strawberrymusicplayer.org/
GNU General Public License v3.0
2.64k stars 177 forks source link

Global media shortcuts don't work with KGlobalAccel #849

Closed DarthGandalf closed 2 years ago

DarthGandalf commented 2 years ago

Describe the bug I tried to configure global keyboard shortcut for Play/Pause. But it does nothing when pressed.

I checked in KDE settings, and it recognized Strawberry, but has only 2 shortcuts instead. These 2 shortcuts work, the other don't.

To Reproduce Every time. I even tried to remove strawberry shortcuts from kde settings, and upon startup, it creates only these 2.

Expected behavior When I press the key, the action should happen. This was working fine with Clementine.

Screenshots:

Настройки_246

Комбинации клавиш  — Параметры системы_001

System Information:

Additional context Add any other context about the problem here.

jonaski commented 2 years ago

Media shortcuts play/stop/next/previous are hard-coded to their respective media keyboard shortcuts when using kglobalaccel. Only the other actions can be assigned a different key from within strawberry. Maybe the media shortcuts can be changed within KDE settings (I'm not sure). The other alternative is to use X11 shortcuts. I can fix so that the media shortcuts are grayed out in the strawberry settings when kglobalaccel is checked, since setting them there have no affect.

DarthGandalf commented 2 years ago

Thanks for answer.

How does it work for Clementine then? I even want the usual Play/Pause key to be used for Play/Pause. It doesn't work with X11 either (and X11 is not recommended, according to settings), simply nothing happens when I press the key.

I started Clementine back, enabled the Play/Pause key from there, and it's visible and configurable from KDE settings fine: Комбинации клавиш  — Параметры системы_002, and it works.

One difference I see is that Clementine is in Applications, while Strawberry is in "System services"(?), not sure whether it matters

gerion0 commented 2 years ago

Everything is working fine for me with Strawberry/KDE/Gentoo. The communication happens via MPRIS. Is Strawberry recognized as player within KDE for you?

image

There is also a Global Shortcuts section within Strawberry itself, where you can choose the method that is used.

Edit: You can also check the working on the command line with

$ playerctl -p strawberry status
# this also works without extra software
$ qdbus org.mpris.MediaPlayer2.strawberry /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlaybackStatus

(Gentoo package)

I remember that I also had problems with MPRIS but that wasn't Strawberry's fault. The mediaplayer widget is installed as part of plasma-workspace and resides here /usr/share/plasma/plasmoids/org.kde.plasma.mediacontroller.

DarthGandalf commented 2 years ago

Yes, it's recognized. I see the same popup, and qdbus command returns Paused or Playing. Just the keyboard shortcut doesn't work.

DarthGandalf commented 2 years ago

There is also a Global Shortcuts section within Strawberry itself, where you can choose the method that is used.

That's where I have the shortcut set, yes. See my first screenshot.

gerion0 commented 2 years ago

Are your media control shortcuts assigned?

image

DarthGandalf commented 2 years ago

No. I don't want the media keys to affect any random player it found, like VLC if I am watching something, or Firefox if I have Youtube opened in one of tabs. I want the media keys to affect specifically Strawberry, which is why I'm trying to configure it in Strawberry settings. And the Strawberry settings claim that it's assigned.

DarthGandalf commented 2 years ago

@gerion0 in your screenshot I noticed that Strawberry is also in Apps like my Clementine is, not in System Services like my Strawberry is. I wonder what caused the difference

gerion0 commented 2 years ago

No. I don't want the media keys to affect any random player it found, like VLC if I am watching something, or Firefox if I have Youtube opened in one of tabs. I want the media keys to affect specifically Strawberry, which is why I'm trying to configure it in Strawberry settings. And the Strawberry settings claim that it's assigned.

Ok, but then the MPRIS (aka KDE/KGlobalaccel) is not the correct way for you to control Strawberry, isn't it? The whole purpose of the MPRIS controls is that multiple players can be controlled with the same mechanism. Of course, KDE itself can provide a setting to "pin" the shortcuts to one specific player (like it also displays several tabs for several player in the media control widget).

@gerion0 in your screenshot I noticed that Strawberry is also in Apps like my Clementine is, not in System Services like my Strawberry is. I wonder what caused the difference

I'm not sure. I have also more controls image

DarthGandalf commented 2 years ago

Ok, but then the MPRIS (aka KDE/KGlobalaccel) is not the correct way for you to control Strawberry, isn't it?

I don't particularly care about MPRIS, but KGlobalaccel is not limited to Media Players, it's just an API for applications to have a global shortcut.

I'm not sure. I have also more controls

Yep! These are the exact controls which I'm missing. And I see them for Clementine (when they are set in Clementine settings)

jonaski commented 2 years ago

I can reproduce this, same problem with the 0.9.3 release, so I don't know when this stopped working.

jonaski commented 2 years ago

This seem to be resolved with https://github.com/strawberrymusicplayer/strawberry/commit/bbd81e7d9c248d406cb425966578b6da961f9b3c where I enabled registering of media shortcuts too.

17:02:38.657 DEBUG GlobalShortcutsBackendKDE:73     Registering
17:02:38.658 INFO  GlobalShortcutsBackendKDE:158    Registered shortcut "next_track" QKeySequence("Media Next")
17:02:38.658 INFO  GlobalShortcutsBackendKDE:158    Registered shortcut "play_pause" QKeySequence("Media Play")
17:02:38.659 INFO  GlobalShortcutsBackendKDE:158    Registered shortcut "prev_track" QKeySequence("Media Previous")
17:02:38.659 INFO  GlobalShortcutsBackendKDE:158    Registered shortcut "stop" QKeySequence("Media Stop")