#!/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