How to create a keyboard shortcut to play/pause any audio/video running in the background?
7
votes
4
answers
17828
views
So I bought this keyboard for my laptop that doesn't have media keys on it and I am very used to pressing the play/pause button on my laptop to pause any media playing in the background. With this keyboard however I have to create my own keyboard shortcuts to do that because of the absence of media keys. Till now I have managed to make keyboard shortcuts for volume control.
Research and my attempts:
1. I found this page which shows a command to simulate media keys from the terminal.
.
The command is
xdotool key XF86AudioPlay
but when I make a keyboard shortcut out of this by going to **Settings > Keyboard > Application Shortcuts**. It doesn't seem to work.
1. When I press the keyboard shortcut which I have set to *Super+F11* my CPU usage rises a bit which means that the shortcut is working. I confirmed this by changing the command the shortcuts executes to exo-open --launch WebBrowser
which as you might have thought opens my web browser when I press *Super+F11*.
1. Now because I knew a bit of C/C++ I created this wrapper program which does exactly the same thing
#include
int main() {
system("xdotool key XF86AudioPlay");
}
and mapped the shortcut to execute this program but Alas!! it still doesn't work.
How do I get the command that XFCE executes when I press the default play/pause button on my laptop keyboard because that seems to play/pause any media playing in the background.
I use XFCE on Arch Linux.
I usually listen to music on rhytmbox music play.
Asked by Mayank Shigaonker
(171 rep)
Aug 10, 2020, 09:25 AM
Last activity: Feb 29, 2024, 08:41 AM
Last activity: Feb 29, 2024, 08:41 AM