`wmctrl` is magic
This old and probably already "done" software from maybe ~16 years ago is magic. I used to launch my terminal instance in my i3wm setup using [this](/?q=d6f0b137-2fd9-4b9b-a0a0-81bfc6845cba) script. When I revisited the script about an hour ago, I think I can just rewrite in in Bash script using `wmctrl` to communicate with i3. I did it in ~30 minutes, and it is very short. I am saying goodbye to parsing messages from `i3-msg` :D ``` #!/usr/bin/bash active_desktop="$(wmctrl -d | awk '/*/ { print $1 }')" term_in_desktop="$(wmctrl -lx | awk '$3~/Alacritty.Alacritty/ && $2=="'"$active_desktop"'" { print $1 }')" if [ -z "$term_in_desktop" ]; then tmux detach -s main alacritty -e tmux new -A -s main else wmctrl -i -a "$term_in_desktop" fi ``` Performance-wise, I think this is probably faster, but I don't really care. It's short, more maintainable, and may also support other WMs (except Wayland WMs like Sway?).Created: 2024-12-11 16:49:52, Updated: 2024-12-11 16:49:52, ID: 6a3ede3d-af78-4460-8628-a07155eefee6