One caveat at the moment, this only works with applications that support MPRIS or "Media Player Remote Interfacing Specification". A large amount of media applications already support this but if you aren't sure open your application and type this code in a terminal.
Code: Select all
qdbus | grep org.mpris.MediaPlayer2 | sed 's/.*\.//'
[Overview]
The overview of my fix:
Say I want to be able to set the Play/Pause button to work on any media player allowing me to play or pause the music. First create a script to send the the Play/Pause command to your applications.
Here's my script for Play/Pause:
Code: Select all
#!/bin/bash
## -- This script will imitate Gnome's Media Controls (Play/Pause, Next, Previous, Stop) -- ##
## -- It will assume you are using a media application that is compatible with MPRIS or -- ##
## -- "Media Player Remote Interfacing Specification" -- ##
# Search for running media applications
# and store into apps array
apps=(`qdbus | grep org.mpris.MediaPlayer2 | sed 's/.*\.//'`)
# For each application send the "PlayPause" command
for app in "${apps[@]}"
do
qdbus org.mpris.MediaPlayer2.$app /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
done
Now all we have to do is assign this script to a global shortcut. In KDE go to System Settings > Shortcuts and Gestures > Custom Shortcuts. Right click in the white space and select New > Global Shortcut > Command URL. Name your Action whatever you like and now click the Trigger tab and assign your appropiate shorcut. Now click the Action tab and browse to your previously made script. Make sure your script is executable by quickly typing "chmod +x /home/USER/script". After you click Apply you should be able to control all supported media applications with your shortcut!