5
submitted 11 months ago by Samueru@lemmy.ml to c/linux4noobs@lemmy.world

Here is the script, which is a hack that I use with i3wm, I already converted most of it to a single line and it still works:

#!/usr/bin/env bash

is-leaf-node() { i3-msg -t get_tree | jq 'recurse(.nodes[]?, .floating_nodes[]?) | select(.type == "con" or .type == "floating_con") | select(.focused == true) | .nodes == []';}; parent-type() { i3-msg -t get_tree | jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.nodes[]?.focused == true) | .type' ;}; if [ "$(is-leaf-node)" == "true" ]; then i3-msg focus parent, focus parent; else i3-msg focus child, focus child; fi

Here is where I'm stuck:

The script needs the #!/usr/bin/env bash to work, it is the only script that I have that needs it.

Changing it to #!/usr/bin/env bash; does not work, it has have a second line for it to work.

you are viewing a single comment's thread
view the rest of the comments
[-] misophist@lemmy.world 1 points 11 months ago

Save it in a file called "myprog.sh", then the one line would be ./myprog.sh (you can replace . With the full file path to make it more robust).

this post was submitted on 30 Nov 2023
5 points (100.0% liked)

Linux 101 stuff. Questions are encouraged, noobs are welcome!

1041 readers
1 users here now

Linux introductions, tips and tutorials. Questions are encouraged. Any distro, any platform! Explicitly noob-friendly.

founded 1 year ago
MODERATORS