#!/usr/bin/perl # ---------- announceroK ---------- # Version 0.4 # Updated: 13 January 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. More # features are on the way, as I think of them. # # ---------- Commands ---------- # /amarok .......... launches amaroK, will also bring it forward if it's also running # /np ................. 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.4","Display what's on amaroK"); Xchat::hook_command("announcerok", "announcerok"); Xchat::hook_command("np", "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"); sub announcerok { IRC::print("\cC2\cBCommands are:"); IRC::print("\cC2/amarok\003 \cC14to launch amaroK"); IRC::print("\cC2/np\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($playing = `dcop --no-user-time amarok default nowPlaying`); # Displays "Artist - Title", this isn't being used right now... 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 chomp($version = `amarok -version | grep amaro`); # Displays amaroK version chomp($genre = `dcop --no-user-time amarok default genre`); # Displays genre if($genre eq "") { $genrestr = "n/a"; } else { $genrestr = $genre; } chomp($bitrate = `dcop --no-user-time amarok default bitrate`); # Displays bitrate # # These are the different ways you can have it display in a channel, choose only ONE at a time by leaving it uncommented. # # BLOATED Action announce! SLOW! Shows much useless crap (bitrate/genre/version)! #Xchat::command("me is listening to \0032$title\003 by \0032$artist\003 from the album \0032$albumstr\003. ($timenow/$timetotal) [] ($genrestr) ($bitrate) (\0032$version\003)"); # Normal Action announce. Xchat::command("me is listening to \0032$title\003 by \0032$artist\003 from the album \0032$albumstr\003. ($timenow/$timetotal)"); # Message announce. #Xchat::command("say Now playing \0032$title\003 by\003 \0032$artist\003 ($timenow/$timetotal)"); # Simple action announce. #Xchat::command("me is listening to \0032$playing\003 ($timetotal)"); # Simple message announce. #Xchat::command("say Now Playing \0032$playing\003 ($timetotal)"); } else { IRC::print "\cC2\cBNo song is currently playing!\003"; } } # Player Controls via XChat sub amarok_start { # Starts amaroK $start = `amarok`; IRC::print("\cC2amaroK has started! :)"); } sub amarok_next { # Goes to next song in playlist. $next = `amarok -next`; IRC::print("\cC2[amaroK] Going to your next song..."); } sub amarok_prev { # Goes to previous song in playlist. $prev = `amarok -previous`; IRC::print("\cC2[amaroK] Going to your previous song..."); } sub amarok_stop { # Stops song. $stop = `amarok -stop`; IRC::print("\cC2[amaroK] Stopping amaroK"); } sub amarok_play { # Plays song. $play = `amarok -play`; IRC::print("\cC2[amaroK] Playing"); } sub amarok_pause { # Pauses song. $pause = `amarok -pause`; IRC::print("\cC2[amaroK] Pausing..."); } sub amarok_resume { # Resumes a paused song. $resume = `dcop --no-user-time amarok default playPause`; IRC::print ("\cC2[amaroK] Resuming song..."); } sub amarok_mute { # Mutes song. $mute = `dcop --no-user-time amarok default mute`; IRC::print("\cC2[amaroK] Muting"); } sub amarok_voldown { # Turns volume down by 4% $voldown = `dcop --no-user-time amarok default volumeDown`; IRC::print("\cC2[amaroK] Turning down the volume"); } sub amarok_volup { # Turns volume up by 4% $volup = `dcop --no-user-time amarok default volumeUp`; IRC::print("\cC2[amaroK] Turning up the volume"); }