X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=i3-abrowser;h=a43c21d375052b000d9bd2523c6b7cc75b0ac9d8;hb=HEAD;hp=eb2d47c5fc3112936ea50ef5216357968112ab86;hpb=3342374657bd712f14cd772378b23d2bca3382cb;p=distro-setup diff --git a/i3-abrowser b/i3-abrowser index eb2d47c..a43c21d 100755 --- a/i3-abrowser +++ b/i3-abrowser @@ -26,6 +26,14 @@ 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 b=abrowser @@ -33,23 +41,30 @@ else b=firefox fi -# mark if we dont have a mark already -if i3-msg -t get_tree | jq --stream -r 'select(.[1]|scalars!=null) | "\(.[0]|join(".")): \(.[1]|tojson)"' | grep 'marks.0: "abrowser"$' &>/dev/null; then - h=$(i3-msg -t get_tree | jq -r ".. | select(.focused? == true) | .rect.height") - cur_workspace=$(i3-msg -t get_workspaces | jq -r '.[] | select(.focused? == true) | .name') +# spawn and mark if we dont have a mark already +if ! /a/c/i3-focus-maybe abrowser; then - # h tests if we have a current focus, but that is just a random guess. - if [[ $cur_workspace == 2 && $h ]]; then - i3-msg "swap container with mark abrowser; [con_mark=\"abrowser\"] focus" - else - i3-msg '[con_mark="abrowser"] move workspace current' - fi - -else + i3-msg "workspace 2" i3-split-maybe - abrowser & + $b "$@" & # on a fast computer, .5 is too fast, 1 is ok. on x200, 1 is too fast, 2 is ok. sleep 2 - i3-msg "[workspace=__focused__ class=\"$b\"] mark abrowser" + i3-msg "[workspace=__focused__ class=\"$b\" instance=\"Navigator\" window_role=\"browser\"] mark abrowser" wait + +# else + # # If we were streaming 1/4 of the screen without separate workspaces, we might + # # want something like this. But as is, it is better to just focus. same deal in + # # my other programs like this one, but I removed the code there. + # + # cur_workspace=$(i3-msg -t get_workspaces | jq -r '.[] | select(.focused? == true) | .name') + # i3-msg "[con_mark=\"abrowser\"] focus" + + # if [[ $cur_workspace == 2 ]]; then + # i3-msg "swap container with mark abrowser; [con_mark=\"abrowser\"] focus" + # else + # i3-msg "[con_mark=\"abrowser\"] focus" + # fi + + fi