Help answer threads with 0 replies.
Go Back > Blogs > linux-related notes
User Name


Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Rate this Entry

Prototype/principle for a wrapper script for multiple media players to use the same Openbox keybindings, depending on which one is running

Posted 03-25-2021 at 10:50 AM by the dsc
Tags mpc, mpv, openbox

Most likely not the most elegant way of doing it, and not fully functional (for mpv) regarding the display of media info:


if pgrep -x mpv ; then

echo '{"command": ["playlist-next"]}' > /tmp/mpvsocket

#title=$(echo '{ "command": ["get_property", "media-title"] }'  >  /tmp/mpvsocket)

#title=( $(wmctrl -l | grep mpv$ ) ) 

#title=$(echo  ${title[@]:3} | sed 's| - mpv||' )
DISPLAY=:0 notify-send "> > > >" --icon=mpv

else next

I just gave up trying to "grep" the title from mpv after a few tries. But otherwise it works. The rationale couldn't be simpler, if mpv is running, the script will handle it, otherwise it defaults to mpc (through another script, in this case, which handles the notify-send OSD correctly for mpv, besides other things, like a pipe menu for openbox and this kind of stuff).

Theoretically all wanted commands can be handled by a single script, with the openbox keybinding specifying the command with a parameter, like " nexttrack," rather than a script for each command, which is how I first "implemented" it in order to give it a try.

The media player hierarchy or selection can possibly be made more sophisticated, with something like using /dev/shm/ files to communicate with itself regarding what was the most recently used media player and whatnot. Maybe one can even detect if a browser is playing something and do some xdotool+wmctrl vodoo with it and unify everyhing. If I ever do that, it would be hard not to celebrate by yelling, "it's ALIVE! It's ALIVE!!"
Posted in Uncategorized
Views 602 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 07:22 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration