aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2024-06-24 17:11:51 +0200
committerMatěj Cepl <mcepl@cepl.eu>2024-06-24 17:11:51 +0200
commit9ecbcdbfbcf8c5a53089229afc0211f8f537a104 (patch)
treebfa6b4e850056f1f6d87039ae28f684101286c8c
downloadsway-layout-9ecbcdbfbcf8c5a53089229afc0211f8f537a104.tar.gz
Store an example
-rw-r--r--example-script.sh31
1 files changed, 31 insertions, 0 deletions
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
+}&