Skip to content

Instantly share code, notes, and snippets.

@massa
Created August 19, 2014 22:07
Show Gist options
  • Save massa/079eb7adc7621fb39435 to your computer and use it in GitHub Desktop.
Save massa/079eb7adc7621fb39435 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
# (C) Humberto Massa 2008
# available to anyone under the terms of any of the following licenses,
# at recipient's will: GNU GPLv2, GNU GPLv3, CC-GPLv2, CC-SAv3.0
use massa;
sub adds {
open my $f, '-|', 'qdbus org.kde.klipper /klipper getClipboardHistoryMenu' or return;
sort map { chomp; $_ } grep { /torrent$|^magnet:/ } <$f>
}
sub args {
my @args = ([]);
for( @_ ) {
when( '--' ) {
push @args, [] if scalar @{$args[$#args]}
}
push @{$args[$#args]}, $_
}
pop @args unless scalar @{$args[$#args]};
@args
}
sub xmsn {
system 'transmission-remote' => 'xmsn:9091' => -n => 'transmission:transmission' => @_
}
if( @ARGV ) {
for( args @ARGV ) {
xmsn -l => ();
xmsn @$_
}
} else {
xmsn -a => $_ for adds
}
xmsn -l => ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment