Pull info from Pithos for Conky

I switched from pianobar to Pithos as pianobar didn’t work as well with conky as I would have liked. The script below lets me get information from Pithos that I can use in pianobar.

< ?php

$song=`dbus-send --print-reply --dest=net.kevinmehall.Pithos /net/kevinmehall/Pithos net.kevinmehall.Pithos.GetCurrentSong`;

$matches = array();

switch($argv[1]) {
	case 'album':
		$pattern = '~"album".*?"(.*?)".*~s';
	case 'title':
		$pattern = '~"title".*?"(.*?)".*~s';
	case 'artist':
		$pattern = '~"artist".*?"(.*?)".*~s';

preg_match($pattern, $song, $matches);

if($matches) {
	echo $matches[1];

Application Developer at the University of Iowa. Works mostly with PHP/Oracle, but doesn't like the Oracle bits. Also an avid gamer and tinkerer.

Posted in Scripting Tagged with: , , ,
10 comments on “Pull info from Pithos for Conky
  1. Scott says:

    What php did you install? I’m using Ubuntu 12.04.

  2. Scott says:

    I got it, works fantastic! Thank you!

  3. VastOne says:

    Scott, what php did you install to get it to run?

  4. Scott says:

    Vastone, I used the following:

    sudo apt-get update
    sudo add-apt-repository ppa:ondrej/php5

    Then in conkyrc file:

    ${goto 50}${color white}${font augie:style=Bold:size=10}${execi 1 php /home/scottr99/pithosGet.php title -f -i title}$font$color
    ${goto 50}${color white}by:$color ${color white}${font augie:style=Bold:size=10}${execi 1 php /home/scottr99/pithosGet.php artist -f -i artist}$font$color
    ${goto 50}${color white}on:$color ${color white}${font augie:style=Bold:size=10}${execi 1 php /home/scottr99/pithosGet.php album -f -i album}$font$color

    let me know if you have a problem.

    • Scott says:

      for php I forgot one line, should read like this:

      sudo apt-get update
      sudo add-apt-repository ppa:ondrej/php5
      sudo apt-get install php5

      copy all lines in this order in a terminal.

      I just did it to my son’s computer, worked perfect.

  5. Scott says:

    sorry, w/o the formatting:

    ${execi 1 php /home/scottr99/pithosGet.php title -f -i title}
    ${execi 1 php /home/scottr99/pithosGet.php artist -f -i artist}
    ${execi 1 php /home/scottr99/pithosGet.php album -f -i album}

  6. Gary DeLaney says:

    Can this same effect be done in a bash script?

  7. Caden says:

    I know i’m kinda raising the dead here but im somewhat stuck. After i install php from the ppa and then insert the lines in the conkyrc i get the php script 3 times in text in my conky.