scripts

misc scripts and tools
git clone git://git.2f30.org/scripts.git
Log | Files | Refs

commit 1b8ea35f7d6c915f8fcff1176c3a7f729da4de9f
parent c6ec7a35bee2d0cccd35d36dd6f8712d00335907
Author: haris <haris@metal.lan>
Date:   Thu Jun 20 18:06:19 +0300

Add epubtohtml pastie

Diffstat:
epubtohtml.pl | 26++++++++++++++++++++++++++
pastie.pl | 44++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 70 insertions(+), 0 deletions(-)
diff --git a/epubtohtml.pl b/epubtohtml.pl @@ -0,0 +1,26 @@ +#!/usr/bin/perl -w + +# General use: unzip your file, head over to the directory where the *.html +# files exist and just execute the script. You'll find a nice "Previous/Next +# Page" link at the bottom of each page + +use strict; +use 5.012; +use Cwd; + +my $dir = getcwd; +my $filenames; +my @filenames = glob "$dir/*.html"; + +my $i = 0; + +for ($i = 0; $i < $#filenames; $i++) { + + # print "Previous: $filenames[$i-1]\n"; + # print "Current $filenames[$i]\n"; + # print "Next $filenames[$i+1]\n"; + open my $fh, '>>', $filenames[$i] or die "Cound not open $filenames[$i]: $!"; + print $fh "<a href=\"$filenames[$i-1]\">Previous Page</a> <a href=\"$filenames[$i+1]\">Next Page</a>"; + close $fh; + +} diff --git a/pastie.pl b/pastie.pl @@ -0,0 +1,44 @@ +use strict; + +my $SCRIPT_NAME = "pastie"; + +weechat::register("pastie", "cipher <haris\@2f30.org>", "0.1", "Public Domain", "Paste output", "", ""); +weechat::hook_command("pastie", "Just select your text with the cursor, and \"/pastie\" in your window. +By default, it uses \"xclip -o\" to output X selection. + +If you want another application for output, you can set it for example with: + + /set plugins.var.perl.pastie.ext_command \"xsel -o\" + +Replace \"xsel -o\" with your program of choice. +----------------------------------------------", "", "", "", "pastie", ""); + +my $pastie_command; + +init_config(); + +sub init_config { + my %options = ( + "ext_command" => "xclip -o", + ); + foreach my $option (keys %options) { + weechat::config_set_plugin($option, $options{$option}) unless weechat::config_is_set_plugin($option); + } +} + +sub pastie { + my ($data, $command, $return_code, $out, $err) = @_; + my $buffer = $data; + $pastie_command = weechat::config_get_plugin("ext_command"); + my @output = `$pastie_command`; + + weechat::command($buffer, ",--<--"); + + foreach my $output (@output) { + $output =~ s/(.*?)\t/ /g; + weechat::command($buffer, "| $output"); + } + + weechat::command($buffer, "`-->--"); + return weechat::WEECHAT_RC_OK; +}