fix i3 related annoyances
authorIan Kelling <ian@iankelling.org>
Fri, 5 Dec 2025 04:34:31 +0000 (23:34 -0500)
committerIan Kelling <ian@iankelling.org>
Fri, 5 Dec 2025 04:34:31 +0000 (23:34 -0500)
filesystem/usr/local/bin/i3-chat
filesystem/usr/local/bin/i3-emacs
g

index 62285fde272cddb768aeb56e7f26094e2d072dbc..b6d854bcadc9c6a84f4836ff9de217f7366c64f6 100755 (executable)
@@ -26,7 +26,7 @@ if ! pgrep "^prof$" >/dev/null; then
 fi
 # start emacs daemon for profanity if it doesnt exist.
 
-id=$(i3-msg -t get_tree | jq -e '.. | select(.name?) | select(.name | test("^e-irc ")).id')
+id=$(i3-msg -t get_tree | jq -e '.. | select(.name?) | select(.name | test("^iznc ")).id')
 
 if [[ ! $id ]]; then
   emacsclient -s profanity -nc  &>/dev/null
index 3337dcbdcc97dc215503443b87980ee3ab24808e..18eddd54d7862370c4f1025c19a724a6a35e4a24 100755 (executable)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
-id=$(i3-msg -t get_tree | jq -e '.. | select(.name?) | select(.name | test("^e-iak ")).id')
+# If there are more than one, just get the 1st one. There is probably
+# some better behavior to do in that case, but atm I don't want to think
+# about it.
+id=$(i3-msg -t get_tree | jq -e '.. | select(.name?) | select(.name | test("^e-iak ")).id'| sort -n| head -n1)
 
 if [[ $id ]]; then
   i3-msg "[con_id=\"$id\"] focus"
 else
-
   i3-msg "workspace 2"
   i3-split-maybe
   emacsclient -c
diff --git a/g b/g
index aaa9ac667142dd4b71d4ed09b7379132874d2e9d..1d6c0d33956a77a7623817cb32e1b772ccc2949c 100755 (executable)
--- a/g
+++ b/g
 # that aren't errors can cause hang too, like when I added gnus
 # git to load path.
 
-# I was experimenting with running
+# note: I was experimenting with running
 # under gdb always to diagnose any hangs/crashes
 # and it won't work due to a gdb crash:
 # gdb -ex="set follow-fork-mode child" -ex=r -ex=quit --args emacsclient -nc
+#
 # -n = --no-wait, go into background
 # -c = create new frame instead of reusing the current frame
 # -a = alternate editor, empty string makes it start emacs daemon.
@@ -48,13 +49,16 @@ g() {
   if (( $# == 0 )); then
     args+=" -c"
   fi
-  # duplicate -c, but oh well
-  if ! pgrep -u $EUID emacsclient &>/dev/null; then
+
+  id=$(i3-msg -t get_tree | jq -e '.. | select(.name?) | select(.name | test("^e-iak ")).id'| sort -n| head -n1)
+
+  if [[ ! $id ]]; then
     if (( $# == 0 )) && type -p gdb &>/dev/null; then
       # no time for messing with gdb right now
       #gdb=true
       :
     else
+      # duplicate arg, but oh well.
       args+=" -c"
     fi
   fi