From abd1eae8291c91fe62bcf22fc15a93178f1ab491 Mon Sep 17 00:00:00 2001 From: sev Date: Wed, 18 Mar 2020 22:33:33 -0500 Subject: [PATCH] fix which usage, create function check-busybox --- base/.zshrc | 13 ++++++++++--- bin/.check-busybox | 4 ++++ bin/dpass | 4 +++- bin/rotate | 2 +- bin/tint2-i3status | 4 +++- 5 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 bin/.check-busybox diff --git a/base/.zshrc b/base/.zshrc index e06c318..eec9016 100644 --- a/base/.zshrc +++ b/base/.zshrc @@ -1,3 +1,6 @@ +### imports +source ~/bin/.check-busybox + ### user-local fpath fpath=(~/.zsh ~/.zsh/functions/Prompts "${fpath[@]}") @@ -53,14 +56,13 @@ if [[ "$OSTYPE" =~ '^(free|net)bsd' ]] { } ## ps local p= -if { which pstree >/dev/null 2>&1 && \ - [[ ! "$(readlink -f $(which pstree))" =~ "/busybox" ]] } { +if which pstree >/dev/null 2>&1 && ! check-busybox pstree { # use pstree, but NOT busybox pstree because it kinda sucks p="pstree -wg3" } elif [[ "$OSTYPE" =~ '^freebsd' ]] { p="ps -aSdfxwwouser=USR -ogroup=GRP -opid,nice=NI \ -o%cpu,%mem,tty,stat,start=START -oetime,command" -} elif [[ "$(readlink -f $(which ps))" =~ "/busybox" ]] { +} elif check-busybox ps { # busybox compatible p="ps -eouser='USR ' -ogroup='GRP ' \ -opid=' PID' -onice=' NI' -ovsz=' MEM' \ @@ -167,6 +169,7 @@ case "$OSTYPE"; in ## sound # TODO: test alsa/oss/sndio/portaudio/pulse in order of importance function s() {} + function vol() {} esac ### modules & styles @@ -204,4 +207,8 @@ compinit autoload -Uz promptinit && promptinit prompt ds6 + +### unset imports +unfunction check-busybox + # vim: set et sts=4 sw=4 ts=8 tw=79 : diff --git a/bin/.check-busybox b/bin/.check-busybox new file mode 100644 index 0000000..f822319 --- /dev/null +++ b/bin/.check-busybox @@ -0,0 +1,4 @@ +#!/bin/sh +function check-busybox() { + which $1 >/dev/null 2>&1 && [ "$(basename "$(readlink -f "$(which "$1" | head -1)")")" = "busybox" ] +} diff --git a/bin/dpass b/bin/dpass index 3dc4c8f..c37942b 100755 --- a/bin/dpass +++ b/bin/dpass @@ -1,6 +1,8 @@ #!/bin/sh +. ~/bin/.check-busybox p="$1" -if [ -z "$p" -a "$(basename "$(readlink -f "$(which ps)")")" =~ "/busybox" ]; then +if [ -z "$p" ] && ! check-busybox ps; then p="[$(ps -o comm= -p $(ps -o ppid= -p $$))]"; fi ~/bin/dmenu -p "$p" -fn Dina-10 -nb \#110800 -nf \#110800 -sb \#264bd2 -sf \#fdf6e3 <&- +unset check-busybox diff --git a/bin/rotate b/bin/rotate index 83b7147..a902580 100755 --- a/bin/rotate +++ b/bin/rotate @@ -69,7 +69,7 @@ num_to_rot $((($rot0 + 4) % 4)) xrandr --output $output --rotation $rot1 # x220t -if which xsetwacom >/dev/null; then +if which xsetwacom >/dev/null 2>&1; then xsetwacom --set stylus Rotate $rot2 xsetwacom --set eraser Rotate $rot2 xsetwacom --set touch Rotate $rot2 diff --git a/bin/tint2-i3status b/bin/tint2-i3status index 1132d1a..f655e6c 100755 --- a/bin/tint2-i3status +++ b/bin/tint2-i3status @@ -1,4 +1,6 @@ #!/bin/sh +. ~/bin/.check-busybox u=-u -if readlink -f $(which sed) | grep -q /busybox; then u=''; fi +check-busybox sed && u='' i3status -c ${XDG_CONFIG_HOME:-~/.config}/i3status/tint2-$1 | sed $u -e 's/fc=\(#[a-f0-9]\{3,6\}\)/span color="\1"/gi;s_/fc_/span_g' +unset check-busybox -- 2.47.0