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 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.
Or wev on wayland