tAdd a few ones left untracked - scripts - various script and utils
(HTM) git clone git://z3bra.org/scripts
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit 3ee0bcf3c6a2aeafdfcff348210a805cda968990
(DIR) parent 6bfdc1770207dd0b0ac3fa086f0a4b21c2315205
(HTM) Author: z3bra <contactatz3bradotorg>
Date: Mon, 5 Dec 2016 17:18:48 +0100
Add a few ones left untracked
Diffstat:
A diffcolor | 7 +++++++
A dmenu | 12 ++++++++++++
A ffstream | 15 +++++++++++++++
A mkpasswd | 6 ++++++
A pack | 38 +++++++++++++++++++++++++++++++
A sbar | 49 +++++++++++++++++++++++++++++++
A tempsh | 7 +++++++
A tpm | 114 +++++++++++++++++++++++++++++++
8 files changed, 248 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/diffcolor b/diffcolor
t@@ -0,0 +1,7 @@
+#!/bin/sed -f
+#
+# diffcolor: colorize unified diff output
+
+s/^+.*$/[0;32m&[0m/
+s/^-.*$/[0;31m&[0m/
+s/^@.*$/[1;34m&[0m/
(DIR) diff --git a/dmenu b/dmenu
t@@ -0,0 +1,12 @@
+#!/bin/sh
+#
+# put it before dmenu in your PATH
+
+FONT="monospace:size=8:antialias=true"
+NB='black'
+NF='white'
+SB='white'
+SF='black'
+
+
+ifne dmenu -fn "$FONT" -nb "$NB" -nf "$NF" -sb "$SB" -sf "$SF" $@
(DIR) diff --git a/ffstream b/ffstream
t@@ -0,0 +1,15 @@
+#!/bin/sh
+
+SND="-f alsa -thread_queue_size 2048 -i default"
+STREAM=${1:-http://phobos.2f30:8090/0.ffm}
+
+if [ "$1" = "-q" ]; then
+ ffmpeg -f x11grab -r 5 -s 1440x900 -thread_queue_size 1024 -i :0.0 -an -fflags nobuffer ${STREAM}
+else
+ ffmpeg -f x11grab -r 5 -s 1440x900 -thread_queue_size 1024 -i :0.0 \
+ -f alsa -ac 1 -thread_queue_size 1024 -i default \
+ -af 'highpass=f=200, lowpass=f=2000' \
+ -fflags nobuffer ${STREAM} \
+ -af 'highpass=f=200, lowpass=f=2000' \
+ -c:v libvpx -b:v 5M -c:a libvorbis webcast-$(date +%Y%m%d%H%M%S).webm
+fi
(DIR) diff --git a/mkpasswd b/mkpasswd
t@@ -0,0 +1,5 @@
+#!/bin/sh
+
+LEN=${1:-16}
+
+</dev/urandom tr -cd ${CHAR:-'a-zA-Z0-9'} | fold -w ${LEN} | sed 1q
+\ No newline at end of file
(DIR) diff --git a/pack b/pack
t@@ -0,0 +1,38 @@
+#!/bin/sh
+
+SICKKEY=$HOME/.sick.d/$USER.key
+DIR=$(basename `pwd`)
+TAG=$(git tag | sed -n '$p' | tr -d a-z)
+REPO=/var/www/htdocs/dl.z3bra.org/pack
+
+prefix=/usr/local
+
+CONFIGURE_OPT="
+--prefix=${prefix}
+--mandir=/share/man
+"
+
+PKG=${1:-$DIR}
+VER=${TAG:-0.0}
+
+MK=make
+
+test -f mkfile && MK=mk
+
+case $MK in
+ make) MAKEFLAGS="-e" ;;
+ *) MAKEFLAGS="" ;;
+esac
+
+test -f configure && ./configure $CONFIGURE_OPT
+$MK $MAKEFLAGS PREFIX="$prefix"
+$MK $MAKEFLAGS DESTDIR=/tmp/rootfs PREFIX="$prefix" MANDIR=/share/man install
+(
+ cd /tmp/rootfs
+ mkdir -p $REPO
+ tar cvj * | sick -s -f ${SICKKEY} > $REPO/${PKG}#${VER}.tar.bz2
+)
+rm -rf /tmp/rootfs
+
+echo
+ls $REPO/${PKG}#${VER}.tar.bz2
(DIR) diff --git a/sbar b/sbar
t@@ -0,0 +1,49 @@
+#!/bin/sh
+
+swidth=$(wattr w `lsw -r`)
+geom="${swidth}x20"
+
+LEMON_FLAVOR="-d -g $geom"
+
+clock() {
+ printf 'TIME %%{R} %s %%{R}' "$(date +%H:%M)"
+}
+
+mailc() {
+ maildir=$HOME/data/mail
+ mailboxes="inbox lists/crux lists/lobsters lists/pcc lists/suckless"
+
+ printf '%%{R} MAILS %%{R}'
+ for m in $mailboxes; do
+ mailbox=$(echo $m | cut -d/ -f2 | tr a-z A-Z)
+ test $(fcount $maildir/$m/new) -eq 0 && continue
+ printf ' %s %%{R} %d %%{R}' "$mailbox" "$(fcount $maildir/$m/new)"
+ done
+ echo
+}
+
+todo() {
+ printf 'TODO %%{R} %d %%{R}' $(<$HOME/.todo wc -l)
+}
+
+sound() {
+ level=$(amixer get Master | sed 's/^.*\[\([0-9]\+\)%.*$/\1/p;d' |uniq)
+ printf 'SOUND %%{R} %s %%{R}' "$level"
+}
+
+vpn() {
+ netname=$1
+ pgrep -f "tincd.*${netname}" 2>&1 >/dev/null
+ case $? in
+ 0) printf 'VPN %%{R} UP %%{R}' ;;
+ 1) printf 'VPN %%{R} DOWN %%{R}' ;;
+ esac
+}
+
+while :; do
+ BUF=
+ BUF="${BUF}%{l}$(mailc inbox)"
+ BUF="${BUF}%{r}$(todo) $(vpn 2f30) $(sound) $(clock)"
+ echo $BUF
+ sleep 1
+done | lemonbar $LEMON_FLAVOR
(DIR) diff --git a/tempsh b/tempsh
t@@ -0,0 +1,6 @@
+#!/bin/sh
+
+TMP=$(mktemp -d)
+cd $TMP
+mksh -l
+rm -rf $TMP
+\ No newline at end of file
(DIR) diff --git a/tpm b/tpm
t@@ -0,0 +1,114 @@
+#!/bin/sh
+# Copyright (C) 2013-2015 Sören Tempel
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+umask 077
+
+##
+# Variables
+##
+
+GPG_OPTS="--quiet --yes --batch"
+STORE_DIR="${PASSWORD_STORE_DIR:-${HOME}/.pass}"
+
+if [ -r "${STORE_DIR}/.gpg-id" ] && [ -z "${PASSWORD_STORE_KEY}" ]; then
+ read -r PASSWORD_STORE_KEY < "${STORE_DIR}/.gpg-id"
+fi
+
+if [ -n "${PASSWORD_STORE_KEY}" ]; then
+ GPG_OPTS="${GPG_OPTS} --recipient ${PASSWORD_STORE_KEY}"
+else
+ GPG_OPTS="${GPG_OPTS} --default-recipient-self"
+fi
+
+##
+# Helper
+##
+
+abort() {
+ echo "${1}" 1>&2
+ exit 1
+}
+
+readpw() {
+ if [ -t 0 ]; then
+ printf "%s" "${1}"
+ stty -echo
+ fi
+
+ IFS= read -r "${2}"
+ [ -t 0 ] && stty echo
+}
+
+##
+# Commands
+##
+
+show() {
+ entry_name="${1}"
+ entry_path="${STORE_DIR}/${entry_name}.gpg"
+
+ if [ -z "${entry_name}" ]; then
+ abort "usage: tpm <entry>"
+ fi
+
+ if [ ! -e "${entry_path}" ]; then
+ abort "The requested entry doesn't exist."
+ fi
+
+ gpg2 ${GPG_OPTS} --decrypt "${entry_path}"
+}
+
+insert() {
+ entry_name="${1}"
+ entry_path="${STORE_DIR}/${entry_name}.gpg"
+
+ if [ -z "${entry_name}" ]; then
+ abort "usage: tpm -i <entry>"
+ fi
+
+ if [ -e "${entry_path}" ]; then
+ abort "This entry already exists, please remove it first."
+ fi
+
+ password=""
+ readpw "Password for '${entry_name}': " password
+ if [ -t 0 ]; then
+ printf "\n"
+ fi
+
+ if [ -z "${password}" ]; then
+ abort "You didn't specify a password."
+ fi
+
+ mkdir -p "$(dirname "${entry_path}")"
+ printf '%s\n' "${password}" | gpg2 ${GPG_OPTS} \
+ --encrypt --output "${entry_path}"
+}
+
+##
+# Parse input
+##
+
+if [ $# -lt 1 ]; then
+ tree $STORE_DIR|sed 's/.gpg$//'
+ exit 0
+fi
+
+case "${1}" in
+ -i) insert "${2}" ;;
+ -h) abort "usage: tpm [-i] <entry>" ;;
+ *) show "$1"
+esac