binsh

useful shell scripts
Log | Files | Refs | LICENSE

commit 6e6a3f2a743829518a1c44eebff39ba04f3c0446
Author: noodle <noodle@pastanoggin.com>
Date:   Fri, 11 Jul 2025 02:45:50 +0300

Add the things

Diffstat:
ALICENSE | 1+
Adfs | 9+++++++++
Adudu | 3+++
Afget | 3+++
Afunstats | 33+++++++++++++++++++++++++++++++++
Awatch | 7+++++++
6 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -0,0 +1 @@ +Public domain. diff --git a/dfs b/dfs @@ -0,0 +1,9 @@ +#!/bin/sh +# prints df(1) then the totals of each statistic +# TODO: align the numbers for totals to match df(1) output +set -e +df -h | grep ^[a-zA-Z/] +df -k | awk ' + function human(kb) { order=1; while (kb >= 1000) { kb /= 1024; order++ }; return sprintf("%.1f%c", kb, substr("KMGTPE", order, 1)) } + NR > 1 && /^\/dev/ { devs++; size += $2; used += $3; avail += $4; cap += $5 } + END {printf "Total:\t\t\t\t%s\t%s\t%s\t%d%%\n", human(size), human(used), human(avail), cap/devs }' diff --git a/dudu b/dudu @@ -0,0 +1,3 @@ +#!/bin/sh +# du(1) but shows a sorted, human-readable listing of sizes of all entries +du -had 1 "$@" | sort -h diff --git a/fget b/fget @@ -0,0 +1,3 @@ +#!/bin/sh +# some kinda openbsd curl(1)? +ftp -VMo - "$@" diff --git a/funstats b/funstats @@ -0,0 +1,33 @@ +#!/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)|" diff --git a/watch b/watch @@ -0,0 +1,7 @@ +#!/bin/sh +# gn* watch +while true; do + clear + "$@" + sleep 1 +done