aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/Makefile3
-rwxr-xr-xbin/OpenBSDStatus.sh108
-rwxr-xr-xbin/ddmenu4
-rwxr-xr-xbin/vol44
4 files changed, 146 insertions, 13 deletions
diff --git a/bin/Makefile b/bin/Makefile
index 6c304d8..56afbe8 100644
--- a/bin/Makefile
+++ b/bin/Makefile
@@ -14,6 +14,9 @@ linux:
install wpa $(HOME)/bin
install touchpad-props $(HOME)/bin
+OpenBSD:
+ install OpenBSDStatus.sh $(HOME)/bin/
+
install:
install -d $(HOME)/bin
sed "s|__REPLACE__|$$(dirname `pwd`)/snips|g" < snipmenu > $(HOME)/bin/snipmenu
diff --git a/bin/OpenBSDStatus.sh b/bin/OpenBSDStatus.sh
new file mode 100755
index 0000000..738f11f
--- /dev/null
+++ b/bin/OpenBSDStatus.sh
@@ -0,0 +1,108 @@
+#!/bin/sh
+timeout=1
+
+_sys_memory() {
+ vmstat | sed -n '$p' | awk '{print $4}'
+}
+
+_sys_uptime() {
+uptime | sed -re's/^.*up[ ]+//g' -e's/^([^,]*),.*/\1/g' -e's/^([^ ]+)[ ]*(.).*/\1\2/g'
+}
+
+wireless_info() {
+ _if="$1"
+
+ printf "WiFi: %s %s %s %s" \
+ "$_if" \
+ "$(ifconfig "$_if" | sed -nre 's/^.*nwid ([^ ]+).*$/\1/p')" \
+ "$(ifconfig "$_if" | sed -nre 's/^.* ([^ ]+dBm) .*$/\1/p')" \
+ "$(ifconfig "$_if" | sed -nre 's/^.*inet ([^ ]+).*$/\1/p')"
+}
+
+eth_info() {
+ _if="$1"
+
+ printf "Eth: %s %s %s" \
+ "$_if" \
+ "$(ifconfig "$_if" | sed -nre 's/^.*inet ([^ ]+).*$/\1/p')"
+ "$(ifconfig "$_if" | grep -oE '[0-9]+baseT')"
+}
+
+network_info() {
+ default_if="$(netstat -rnf inet | awk '/^default/{print $8}')"
+
+ if [ -z "$default_if" ] ; then
+ echo "No conn"
+ elif ifconfig "$default_if" | grep -q IEEE802.11 ; then
+ wireless_info "$default_if"
+ else
+ eth_info "$default_if"
+ fi
+}
+
+
+ac_status() {
+ if [ `apm -a` -eq 1 ] ; then
+ echo "charging"
+ else
+ printf "discharging "
+
+ if [ `apm -m` != "unknown" ] ; then
+ minutes="$(apm -m)"
+ hours="$(echo "$minutes"/60 | bc)"
+ hours2="$(echo "$minutes"/60 | bc -l)"
+ minutes="$(echo "(${hours2}-${hours})*60" | bc -l )"
+ printf "%d hours, %d minutes left" "$hours" "$minutes"
+ fi
+ fi
+}
+
+cpu_temp() {
+ sysctl hw.sensors.cpu0.temp0 \
+ | awk -F= '{print $2}' \
+ | cut -d' ' -f 1 \
+ | cut -d'.' -f 1 \
+ | tr -d '\n'
+ printf "c"
+}
+
+cpu_fan() {
+ sysctl hw \
+ | grep fan \
+ | awk -F= '{print $2;exit}' \
+ | cut -d' ' -f 1 \
+ | tr -d '\n'
+ printf "rpm"
+}
+
+get_status_simple() {
+echo \
+ "Volume: $(sndioctl | awk 'BEGIN{FS="="}{if($1 ~ /output.level/){print ($2+0)*100}}') |"\
+ "Fan: $(cpu_fan) |"\
+ "Temp: $(cpu_temp) |"\
+ "Setperf: $(sysctl hw.setperf | awk -F= '{print $2}') |"\
+ "Batt: $(apm -l) $(ac_status)|"\
+ "$(network_info) |"\
+ "$(date '+%m.%d.%Y %H:%M:%S')"
+}
+
+get_status() {
+echo \
+ "Volume: $(sndioctl | awk 'BEGIN{FS="="}{if($1 ~ /output.level/){print ($2+0)*100}}')|"\
+ "Temp: $(sysctl hw.sensors.cpu0.temp0 | awk -F= '{print $2}')|"\
+ "Fan: $(sysctl hw | grep fan | awk -F= '{print $2;exit}')|"\
+ "Cpu Freq: $(sysctl hw.cpuspeed | awk -F= '{print $2}')mhz|"\
+ "Setperf: $(sysctl hw.setperf | awk -F= '{print $2}')|"\
+ "Batt: $(apm -l) $(ac_status)|"\
+ "$(network_info) |"\
+ "Free Mem: $(_sys_memory)|"\
+ "uptime: $(_sys_uptime)|"\
+ "$(date '+%m.%d.%Y %H:%M:%S')"
+}
+
+while true ; do
+
+xsetroot -name "$(get_status_simple)"
+
+sleep "$timeout"
+done
diff --git a/bin/ddmenu b/bin/ddmenu
index b4c1bc6..3682139 100755
--- a/bin/ddmenu
+++ b/bin/ddmenu
@@ -7,6 +7,8 @@ otp
otp-type
snip
snip-type
+dmenu_run
+pm
EOF
)"
@@ -17,4 +19,6 @@ case $command in
otp-type) dpw-menu --otp --type "$@" ;;
snip) snipmenu copy "$@" ;;
snip-type) snipmenu "$@" ;;
+ dmenu_run) dmenu_run "$@" ;;
+ pm) pm "$@" ;;
esac
diff --git a/bin/vol b/bin/vol
index 1071d8c..58c500e 100755
--- a/bin/vol
+++ b/bin/vol
@@ -7,18 +7,36 @@ getVolume() {
currentVolume=$(echo "${volumeInput#*Sink #$sinkNumber}" | grep -E 'V.*-left' | grep -oE '[0-9]+%' | tail -n 1)
notify-send "Volume: $currentVolume"
}
+
+case $(uname) in
+ Linux)
-case "$1" in
- up) pactl set-sink-volume @DEFAULT_SINK@ +5%; getVolume;;
- down) pactl set-sink-volume @DEFAULT_SINK@ -5%; getVolume;;
- mute) muted=$(pactl list sinks | grep 'Mute: yes')
- if [ -z "$muted" ]; then
- pactl set-sink-mute @DEFAULT_SINK@ 1
- notify-send Volume: Muted
- else
- pactl set-sink-mute @DEFAULT_SINK@ 0
- getVolume
- fi;;
- *) echo error;;
-esac
+ case "$1" in
+ up) pactl set-sink-volume @DEFAULT_SINK@ +5%; getVolume;;
+ down) pactl set-sink-volume @DEFAULT_SINK@ -5%; getVolume;;
+ mute) muted=$(pactl list sinks | grep 'Mute: yes')
+ if [ -z "$muted" ]; then
+ pactl set-sink-mute @DEFAULT_SINK@ 1
+ notify-send Volume: Muted
+ else
+ pactl set-sink-mute @DEFAULT_SINK@ 0
+ getVolume
+ fi;;
+ *) echo error;;
+ esac
+
+ ;;
+
+ OpenBSD)
+
+ up="$(sndioctl output.level | awk -F= '{print $2}' | awk '{print $0+.10}')"
+ down="$(sndioctl output.level | awk -F= '{print $2}' | awk '{print $0-.10}')"
+
+ case $1 in
+ up) sndioctl output.level="$up" ;;
+ dn|down) sndioctl output.level="$down" ;;
+ esac
+
+ ;;
+esac