Created
August 19, 2014 22:07
-
-
Save massa/079eb7adc7621fb39435 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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