From 0099e7fe7b26477b9c2d8e783991cd0b2fd0116e Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Thu, 4 Dec 2025 23:34:31 -0500 Subject: [PATCH] fix i3 related annoyances --- filesystem/usr/local/bin/i3-chat | 2 +- filesystem/usr/local/bin/i3-emacs | 7 ++++--- g | 10 +++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/filesystem/usr/local/bin/i3-chat b/filesystem/usr/local/bin/i3-chat index 62285fd..b6d854b 100755 --- a/filesystem/usr/local/bin/i3-chat +++ b/filesystem/usr/local/bin/i3-chat @@ -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 diff --git a/filesystem/usr/local/bin/i3-emacs b/filesystem/usr/local/bin/i3-emacs index 3337dcb..18eddd5 100755 --- a/filesystem/usr/local/bin/i3-emacs +++ b/filesystem/usr/local/bin/i3-emacs @@ -20,13 +20,14 @@ # 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 aaa9ac6..1d6c0d3 100755 --- a/g +++ b/g @@ -27,10 +27,11 @@ # 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 -- 2.30.2