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
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\" 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