From 9ecbcdbfbcf8c5a53089229afc0211f8f537a104 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Mon, 24 Jun 2024 17:11:51 +0200 Subject: Store an example --- example-script.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 example-script.sh diff --git a/example-script.sh b/example-script.sh new file mode 100644 index 0000000..cf85b96 --- /dev/null +++ b/example-script.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# From https://github.com/tardypad/dotfiles/blob/1ea889a6d98b44d97fcf183e97ec2933dafef8b2/files/scripts/sway/sway-subscribe-events-run#L3 +# Working on rewrite of https://aduros.com/blog/hacking-i3-automatic-layout/ +# and potentionally even https://aduros.com/blog/hacking-i3-window-promoting/ + +{ + swaymsg -t subscribe -m '[ "workspace" ]' | + while read -r EVENT; do + CHANGE=$( echo "${EVENT}" | jq -r '.change' ) + if [ "${CHANGE}" != 'focus' ] \ + && [ "${CHANGE}" != 'urgent' ]; then + sway-renumber-workspaces + fi + + if [ "${CHANGE}" = 'focus' ] \ + || [ "${CHANGE}" = 'move' ]; then + pkill -x -RTMIN+8 i3blocks + fi + done +}& + +{ + swaymsg -t subscribe -m '[ "window" ]' | + jq --unbuffered 'select(.change == "focus").container.id' | + while read -r CURRENT_WINDOW; do + pkill -x -RTMIN+8 i3blocks + + swaymsg "[con_id=${PREV_WINDOW}] mark --add _prev" > /dev/null + PREV_WINDOW="${CURRENT_WINDOW}" + done +}& -- cgit