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.
#!/usr/bin/php
< ?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';
break;
case 'title':
$pattern = '~"title".*?"(.*?)".*~s';
break;
case 'artist':
$pattern = '~"artist".*?"(.*?)".*~s';
break;
default:
exit;
}
preg_match($pattern, $song, $matches);
if($matches) {
echo $matches[1];
}
What php did you install? I’m using Ubuntu 12.04.
I got it, works fantastic! Thank you!
Scott, what php did you install to get it to run?
check below, idk if this will notify you or not.
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.
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.
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}
Can this same effect be done in a bash script?
Hi Gary, I am not 100% sure, but I tend to think not. conky continuously updates.
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.