summaryrefslogtreecommitdiff
path: root/.local/bin/bspwm_enforce_monitor_position
blob: 8dfff3c230fa44cddf45a9474953571214fe6bdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/sh
# Taken from:
# https://github.com/baskerville/bspwm/issues/679

# Get monitor id and monitor position from passed arguments.
MON_ID=$(bspc query -M -m "$1")
MON_POS="$2"

# Initial swap to main monitor.
[ $(bspc query -M -m "$MON_POS") != "$MON_ID" ] && bspc monitor "$MON_POS" -s "$MON_ID"

# Keep checking for monitor swaps.
bspc subscribe monitor_swap | while read msg ; do
	[ $(bspc query -M -m "$MON_POS") != "$MON_ID" ] && bspc monitor "$MON_POS" -s "$MON_ID"
done