test

Plain text code posted
created at 01 May 11:46

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl -w

Xchat::register("Rhythmbox Now Playing script for XChat", "0.1", "Rhythmbox Now Playing script for XChat" , "");
Xchat::hook_command("np", "nowPlaying");

sub nowPlaying
{
  # Check if a rhythmbox process exists.  
  if (`ps -C rhythmbox` =~ /rhythmbox/) {
    # Check if rhythmbox streams music
    $title = `rhythmbox-client --print-playing-format %st`;
    if (length $title > 1) {
      $title = `rhythmbox-client --print-playing-format %st\\ -\\ %tt`;
    } else {
      $title = `rhythmbox-client --print-playing-format %ta\\ -\\ %tt`;
    }
    
    # Send out now playing line
    chop $title;
    Xchat::command("me is listening to: " . $title);
  } else {
    Xchat::print("Rhythmbox is not running.");
  }
}
732 Bytes in 2 ms with coderay