fix abrowser
authorIan Kelling <ian@iankelling.org>
Fri, 26 Jul 2024 15:19:22 +0000 (11:19 -0400)
committerIan Kelling <ian@iankelling.org>
Fri, 26 Jul 2024 15:19:22 +0000 (11:19 -0400)
filesystem/usr/local/bin/abrowser
filesystem/usr/local/bin/i3-abrowser
path-add-function

index 96c969a4c149ca95aadd09383fa56df94e523534..8d47fec4bc71b4a0d23b4b794feb8ce9be4a2496 100755 (executable)
@@ -39,19 +39,12 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${P
 
 
 
-# remove local/bin from path
-# https://stackoverflow.com/a/2108540
-tmp=:$PATH:
-del=/usr/local/bin
-tmp=${tmp//:$del:/:}
-tmp=${tmp%:}
-tmp=${tmp#:}
-PATH=$tmp
 # prefer abrowser
-if type -P abrowser &>/dev/null; then
+if [[ -x /usr/bin/abrowser ]]; then
   b=abrowser
 else
   b=firefox
 fi
 
-$b "$@"
+# avoid our wrapper in /usr/local/bin
+/usr/bin/$b "$@"
index fdd9e27d1687108319b78cb719427ca859b902cc..d592ceb1b4902278972ed6d96a850fa028f1768d 100755 (executable)
@@ -26,16 +26,8 @@ set -eE -o pipefail
 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR
 
 
-# remove local/bin from path
-# https://stackoverflow.com/a/2108540
-tmp=:$PATH:
-del=/usr/local/bin
-tmp=${tmp//:$del:/:}
-tmp=${tmp%:}
-tmp=${tmp#:}
-PATH=$tmp
 # prefer abrowser
-if type -P abrowser &>/dev/null; then
+if [[ -x /usr/bin/abrowser ]]; then
   b=abrowser
 else
   b=firefox
@@ -46,7 +38,8 @@ if ! i3-focus-maybe abrowser; then
 
   i3-msg "workspace 2"
   i3-split-maybe
-  $b "$@" &
+  # avoid our wrapper in /usr/local/bin
+  /usr/bin/$b "$@" &
   # on a fast computer, .5 is too fast, 1 is ok. on x200, 2 is ok if the computer isn't busy.
 
   for (( i=0; i < 15; i++ )); do
@@ -71,5 +64,4 @@ if ! i3-focus-maybe abrowser; then
   #   i3-msg "[con_mark=\"abrowser\"] focus"
   # fi
 
-
 fi
index 92f39b51b0ef4aa339891d11a1c5156b1f271aa9..fb93787233c9d52cef490875846b02a32db0aef1 100644 (file)
@@ -90,3 +90,13 @@ path-add() {
     fi
   done
 }
+
+
+# example of removing local/bin from path
+# https://stackoverflow.com/a/2108540
+# tmp=:$PATH:
+# del=/usr/local/bin
+# tmp=${tmp//:$del:/:}
+# tmp=${tmp%:}
+# tmp=${tmp#:}
+# PATH=$tmp