]> git.sev.monster Git - dotfiles.git/commitdiff
fix which usage, create function check-busybox
authorsev <git@sev.monster>
Thu, 19 Mar 2020 03:33:33 +0000 (22:33 -0500)
committersev <git@sev.monster>
Thu, 19 Mar 2020 03:33:33 +0000 (22:33 -0500)
base/.zshrc
bin/.check-busybox [new file with mode: 0644]
bin/dpass
bin/rotate
bin/tint2-i3status

index e06c318d6ba169aa77f41d76b5c611b4d41c203f..eec9016b9b2cb3fa1dc5bda1d0c85dba38990559 100644 (file)
@@ -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 (file)
index 0000000..f822319
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+function check-busybox() {
+    which $1 >/dev/null 2>&1 && [ "$(basename "$(readlink -f "$(which "$1" | head -1)")")" = "busybox" ]
+}
index 3dc4c8f40c722ebb65ae8d31dbf05bdc20963d07..c37942ba741c7bc8516ec0dce8acf8b2a9572fa0 100755 (executable)
--- 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
index 83b71473bb9e0eb7a2898072a45230a7b684465c..a902580a6ce91149e88f147a15f66d9710b1d95b 100755 (executable)
@@ -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
index 1132d1a50093e00277f8e4945dc48a27fa0eca3d..f655e6c408fe00a75a3d19280b541139a9e57fe9 100755 (executable)
@@ -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
This page took 0.040255 seconds and 4 git commands to generate.