pithos.php 536 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/php
  2. <?php
  3. $song=`dbus-send --print-reply --dest=net.kevinmehall.Pithos /net/kevinmehall/Pithos net.kevinmehall.Pithos.GetCurrentSong`;
  4. $matches = array();
  5. switch($argv[1]) {
  6. case 'album':
  7. $pattern = '~"album".*?"(.*?)".*~s';
  8. break;
  9. case 'title':
  10. $pattern = '~"title".*?"(.*?)".*~s';
  11. break;
  12. case 'artist':
  13. $pattern = '~"artist".*?"(.*?)".*~s';
  14. break;
  15. default:
  16. exit;
  17. }
  18. preg_match($pattern, $song, $matches);
  19. if($matches) {
  20. echo $matches[1];
  21. }
  22. ?>