X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=filesystem%2Fusr%2Flocal%2Fbin%2Fabrowser;h=d3ce6431f1053ecc4d4ffcb7527bba948c78ac6c;hb=e801d1a57f0b30c57c6f644ab06a0f790159b236;hp=c84a6aebb73c13d659511c3771c6c4c4d1970387;hpb=d67edcdca8795a4bca116aa532d02dda246a6f53;p=distro-setup diff --git a/filesystem/usr/local/bin/abrowser b/filesystem/usr/local/bin/abrowser index c84a6ae..d3ce643 100755 --- a/filesystem/usr/local/bin/abrowser +++ b/filesystem/usr/local/bin/abrowser @@ -1,4 +1,25 @@ #!/bin/bash +# I, Ian Kelling, follow the GNU license recommendations at +# https://www.gnu.org/licenses/license-recommendations.en.html. They +# recommend that small programs, < 300 lines, be licensed under the +# Apache License 2.0. This file contains or is part of one or more small +# programs. If a small program grows beyond 300 lines, I plan to switch +# its license to GPL. + +# Copyright 2024 Ian Kelling + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # https://stackoverflow.com/a/2108540 tmp=:$PATH: @@ -22,13 +43,15 @@ i3-msg -t get_tree | jq -e '.nodes[].nodes[].nodes[].nodes | [.[]] + ( [.[].node # prefer abrowser if type -P abrowser &>/dev/null; then - abrowser "$@" & + b=abrowser else - firefox "$@" & + b=firefox fi -# .5 was too fast -sleep 1 +$b "$@" & + +# on a fast computer, .5 is too fast, 1 is ok. on x200, 1 is too fast, 2 is ok. +sleep 2 # debug #printf "%s\n" "$*" >> /tmp/a if (( $# == 0 )) && ! i3-msg -t get_tree | jq --stream -r 'select(.[1]|scalars!=null) | "\(.[0]|join(".")): \(.[1]|tojson)"' | grep 'marks.0: "abrowser"$' &>/dev/null; then @@ -39,7 +62,7 @@ if (( $# == 0 )) && ! i3-msg -t get_tree | jq --stream -r 'select(.[1]|scalars!= # into a single array instead of a list of arrays with [.[]], or else # it will add the arrays a bunch of times and give several results. # comm gives us just the new id. - id=$(i3-msg -t get_tree | jq -e '.nodes[].nodes[].nodes[].nodes | [.[]] + ( [.[].nodes[]]) | .[] | select(.window_properties.class=="abrowser") | .id' | comm -23 - $tmpf | head -n1) + id=$(i3-msg -t get_tree | jq -e '.nodes[].nodes[].nodes[].nodes | [.[]] + ( [.[].nodes[]]) + ( [.[].nodes[].nodes[]]) + ( [.[].nodes[].nodes[].nodes[]]) | .[] | select(.window_properties.class=="'$b'") | .id' | comm -23 - $tmpf | head -n1) rm -f $tmpf if [[ $id ]]; then i3-msg "[con_id=$id] mark abrowser"