Skip to content

Instantly share code, notes, and snippets.

@ckafi
Last active March 21, 2024 09:57
Show Gist options
  • Save ckafi/0a5b79105c8301466cc324a08200aad7 to your computer and use it in GitHub Desktop.
Save ckafi/0a5b79105c8301466cc324a08200aad7 to your computer and use it in GitHub Desktop.
Tracks the previosly focused window in sway and marks it with '_prev'
#!/bin/sh
prev_focus=$(swaymsg -r -t get_seats | jq '.[0].focus')
swaymsg -m -t subscribe '["window"]' | \
jq --unbuffered 'select(.change == "focus").container.id' | \
while read new_focus; do
swaymsg "[con_id=${prev_focus}] mark --add _prev" &>/dev/null
prev_focus=$new_focus
done
@ckafi
Copy link
Author

ckafi commented Feb 1, 2024

You can find a somewhat expanded version (incl. i3 support) here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment