How do you switch whats controlled by media keys?

https://lemmy.dbzer0.com/post/25499675

How do you switch whats controlled by media keys? - Divisions by zero

I use Kubuntu 24.04. My keyboard has working media playback keys. When I listen to music and a video starts playing, I want to pause the music. It usually pauses the video which i could also pause easily in other ways. Is it possible to write a script that toggles through the other other media playing processes in terms of coupling them to the media keys?

I don’t have a solution for you, but to get you started, run xev and see which keycode event is triggered by the keypresses.
playerctl can list and control (most) media players individually, and would be suitable for writing a script with. In terms of rebinding keys you might be able to set them to run shell commands using global shortcuts in KDE system settings, although I’m not at my computer right now to test it.
GitHub - altdesktop/playerctl: 🎧 mpris media player command-line controller for vlc, mpv, RhythmBox, web browsers, cmus, mpd, spotify and others.

🎧 mpris media player command-line controller for vlc, mpv, RhythmBox, web browsers, cmus, mpd, spotify and others. - altdesktop/playerctl

GitHub
That looks promising, thank you.