Commit Diff


commit - c31c225d619e436ab674e72f50cb8ed62a32acae
commit + 0388c85624241671417e938ef8f227ec3bde6851
blob - /dev/null
blob + 0e7f7b549b3c38ef52ba877fbc163039c8d36d7b (mode 755)
--- /dev/null
+++ badphrase
@@ -0,0 +1,54 @@
+#!/bin/sh
+# badphrase: creates a passphrase from a word dictionary
+
+# constants
+englishchars=26
+
+# flags
+charmin=6
+charmax=0
+copy=0
+entropymin=100
+includenames=0
+wordlist=/usr/share/dict/words
+wordnum=4
+
+usage() {
+	echo "usage: ${0##*/} [-ci] [-e entropymin] [-l wordlist] [-m charmax] \
+[-n charmin] [-w wordnum]" 1>&2
+	return 1;
+}
+
+while getopts ce:hil:m:n:w: arg; do
+	case $arg in
+	c)	copy=1;;
+	e)	entropymin=${OPTARG};;
+	h)	usage;;
+	i)	includenames=1;;
+	l)	wordlist=${OPTARG};;
+	m)	charmax=${OPTARG};;
+	n)	charmin=${OPTARG};;
+	w)	wordnum=${OPTARG};;
+	?)	usage;;
+	esac
+done
+shift $((OPTIND - 1))
+
+# password length should satisfy entropy requirements
+minlen=$(echo "l(2^${entropymin})/l($englishchars)" | bc -l)
+if [ "$(echo "${wordnum}*${charmin} >= ${minlen}" | bc -l)" -ne 1 ]; then
+	printf "%s: wordnum * charmin needs to be >= %.2f\n" "${0##*/}" "$minlen" 1>&2
+	exit 1;
+fi
+
+# generate the passphrase
+sort -R "$wordlist" | \
+if [ "$includenames" -eq 0 ]; then grep '^[^A-Z]'; else cat; fi | \
+if [ "$charmax" -lt "$charmin" ]; then grep -x ".\{${charmin},\}"; else grep -x ".\{${charmin},${charmax}\}"; fi | \
+head -n "$wordnum" | \
+# output the passphrase
+if [ "$copy" -eq 1 ]; then
+	paste -sd '' - | xclip -selection clipboard
+else
+	paste -sd ' ' -
+fi
blob - /dev/null
blob + 300fb705b49ff26af3788495b9f7cb011952700f (mode 755)
--- /dev/null
+++ entropy
@@ -0,0 +1,10 @@
+#!/bin/sh
+# entropy: calculates the entropy of a password given the length and number of
+# possiblities
+
+num=0
+[ "$1" = '-n' ] && { num=1; shift; }
+[ "$#" -ne 2 ] && { echo "usage: ${0##*/} [-n] possibilites length " 1>&2; exit 1; }
+echo "l($1^$2)/l(2)" | bc -l | xargs printf "%.2f"
+[ "$num" -eq 0 ] && printf " bits of entropy"
+printf "\n"
blob - /dev/null
blob + 7fcfb992a1136e822a47a2c083dd3c07c1ef54ff (mode 755)
--- /dev/null
+++ funstats
@@ -0,0 +1,32 @@
+#!/bin/sh
+# some cool stats for the tmux bar on openbsd
+
+vol () {
+	if [ "$(sndioctl -n output.mute)" -eq 1 ]; then
+		echo "muted"
+	else
+		sndioctl -n output.level | awk '{ printf "%d%%\n", int($0*100) }'
+	fi
+}
+
+mic () {
+	if [ "$(sysctl -n kern.audio.record)" -eq 1 ] || [ "$(sndioctl -n input.mute)" -eq 1 ]; then
+		printf "muted"
+	else
+		sndioctl -n input.level | awk '{ printf "%d%%\n", int($0*100) }'
+	fi
+}
+
+bat () {
+	apm -l
+}
+
+lidaction () {
+	[ "$(sysctl -n machdep.lidaction)" -eq 1 ] && printf "on" || printf "off"
+}
+
+temp () {
+	sysctl -n hw.sensors.cpu0.temp0 | awk '{ print $1, "C" }'
+}
+
+echo "|mic: $(mic)|vol: $(vol)|bat: $(bat)%|temp: $(temp)|lid: $(lidaction)|"