Created
August 1, 2010 17:57
-
-
Save goerz/503579 to your computer and use it in GitHub Desktop.
filter.pl: Filter the contents of the KDE clipboard through any pipe
This file contains 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/perl -w | |
use strict; | |
my $historyfile = glob '~/.filter.pl.last'; | |
my $command = ""; | |
system("touch $historyfile"); | |
open(HIST, "$historyfile") or die "Can't open file: $!"; | |
$command = <HIST>; | |
chomp $command; | |
close HIST; | |
$command = readpipe('kdialog --title "filter.pl" -inputbox "Insert command" "'."$command".'"'); | |
# delete everything after the first newline | |
if ($command =~ m/(^.*)\n/){ | |
$command = $1; | |
} | |
unless ($command eq ""){ | |
system('dcop klipper klipper setClipboardContents "`dcop klipper klipper getClipboardContents | '."$command".'`"'); | |
open(HIST, ">$historyfile") or die "Can't open file: $!"; | |
print HIST $command; | |
close HIST; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment