From 6f2c8f087777e59d5126982fd275da57027bba31 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Fri, 26 Jul 2024 11:19:22 -0400 Subject: [PATCH] fix abrowser --- filesystem/usr/local/bin/abrowser | 13 +++---------- filesystem/usr/local/bin/i3-abrowser | 14 +++----------- path-add-function | 10 ++++++++++ 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/filesystem/usr/local/bin/abrowser b/filesystem/usr/local/bin/abrowser index 96c969a..8d47fec 100755 --- a/filesystem/usr/local/bin/abrowser +++ b/filesystem/usr/local/bin/abrowser @@ -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 "$@" diff --git a/filesystem/usr/local/bin/i3-abrowser b/filesystem/usr/local/bin/i3-abrowser index fdd9e27..d592ceb 100755 --- a/filesystem/usr/local/bin/i3-abrowser +++ b/filesystem/usr/local/bin/i3-abrowser @@ -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 diff --git a/path-add-function b/path-add-function index 92f39b5..fb93787 100644 --- a/path-add-function +++ b/path-add-function @@ -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 -- 2.30.2