Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Media Player Info Script

Off-Topic discussions about science, technology, and non Debian specific topics.
Post Reply
Message
Author
User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Media Player Info Script

#1 Post by debiman »

Called without arguments, it returns the title (filled as intelligently as
possible, whether it's a network stream or a file without metadata) of the
currently playing song to stdout, clipped and ellipsized to a width of 60
chars, and a more verbose tooltip to stderr.

Image
https://notabug.org/ohnonot/media-player-info


Features and options include splitting into multiple lines respecting word boundaries, support of multiple players without having to settle on one, player controls dumped to a file, icons...

If you use tint2 it will fit right into its executor plugin, and that's what i wrote it for, but it doesn't require tint2 at all.

i'm still trying to figure out if this is useful to anybody but me. please share your thoughts - and don't spare the venom ;-)
Last edited by debiman on 2018-06-22 00:43, edited 1 time in total.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Media Player Info Script

#2 Post by debiman »

there's been a few more commits.
i have a few ideas for additions already, and will definitely implement something, but it is stable now (famous last words).
i think the plugin thing is pretty neat, you can not only add other media players but hack existing functionality in a relatively simple way (plugin overrides builtin).

I've been using this script for over 2 years.
i just think it could be useful for others, too.

what should i develop further, what features should i add? what's too much?

n_hologram
Posts: 459
Joined: 2013-06-16 00:10

Re: Media Player Info Script

#3 Post by n_hologram »

debiman wrote:If you use tint2 it will fit right into its executor plugin, and that's what i wrote it for
Nice.
Also looking forward to trying this on BSD. Will report if it works in case you want to advertise it as a "cross-unix benediction."
bester69 wrote:There is nothing to install in linux, from time to time i go to google searching for something fresh to install in linux, but, there is nothing
the crunkbong project: scripts, operating system, the list goes on...

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Media Player Info Script

#4 Post by debiman »

alright!
may i ask which player(s) you use it with?
do you think the multiplayer feature is silly?

i added optional notification on sing-change yesterday. the random colorisation requires bc; forgot to mention that in the documentation.

about BSD: this is a bash script. i suppose BSD also offers that; which version?
apart from that there's no reason why it shouldn't work.

n_hologram
Posts: 459
Joined: 2013-06-16 00:10

Re: Media Player Info Script

#5 Post by n_hologram »

debiman wrote:alright!
may i ask which player(s) you use it with?
do you think the multiplayer feature is silly?

i added optional notification on sing-change yesterday. the random colorisation requires bc; forgot to mention that in the documentation.

about BSD: this is a bash script. i suppose BSD also offers that; which version?
apart from that there's no reason why it shouldn't work.
I'll be using Audacious. I'm interested if I can also set it up to poll from my headless mpd server, though.
Multiplayer feature sounds fine, nothing silly about it.
OpenBSD 6.2 comes with bash 4.4 with a default install, even though it isn't the default shell. I also discovered that its default location is /usr/local/bin.

Update: tried it in openbsd and nothing showed up in tint2. I set a new executor to run the script, but nothing changed in tint2.

Code: Select all

/usr/local/bin/bash /home/omega/Downloads/media-player-info/mpi-panel -p audacious -t 1
Variations: without bash, and without the full path to bash; without one option, and without both options; and directly from a terminal.
bester69 wrote:There is nothing to install in linux, from time to time i go to google searching for something fresh to install in linux, but, there is nothing
the crunkbong project: scripts, operating system, the list goes on...

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Media Player Info Script

#6 Post by debiman »

n_hologram wrote:Variations: without bash, and without the full path to bash; without one option, and without both options; and directly from a terminal.
and nothing at all?
that's bad.
and you're sure audacious is playing something, and audtool is available?
does this command:

Code: Select all

audtool current-song-tuple-data artist current-song-tuple-data title current-song-filename current-song-output-length current-song-length playback-status
output something?

maybe you can add 'set -x' to the top of the script, and post the output.

n_hologram
Posts: 459
Joined: 2013-06-16 00:10

Re: Media Player Info Script

#7 Post by n_hologram »

Audacious is definitely running; I can tell because of the death metal. And the audtool command outputs exactly what you'd expect.

Here are the results of appending set -x to mpi-panel (I'm assuming that's what you meant):
https://pastebin.com/raw/2ZKUkhDt
bester69 wrote:There is nothing to install in linux, from time to time i go to google searching for something fresh to install in linux, but, there is nothing
the crunkbong project: scripts, operating system, the list goes on...

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Media Player Info Script

#8 Post by debiman »

i'll try to make sense of it, but i can already see that something isn't quite right.
too many empty strings.
this actually looks a lot like what i get when i use '-p audacious', but audacious is not running.
what's the output of 'pidof audacious'?

how did you call the script? command line & options for the output you pastebin'd?

while troubleshooting with 'set -x', could you try again without the tint2 option (-t), because it periodically clears stderr.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Media Player Info Script

#9 Post by debiman »

the script can now also extract album art from local files.
i also fixed a glitch where enabling the -I option actually disabled the display of normal play/pause/stop icons, and improved mpd title recognition for e.g. soundcloud playlists.

(open)BSD support: it seems the BSDs don't ship with some fairly standard linux utilities. the missing pidof completely breaks the script.
is it something bsd users normally install on their systems? i tried in a vm but didn't get very far in configuring it (or figuring out how to get pidof installed).
anybody have an idea how i can reproduce that with ps or other bsd utilities without using pipes or too much additional logic?
the script just needs to know whether the media player is running, e.g. pidof mpd >/dev/null 2>&1.

i have updated the list of dependencies and will see what i can do about it.

n_hologram
Posts: 459
Joined: 2013-06-16 00:10

Re: Media Player Info Script

#10 Post by n_hologram »

debiman wrote:the script just needs to know whether the media player is running
What would be the issue with using ps -ax or something?
bester69 wrote:There is nothing to install in linux, from time to time i go to google searching for something fresh to install in linux, but, there is nothing
the crunkbong project: scripts, operating system, the list goes on...

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Media Player Info Script

#11 Post by debiman »

n_hologram wrote:
debiman wrote:the script just needs to know whether the media player is running
What would be the issue with using ps -ax or something?
pidof is just one command; with ps -ax i have to do either very complex bash analyzing afterwards, or pipe the output to grep.
i am trying to avoid all external commands here; 1 external command is better than 2.
it also seems that openbsd's ps version is different from gnu/linux.

interestingly, pgrep is already provided on the pristine openbsd i have running in a vm.
on my linux machine, it belongs to the same package as pidof. weird.

i have now uploaded another commit that uses pgrep instead of pidof, would you mind trying it out?
please also look at the dependencies in the README.md.

n_hologram
Posts: 459
Joined: 2013-06-16 00:10

Re: Media Player Info Script

#12 Post by n_hologram »

I always forget pgrep is a command lol.

The script works now, in that it shows the artist-track (which is honestly all I wanted). I read something about buttons and artist/album icons, but I didn't read enough to see if I had properly set that up, if it's an out-of-the-box feature, or if I need to install a dependency or two.
bester69 wrote:There is nothing to install in linux, from time to time i go to google searching for something fresh to install in linux, but, there is nothing
the crunkbong project: scripts, operating system, the list goes on...

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Media Player Info Script

#13 Post by debiman »

^ good to know it works on openbsd :D

if you use tint2 with executor plugin capabilites, you should look at the example snippet provided.
the magic is that you can dump information to a file, such as playing song or command used to show the player.
then you can e.g. bind a hotkey to

Code: Select all

$(sed -n 8p /tmp/tint2-mpi-panel-dump)
to show the player ui, or tell tint2 to do the same on mouseclick, or tell conky to display album art (haven't actually tried that yet) etc.

try the -h option, it's almost like a man page! :)

Post Reply