LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs > linux-related notes
User Name
Password

Notices


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:


Code:
#!/bin/bash

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

obmpc.sh next

fi
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 "mediaplayerwrapper.sh 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 712 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 01:32 PM.

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