From: Bruno Cattáneo Date: Sat, 30 Dec 2017 23:33:13 +0000 (-0300) Subject: Add deadbeef.pl X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=0541950dd437469dab2b607e4ea14cd106acd12b;p=irssi-scripts.irssi.org.git Add deadbeef.pl --- diff --git a/scripts/deadbeef.pl b/scripts/deadbeef.pl new file mode 100644 index 0000000..f215f60 --- /dev/null +++ b/scripts/deadbeef.pl @@ -0,0 +1,102 @@ +# +# 2017-12-30 bcattaneo: +# - initial release +# + +use Irssi; +use Irssi::Irc; +use strict; +use vars qw($VERSION %IRSSI); + +# +# List of commands: +# /np - now playing +# /ddplay - Start playback +# /ddstop - Stop playback +# /ddpause - Pause playback +# /ddnext - Next song in playlist +# /ddprev - Previous song in playlist +# /ddrandom - Random song in playlist +# +# Settings: +# /set deadbeef_format [Formatting syntax for "now playing" command] +# For more info, see https://github.com/DeaDBeeF-Player/deadbeef/wiki/Title-formatting +# + +our $VERSION = '1.0.0'; +our %IRSSI = ( + authors => 'bcattaneo', + contact => 'c@ttaneo.uy', + name => 'deadbeef', + url => 'http://github.com/bcattaneo', + description => 'deadbeef control and now playing script', + license => 'Public Domain', + #changed => "2017-12-30", +); + +Irssi::settings_add_str('deadbeef', 'deadbeef_format' => '%a - %t'); + +my $deadbeef = "deadbeef.pl"; + +######################### +## Now playing command ## +######################### +sub now_playing { + my ($data, $server, $witem) = @_; + my $format = Irssi::settings_get_str('deadbeef_format'); + my $output = (split("\n",`deadbeef --nowplaying "$format" 2>&1`))[-1]; + + if ($output ne "nothing" ) + { + if ($witem && ($witem->{type} eq "CHANNEL" || $witem->{type} eq "QUERY")) + { + $witem->command("me nowplaying: $output") + } + else + { + Irssi::print("%_$deadbeef%_ - Not a channel/query!"); + } + } + else + { + Irssi::print("%_$deadbeef%_ - Play something!"); + } +} + +############## +## Controls ## +############## +sub play { + system("deadbeef --play &> /dev/null"); +} + +sub stop { + system("deadbeef --stop &> /dev/null"); +} + +sub pause { + system("deadbeef --pause &> /dev/null"); +} + +sub next { + system("deadbeef --next &> /dev/null"); +} + +sub prev { + system("deadbeef --prev &> /dev/null"); +} + +sub random { + system("deadbeef --prev &> /dev/null"); +} + +##################### +## Command binding ## +##################### +Irssi::command_bind('np', 'now_playing'); +Irssi::command_bind('dbplay', 'play'); +Irssi::command_bind('dbstop', 'stop'); +Irssi::command_bind('dbpause', 'pause'); +Irssi::command_bind('dbnext', 'next'); +Irssi::command_bind('dbprev', 'prev'); +Irssi::command_bind('dbrandom', 'random');