]> Sergey Matveev's repositories - dotfiles.git/commitdiff
~/bin contents
authorSergey Matveev <stargrave@stargrave.org>
Wed, 25 Mar 2020 04:14:47 +0000 (07:14 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 25 Mar 2020 04:21:42 +0000 (07:21 +0300)
38 files changed:
bin/bin/bitlbee.sh [new file with mode: 0755]
bin/bin/cfind [new file with mode: 0755]
bin/bin/cleanup.sh [new file with mode: 0755]
bin/bin/cp-sorted.sh [new file with mode: 0755]
bin/bin/cueparser.sh [new file with mode: 0755]
bin/bin/der2pem.sh [new file with mode: 0755]
bin/bin/dwm-menu [new file with mode: 0755]
bin/bin/dwm-term [new file with mode: 0755]
bin/bin/dwm-term-session [new file with mode: 0755]
bin/bin/exifrm.sh [new file with mode: 0755]
bin/bin/mail_dup_hdrs_remote.py [new file with mode: 0755]
bin/bin/mencoder.sh [new file with mode: 0755]
bin/bin/mfind [new file with mode: 0755]
bin/bin/mirror-page-warc.sh [new file with mode: 0755]
bin/bin/mirror-page.sh [new file with mode: 0755]
bin/bin/mirror-site-warc.sh [new file with mode: 0755]
bin/bin/mirror-site.sh [new file with mode: 0755]
bin/bin/mkvclean.sh [new file with mode: 0755]
bin/bin/mplayeraf.sh [new file with mode: 0755]
bin/bin/mplayervo.sh [new file with mode: 0755]
bin/bin/mplayervoaf.sh [new file with mode: 0755]
bin/bin/mv-sha.sh [new file with mode: 0755]
bin/bin/mylock [new file with mode: 0755]
bin/bin/pdfa.sh [new file with mode: 0755]
bin/bin/pem2der.sh [new file with mode: 0755]
bin/bin/plantuml [new file with mode: 0755]
bin/bin/pngcrush.sh [new file with mode: 0755]
bin/bin/ps2pdf.sh [new file with mode: 0755]
bin/bin/rem [new file with mode: 0755]
bin/bin/start-im [new file with mode: 0755]
bin/bin/start-x [new file with mode: 0755]
bin/bin/texinavfix.pl [new file with mode: 0755]
bin/bin/tmux-common.sh [new file with mode: 0644]
bin/bin/xr-external [new file with mode: 0755]
bin/bin/xr-internal [new file with mode: 0755]
bin/bin/ytdl [new file with mode: 0755]
bin/bin/ytdlb [new file with mode: 0755]
bin/bin/zstd-gut.sh [new file with mode: 0755]

diff --git a/bin/bin/bitlbee.sh b/bin/bin/bitlbee.sh
new file mode 100755 (executable)
index 0000000..c149a32
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+/usr/local/sbin/bitlbee -c ~/.bitlbee.conf
diff --git a/bin/bin/cfind b/bin/bin/cfind
new file mode 100755 (executable)
index 0000000..0ed88f2
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+mu cfind --format=mutt-alias $1 | sed -n 's/alias [^ ]* \(.*\)$/\1/p'
diff --git a/bin/bin/cleanup.sh b/bin/bin/cleanup.sh
new file mode 100755 (executable)
index 0000000..e52613f
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+rm -fr \
+    ~/.bash_history \
+    ~/.cache \
+    ~/.config \
+    ~/.dbus \
+    ~/.dvdcss \
+    ~/.fltk \
+    ~/.gconf* \
+    ~/.gegl* \
+    ~/.gnome2* \
+    ~/.gnuplot* \
+    ~/.gstreamer* \
+    ~/.gvfs* \
+    ~/.java* \
+    ~/.kde* \
+    ~/.libreoffice \
+    ~/.links \
+    ~/.local* \
+    ~/.minio \
+    ~/.pki* \
+    ~/.pulse* \
+    ~/.pylint.d \
+    ~/.python_history \
+    ~/.sqlite_history \
+    ~/.thumbnails \
+    ~/.viminfo \
+    ~/.w3m \
+    ~/.zcalc_history \
+    ~/xombrero.core \
+    ~/zathura.core
diff --git a/bin/bin/cp-sorted.sh b/bin/bin/cp-sorted.sh
new file mode 100755 (executable)
index 0000000..1ae6eba
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh -x
+
+find "$1" -type f | sort | while read ent ; do tar cf - "$ent" | tar xvfC - "$2" ; sync ; done
diff --git a/bin/bin/cueparser.sh b/bin/bin/cueparser.sh
new file mode 100755 (executable)
index 0000000..546b47d
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+c=1
+sed -n 's/^  *TITLE .\(.*\)".*$/\1/p' < $1 | while read trackname; do
+       v=`printf "%02d\n" $c`
+       echo mv split-track$v.flac $v.\"$trackname\".flac
+       c=$(( $c + 1 ))
+done
diff --git a/bin/bin/der2pem.sh b/bin/bin/der2pem.sh
new file mode 100755 (executable)
index 0000000..a97489d
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+openssl x509 -inform DER -outform PEM -in "$1" -out $(dirname "$1")/"$(basename "$1" .cer)".pem
diff --git a/bin/bin/dwm-menu b/bin/bin/dwm-menu
new file mode 100755 (executable)
index 0000000..68556ac
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+DMENU=/home/stargrave/src/suckless/dmenu/dmenu
+STEST=/home/stargrave/src/suckless/dmenu/stest
+
+cache=/tmp/.dmenu_cache
+export PATH="/usr/local/bin:/usr/bin:/bin:/usr/games:/home/stargrave/bin"
+(
+       IFS=:
+       if $STEST -dqr -n "$cache" $PATH; then
+               $STEST -flx $PATH | sort -u | tee "$cache" | $DMENU "$@"
+       else
+               $DMENU "$@" < "$cache"
+       fi
+) | /bin/sh &
diff --git a/bin/bin/dwm-term b/bin/bin/dwm-term
new file mode 100755 (executable)
index 0000000..3e9e63b
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+[ -n "$CMD" ] || CMD=tmux
+[ -z "$CMDTITLE" ] || CMDTITLE="-t $CMDTITLE"
+
+exec $HOME/bin/st $@ $CMDTITLE -e $CMD 2>/dev/null
diff --git a/bin/bin/dwm-term-session b/bin/bin/dwm-term-session
new file mode 100755 (executable)
index 0000000..2c70ac5
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+CMD="tmux attach-session -t $@" $HOME/bin/dwm-term &
diff --git a/bin/bin/exifrm.sh b/bin/bin/exifrm.sh
new file mode 100755 (executable)
index 0000000..0474704
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exiftool -all= -overwrite_original $@
diff --git a/bin/bin/mail_dup_hdrs_remote.py b/bin/bin/mail_dup_hdrs_remote.py
new file mode 100755 (executable)
index 0000000..669d8b4
--- /dev/null
@@ -0,0 +1,34 @@
+#!/usr/bin/env python3.6
+
+import sys
+
+fn = sys.argv[1]
+out = sys.argv[2]
+with open(fn, "rb") as fd:
+    lines = fd.read().split(b"\n")
+
+def dup(lines, what):
+    idx = []
+    met = False
+    for i, line in enumerate(lines):
+        if line == "":
+            break
+        if met:
+            if line.startswith(b" "):
+                idx.append(i)
+                continue
+            else:
+                met = False
+        if line.startswith(what):
+            if len(idx) == 0:
+                idx.append(i)
+                met = True
+            else:
+                return [l for n, l in enumerate(lines) if n not in idx]
+    return lines
+
+lines = dup(lines, b"To")
+lines = dup(lines, b"From")
+lines = dup(lines, b"Subject")
+with open(out, "wb") as fd:
+    fd.write(b"\n".join(lines))
diff --git a/bin/bin/mencoder.sh b/bin/bin/mencoder.sh
new file mode 100755 (executable)
index 0000000..7768a95
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh -ex
+
+mencoder -mc 0 -noskip -oac pcm -ovc copy -o "$1".mkv "$1"
+mplayer -noframedrop -ao pcm:fast:file="$1".wav -novideo "$1".mkv
+sox "$1".wav -c 1 -r 44100 -e signed-integer -b 16 "$1".wav.wav
+mv "$1".wav.wav "$1".wav
+normalize --peak "$1".wav
+opusenc "$1".wav "$1".opus
+rm "$1".wav
+opts="mbd=2:trell:dia=6:predia=6:cmp=6:subcmp=6:preme=2:vb_strategy=2:v4mv:cbp:mv0:qns=2"
+opts="mbd=2:trell:dia=6:predia=6:cmp=6:subcmp=6:preme=2:vb_strategy=2:v4mv"
+for vpass in 1 2; do
+    mencoder \
+        -mc 0 -noskip \
+        -nosound \
+        -passlogfile "$1".log \
+        -ovc lavc \
+        -lavcopts vcodec=libvpx:$opts:autoaspect:vpass=$vpass \
+        -vf scale=960:540 \
+        -o "$1".vp8 "$1".mkv
+done
+mkvmerge --webm -o "$1".webm "$1".opus "$1".vp8
+rm "$1".opus "$1".vp8 "$1".log "$1".mkv
diff --git a/bin/bin/mfind b/bin/bin/mfind
new file mode 100755 (executable)
index 0000000..24cbf3e
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+mu find --clearlinks --format=links --linksdir=$MAILDIR/search $@
diff --git a/bin/bin/mirror-page-warc.sh b/bin/bin/mirror-page-warc.sh
new file mode 100755 (executable)
index 0000000..f0c8183
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+mirror-page.sh "$1" \
+    --warc-file $name-$(date '+%Y%M%d%H%m%S') \
+    --no-warc-compression \
+    --no-warc-keep-log \
+    $@
diff --git a/bin/bin/mirror-page.sh b/bin/bin/mirror-page.sh
new file mode 100755 (executable)
index 0000000..9f5d613
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+user_agent="Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27"
+
+name=$1
+shift
+mkdir -p $name
+
+cd $name
+wget \
+    --page-requisites \
+    --convert-links \
+    --adjust-extension \
+    --restrict-file-names=ascii \
+    --span-hosts \
+    --random-wait \
+    --execute robots=off \
+    --user-agent "$user_agent" \
+    --reject '*.woff*,*.ttf,*.eot,*.js' \
+    --tries 10 \
+    $@
diff --git a/bin/bin/mirror-site-warc.sh b/bin/bin/mirror-site-warc.sh
new file mode 100755 (executable)
index 0000000..7808115
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+mirror-site.sh "$1" \
+    --warc-file $name-$(date '+%Y%M%d%H%m%S') \
+    --no-warc-compression \
+    --no-warc-keep-log \
+    $@
diff --git a/bin/bin/mirror-site.sh b/bin/bin/mirror-site.sh
new file mode 100755 (executable)
index 0000000..a5d83c6
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+user_agent="Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27"
+
+name=$1
+shift
+mkdir -p $name
+
+cd $name
+wget \
+    --page-requisites \
+    --convert-links \
+    --adjust-extension \
+    --restrict-file-names=ascii \
+    --span-hosts \
+    --random-wait \
+    --execute robots=off \
+    --recursive \
+    --timestamping \
+    -l inf \
+    --no-remove-listing \
+    --no-parent \
+    --user-agent "$user_agent" \
+    --reject '*.woff*,*.ttf,*.eot,*.js' \
+    --tries 10 \
+    $@
diff --git a/bin/bin/mkvclean.sh b/bin/bin/mkvclean.sh
new file mode 100755 (executable)
index 0000000..476283a
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+mkvpropedit \
+    --edit info \
+    --delete title \
+    --delete date \
+    --set muxing-application=- \
+    --set writing-application=- \
+    --chapters "" \
+    --tags all: $@
diff --git a/bin/bin/mplayeraf.sh b/bin/bin/mplayeraf.sh
new file mode 100755 (executable)
index 0000000..f33a70d
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+mplayer -af volnorm "$@"
diff --git a/bin/bin/mplayervo.sh b/bin/bin/mplayervo.sh
new file mode 100755 (executable)
index 0000000..3c81849
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+mplayer -vo vdpau "$@"
diff --git a/bin/bin/mplayervoaf.sh b/bin/bin/mplayervoaf.sh
new file mode 100755 (executable)
index 0000000..f2a6265
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+mplayer -vo vdpau -af volnorm "$@"
diff --git a/bin/bin/mv-sha.sh b/bin/bin/mv-sha.sh
new file mode 100755 (executable)
index 0000000..bf5cc5c
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+[ $# -eq 0 ] && fs="$(find . -maxdepth 1 -type f)" || fs="$@"
+for f in $fs ; do
+    mv -v "$f" $(sha1 -q "$f").${f##*.}
+done
diff --git a/bin/bin/mylock b/bin/bin/mylock
new file mode 100755 (executable)
index 0000000..e123f5b
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+xset dpms force off
+gpgconf --reload gpg-agent
+SSH_AUTH_SOCK=$HOME/.ssh/agent ssh-add -D
+slock
diff --git a/bin/bin/pdfa.sh b/bin/bin/pdfa.sh
new file mode 100755 (executable)
index 0000000..2081248
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+gs \
+    -dPDFA=1 \
+    -dBATCH \
+    -dNOPAUSE \
+    -sDEVICE=pdfwrite \
+    -sColorConversionStrategy=DeviceRGB \
+    -sOutputFile="$1".pdf "$1"
diff --git a/bin/bin/pem2der.sh b/bin/bin/pem2der.sh
new file mode 100755 (executable)
index 0000000..0e29baa
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+openssl x509 -inform PEM -outform DER -in "$1" -out $(dirname "$1")/"$(basename "$1" .pem)".cer
diff --git a/bin/bin/plantuml b/bin/bin/plantuml
new file mode 100755 (executable)
index 0000000..6f9d16f
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec java -jar $HOME/src/plantuml.jar $@
diff --git a/bin/bin/pngcrush.sh b/bin/bin/pngcrush.sh
new file mode 100755 (executable)
index 0000000..cc73d9b
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh -ex
+
+t=$(TMPDIR=. mktemp)
+pngcrush -rem alla -rem allb "$1" $t
+mv $t "$1"
diff --git a/bin/bin/ps2pdf.sh b/bin/bin/ps2pdf.sh
new file mode 100755 (executable)
index 0000000..7ffd44f
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+ps2pdf14 \
+    -dPDFSETTINGS=/prepress \
+    -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode \
+    -dAutoFilterGrayImages=false -dGrayImageFilter=/FlateEncode \
+    -dAutoFilterMonoImages=false -dMonoImageFilter=/CCITTFaxEncode \
+    -dCompressPages=true -dUseFlateCompression=true \
+    -dEmbedAllFonts=true -dSubsetFonts=false \
+    -dPreserveEPSInfo=true \
+    -dDoThumbnails=true $1 $2
diff --git a/bin/bin/rem b/bin/bin/rem
new file mode 100755 (executable)
index 0000000..4b7a0da
--- /dev/null
@@ -0,0 +1 @@
+remind -g ~/rem/index.rem
diff --git a/bin/bin/start-im b/bin/bin/start-im
new file mode 100755 (executable)
index 0000000..2e1a39a
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/zsh
+
+. $HOME/bin/tmux-common.sh
+
+$TMUX new-session -d -s im
+$TMUX rename-window -t im:1 "mattermost"
+$TMUX split-window -t im:1
+
+paste im:1.0 "~/work/matterircd/start.sh"
+sleep 1
+paste im:1.1 "irssi"
+$TMUX resize-pane -U -t im:1 15
+
+#$TMUX select-window -t root:1.0
+
+CMD="$TMUX attach-session -t im" CMDTITLE="Terminal8" $HOME/bin/dwm-term &
diff --git a/bin/bin/start-x b/bin/bin/start-x
new file mode 100755 (executable)
index 0000000..ca17aa2
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+rm .serverauth.* .Xauthority*
+exec startx
diff --git a/bin/bin/texinavfix.pl b/bin/bin/texinavfix.pl
new file mode 100755 (executable)
index 0000000..b82a85e
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+my %rels;
+my $header = 0;
+my $printed = 0;
+
+while(<STDIN>){
+    ($rels{$2} = $1) if /^<link href="([^#]*)[^"]*" rel="([^"]*)" title/;
+    if(/^<div class="header">$/){
+        print "$_<center><p>";
+        if(defined $rels{"prev"}){
+            print "<a href=\"$rels{'prev'}\">[&lt;&lt;&lt;]</a>";
+        };
+        if(defined $rels{"up"}){
+            print "<a href=\"$rels{'up'}\">[^^^]</a>";
+        };
+        if(defined $rels{"next"}){
+            print "<a href=\"$rels{'next'}\">[&gt;&gt;&gt;]</a>";
+        };
+        $header++;
+    };
+    if($header && /^<.div>$/){
+        print "</p></center>$_";
+        $header--;
+    };
+    next if $header;
+    print;
+};
diff --git a/bin/bin/tmux-common.sh b/bin/bin/tmux-common.sh
new file mode 100644 (file)
index 0000000..35de255
--- /dev/null
@@ -0,0 +1,11 @@
+TMUX=/usr/local/bin/tmux
+
+paste()
+{
+    local pane="$1"
+    local cmd="$2"
+    $TMUX set-buffer "$cmd"
+    $TMUX paste-buffer -t "$pane"
+    $TMUX delete-buffer
+    $TMUX send-keys -t "$pane" Enter
+}
diff --git a/bin/bin/xr-external b/bin/bin/xr-external
new file mode 100755 (executable)
index 0000000..0ecdfc2
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+xrandr --output HDMI-1 --auto --output eDP-1 --off
diff --git a/bin/bin/xr-internal b/bin/bin/xr-internal
new file mode 100755 (executable)
index 0000000..9d7b9c2
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+xrandr --output eDP-1 --auto --output HDMI-1 --off
diff --git a/bin/bin/ytdl b/bin/bin/ytdl
new file mode 100755 (executable)
index 0000000..2bbe403
--- /dev/null
@@ -0,0 +1,5 @@
+#!/usr/local/bin/zsh
+
+. /usr/local/bin/virtualenvwrapper.sh
+workon youtube3
+youtube-dl --config-location ~/.youtube-dl.conf $@
diff --git a/bin/bin/ytdlb b/bin/bin/ytdlb
new file mode 100755 (executable)
index 0000000..39f3dde
--- /dev/null
@@ -0,0 +1,3 @@
+#!/usr/local/bin/zsh
+
+ytdl --format best $@
diff --git a/bin/bin/zstd-gut.sh b/bin/bin/zstd-gut.sh
new file mode 100755 (executable)
index 0000000..95a0a00
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+zstdmt -v --ultra -22 --rm $@