#!/usr/bin/perl # ---------- announceroK ---------- # Version 0.5 # Updated: 6 March 2006 # Created by Jen (jen@caffeinated-dreams.net) # # Display what's playing with an easy to read announce script # and control basic functions of amaroK through XChat. Make # sure to read the CONFIGURABLE VARIABLES section starting at # line 46 for options/customization. # # ---------- Commands ---------- # /amarok .......... launches amaroK, will also bring it forward if it's already running # /arok ................. displays current track # /next .............. go to next track # /prev .............. go to previous track # /stop ............. stop amarok # /play ............. play track # /pause .......... pause track # /resume ........ resume paused track # /mute ........... mute song # /voldown ...... turn down the volume by 4% # /volup .......... turn up the volume 4% # # TODO Working on a way to seek through a song and adjust volume by user-input integers (ex /vol +80) # ----------------------------------------- IRC::print "\cC2\cBannounceroK has loaded successfully.\003"; IRC::print "\cC2/announcerok for list of commands."; Xchat::register("announceroK", "0.5","Display what's on amaroK"); Xchat::hook_command("announcerok", "announcerok"); Xchat::hook_command("arok", "amarok"); Xchat::hook_command("amarok","amarok_start"); Xchat::hook_command("next", "amarok_next"); Xchat::hook_command("prev", "amarok_prev"); Xchat::hook_command("stop", "amarok_stop"); Xchat::hook_command("play", "amarok_play"); Xchat::hook_command("pause", "amarok_pause"); Xchat::hook_command("resume","amarok_resume"); Xchat::hook_command("mute", "amarok_mute"); Xchat::hook_command("voldown","amarok_voldown"); Xchat::hook_command("volup","amarok_volup"); # ---------- CONFIGURABLE VARIABLES ---------- # Here you can easily customize announceroK. # The $mode is how it'll output into Xchat, put either "action" or "message". # The $theme is if you want colors or bold. Use "color" or "bold". $mode = "action"; $theme = "bold"; # DO NOT EDIT ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING. KTHX. sub announcerok { IRC::print("\cC2\cBCommands are:"); IRC::print("\cC2/amarok\003 \cC14to launch amaroK"); IRC::print("\cC2/arok\003 \cC14to display current song"); IRC::print("\cC2/next\003 \cC14 goes to next song"); IRC::print("\cC2/prev\003 \cC14goes to previous song"); IRC::print("\cC2/stop\003 \cC14to stop amarok"); IRC::print("\cC2/play \cC14to play song"); IRC::print("\cC2/pause \cC14pauses song"); IRC::print("\cC2/resume \cC14resumes a paused track"); IRC::print("\cC2/mute \cC14to mute song"); IRC::print("\cC2/voldown \cC14turns volume down by 4%"); IRC::print("\cC2/volup \cC14turns volume up by 4%"); } sub amarok { chomp($isplaying = `dcop --no-user-time amarok default isPlaying`); if($isplaying eq "true") { chomp($title = `dcop --no-user-time amarok default title`); # Displays song title chomp($artist = `dcop --no-user-time amarok default artist`); # Displays song artist chomp($album = `dcop --no-user-time amarok default album`); # Displays album if($album eq "") { $albumstr = "n/a"; } else { $albumstr = $album } chomp($timenow = `dcop --no-user-time amarok default currentTime`); # Displays current position in song in minutes chomp($timetotal =`dcop --no-user-time amarok default totalTime`); # Displays length of song in minutes if($genre eq "") { $genrestr = "n/a"; } else { $genrestr = $genre; } #OUTPUT if ($mode eq "message") { if ($theme eq "color") { Xchat::command("say Now playing \0032$title\003 by\003 \0032$artist\003 (\0032$albumstr\003) [$timenow/$timetotal]"); } elsif ($theme eq "bold") { Xchat::command("say Now playing \cB$title\002 by \cB$artist\002 (\cB$albumstr\002) [$timenow/$timetotal]"); } else { IRC::print("\cC5Invalid Theme Selected:\003 \cB$theme\002, Please use 'color' or 'bold'."); } } elsif ($mode eq "action") { if ($theme eq "color") { Xchat::command("me is listening to \0032$title\003 by \0032$artist\003 from the album \0032$albumstr\003. ($timenow/$timetotal)"); } elsif ($theme eq "bold") { Xchat::command("me is listening to \cB$title\002 by \cB$artist\002 from the album \cB$albumstr\002. ($timenow/$timetotal)"); } else { IRC::print("\cC5Invalid Theme Selected:\003 \cB$theme\002, Please use 'color' or 'bold'."); } } else { IRC::print("\cC5Inavlid Mode Selected: $mode\003, Please use 'action' or 'message'."); } } else { IRC::print "\cC5\cBNo song is currently playing!\003"; } } # Player Controls via XChat sub amarok_start { # Starts amaroK $start = `amarok`; IRC::print("\cC2amaroK\003 has started! :)"); return Xchat::EAT_ALL; } sub amarok_next { # Goes to next song in playlist. $next = `amarok -next`; $next_show = `dcop --no-user-time amarok default nowPlaying`; IRC::print("\cC2[amaroK]\003 Going to your next song: $next_show"); return Xchat::EAT_ALL; } sub amarok_prev { # Goes to previous song in playlist. $prev = `amarok -previous`; $prev_show = `dcop --no-user-time amarok default nowPlaying`; IRC::print("\cC2[amaroK]\003 Going to your previous song: $prev_show"); return Xchat::EAT_ALL; } sub amarok_stop { # Stops song. $stop = `amarok -stop`; IRC::print("\cC2[amaroK]\003 Stopping amaroK"); return Xchat::EAT_ALL; } sub amarok_play { # Plays song. $play = `amarok -play`; $play_show = `dcop amarok default nowPlaying`; IRC::print("\cC2[amaroK]\003 Playing: $play_show"); return Xchat::EAT_ALL; } sub amarok_pause { # Pauses song. $pause = `amarok -pause`; IRC::print("\cC2[amaroK]\003 Pausing..."); return Xchat::EAT_ALL; } sub amarok_resume { # Resumes a paused song. $resume = `dcop --no-user-time amarok default playPause`; IRC::print ("\cC2[amaroK]\003 Resuming song..."); return Xchat::EAT_ALL; } sub amarok_mute { # Mutes song. $mute = `dcop --no-user-time amarok default mute`; IRC::print("\cC2[amaroK]\003 Muting"); return Xchat::EAT_ALL; } sub amarok_voldown { # Turns volume down by 4% $voldown = `dcop --no-user-time amarok default volumeDown`; IRC::print("\cC2[amaroK]\003 Turning down the volume"); return Xchat::EAT_ALL; } sub amarok_volup { # Turns volume up by 4% $volup = `dcop --no-user-time amarok default volumeUp`; IRC::print("\cC2[amaroK]\003 Turning up the volume"); return Xchat::EAT_ALL; }