tSome updates. - scripts - random scripts [h|git clone https://git.parazyd.org/scripts|URL:https://git.parazyd.org/scripts|server|port] [1|Log|/git/scripts/log.gph|server|port] [1|Files|/git/scripts/files.gph|server|port] [1|Refs|/git/scripts/refs.gph|server|port] --- [1|commit 933852ecce46bffbae79861a41c6213a2440105e|/git/scripts/commit/933852ecce46bffbae79861a41c6213a2440105e.gph|server|port] [1|parent af0786393d19457ffe414f3f3c75315c723c96d3|/git/scripts/commit/af0786393d19457ffe414f3f3c75315c723c96d3.gph|server|port] [h|Author: parazyd |URL:mailto:parazyd@dyne.org|server|port] Date: Mon, 11 May 2020 23:16:29 +0200 Some updates. Diffstat: M autoup | 6 +++++- M chandl | 10 +++++++++- M ff | 9 +++++++-- A mladmin | 33 +++++++++++++++++++++++++++++++ M radio | 71 ++++++++++++++----------------- M takeoffdir | 4 ++-- A torrentwatch | 6 ++++++ M update-gits | 23 ++++++++++++++++++++--- D vipe | 74 ------------------------------- M xkcd | 35 ++++++++++++++----------------- 10 files changed, 131 insertions(+), 140 deletions(-) --- [1|diff --git a/autoup b/autoup|/git/scripts/file/autoup.gph|server|port] t@@ -16,6 +16,10 @@ case "$1" in shift webdir=tmp/photo ;; +-t) + shift + webdir=tmp + ;; esac t@@ -25,7 +29,7 @@ filename=$(basename $1) case "$filename" in *_scrot.*|mpv-shot*.*) webdir=tmp/screenshots - num=$(echo $(lynx -dump https://$server/pub/tmp/screenshots \ + num=$(echo $(lynx -dump http://$server/pub/tmp/screenshots \ | tail -n1 | tr -d '[a-z]./:' | awk '{print $2}') + 1 | bc) if [ "$num" -lt 100 ]; then num="00$num" [1|diff --git a/chandl b/chandl|/git/scripts/file/chandl.gph|server|port] t@@ -1,7 +1,8 @@ #!/bin/sh case "$1" in -*boards.4chan.org*) +*4chan.org*) + #imgs='is2.4chan.org' imgs='i.4cdn.org' ;; *8ch.net*) t@@ -13,6 +14,12 @@ case "$1" in *arisuchan.jp*) imgs='.* https:\/\/arisuchan.jp\/.*/src\/' ;; +*enrive.org*) + imgs='enrive.org\/media\/' + ;; +*endchan.xyz*) + imgs='endchan.xyz\/\.media\/' + ;; *) echo 'Unsupported URL.' exit 1 t@@ -20,4 +27,5 @@ case "$1" in esac lynx -dump "$1" | awk '/^References/,EOF' | awk '/'"$imgs"'/ {print $2}' | + grep -v player | sort | uniq | while read foo ; do wget -c "$foo" ; done [1|diff --git a/ff b/ff|/git/scripts/file/ff.gph|server|port] t@@ -1,4 +1,5 @@ #!/bin/sh + case "$(basename $0)" in cb) xhost si:localuser:ff && \ t@@ -6,7 +7,11 @@ cb) ;; ff) - xhost si:localuser:ff && \ - exec sudo -u ff /usr/bin/firefox -no-remote -ProfileManager $@ + xhost si:localuser:ff + if [ -z "$1" ]; then + exec sudo -u ff /usr/bin/firefox --ProfileManager + else + sudo -u ff /usr/bin/firefox $@ + fi ;; esac [1|diff --git a/mladmin b/mladmin|/git/scripts/file/mladmin.gph|server|port] t@@ -0,0 +1,33 @@ +#!/bin/sh + +mailman_url="https://mailinglists.dyne.org/cgi-bin/mailman/admin" + +listname="$1" + +if [ "$listname" = "" ]; then + echo "Usage: $(basename "$0") listname" + pass ls ml + exit 1 +fi + +pw="$(pass show ml/$listname)" +tmp="$(mktemp)" + +cat < "$tmp" + + + Mailman admin for $listname + + +

Go to mailman admin: $listname

+
+ + +
+ + +EOF + +surf "$tmp" + +(sleep 10; rm -f "$tmp") & [1|diff --git a/radio b/radio|/git/scripts/file/radio.gph|server|port] t@@ -1,45 +1,40 @@ -#!/bin/sh +#!/usr/bin/env python3 -usage() { - cat </dev/null } done [1|diff --git a/vipe b/vipe|/git/scripts/file/vipe.gph|server|port] t@@ -1,74 +0,0 @@ -#!/usr/bin/perl - -=head1 NAME - -vipe - edit pipe - -=head1 SYNOPSIS - -command1 | vipe | command2 - -=head1 DESCRIPTION - -vipe allows you to run your editor in the middle of a unix pipeline and -edit the data that is being piped between programs. Your editor will -have the full data being piped from command1 loaded into it, and when you -close it, that data will be piped into command2. - -=head1 ENVIRONMENT VARIABLES - -=over 4 - -=item EDITOR - -Editor to use. - -=item VISUAL - -Also supported to determine what editor to use. - -=back - -=head1 AUTHOR - -Copyright 2006 by Joey Hess - -Licensed under the GNU GPL. - -=cut - -use warnings; -use strict; -use File::Temp q{tempfile}; - -$/=undef; - -my ($fh, $tmp)=tempfile(); -die "cannot create tempfile" unless $fh; -print ($fh ) || die "write temp: $!"; -close $fh; -close STDIN; -open(STDIN, "&STDOUT") || die "save stdout: $!"; -close STDOUT; -open(STDOUT, ">/dev/tty") || die "reopen stdout: $!"; - -my @editor="vi"; -if (-x "/usr/bin/editor") { - @editor="/usr/bin/editor"; -} -if (exists $ENV{EDITOR}) { - @editor=split(' ', $ENV{EDITOR}); -} -if (exists $ENV{VISUAL}) { - @editor=split(' ', $ENV{VISUAL}); -} -my $ret=system(@editor, $tmp); -if ($ret != 0) { - die "@editor exited nonzero, aborting\n"; -} - -open (IN, $tmp) || die "$0: cannot read $tmp: $!\n"; -print (OUT ) || die "write failure: $!"; -close IN; -unlink($tmp); [1|diff --git a/xkcd b/xkcd|/git/scripts/file/xkcd.gph|server|port] t@@ -2,31 +2,28 @@ # # grab a random xkcd comic, append title and alttext, and save to a dir +from os import environ +from re import search +from random import randrange + from PIL import Image, ImageDraw, ImageFont from requests import get -from random import randrange -from textwrap import wrap -from json import loads -from re import search -import os -download_dir = os.environ['HOME']+'/xkcd/' -title_fontsize = 28 -alt_fontsize = 18 -line_offset = 10 +DOWNLOAD_DIR = environ['HOME']+'/xkcd/' +TITLE_FONTSIZE = 28 +ALT_FONTSIZE = 18 +LINE_OFFSET = 10 -def add_text(image, title, alt, tfont=download_dir+'xkcd.ttf', - afont=download_dir+'xkcd.ttf'): +def add_text(image, title, alt, tfont=DOWNLOAD_DIR+'xkcd.ttf', + afont=DOWNLOAD_DIR+'xkcd.ttf'): try: img = Image.open(image) except OSError: return - tfont = ImageFont.truetype(tfont, title_fontsize) - afont = ImageFont.truetype(afont, alt_fontsize) + tfont = ImageFont.truetype(tfont, TITLE_FONTSIZE) + afont = ImageFont.truetype(afont, ALT_FONTSIZE) - twidth, theight = tfont.getsize(title) - awidth, aheight = afont.getsize(alt) line_padding = 5 draw = ImageDraw.Draw(img) lines = text_wrap(tfont, title, img.size[0]) t@@ -65,8 +62,8 @@ def add_text(image, title, alt, tfont=download_dir+'xkcd.ttf', def text_wrap(font, text, image_width, i=0): lines = [[]] text = text.split(" ") - while len(text) > 0: - while len(text) > 0 \ + while text: + while text \ and font.getsize(" ".join(lines[i]))[0] < image_width: if font.getsize(text[0]+" "+" ".join(lines[i]))[0] > image_width * 0.95: if len(lines[i]) == 0: t@@ -107,13 +104,13 @@ def main(): image = num+search("\.([a-z])+$", info['img']).group() - with open(download_dir+image, 'wb') as image_file: + with open(DOWNLOAD_DIR+image, 'wb') as image_file: req = get(info['img'], stream=True) for block in req.iter_content(1024): if block: image_file.write(block) image_file.flush() if not search("\.gif", info['img']): - add_text(download_dir+image, title, alt) + add_text(DOWNLOAD_DIR+image, title, alt) main()