#!/bin/sh set -eu OUTPUT="HDMI-A-2" active="$(swaymsg -t get_outputs -r \ | jq -r --arg o "$OUTPUT" '.[] | select(.name==$o) | .active')" case "$active" in true) swaymsg output "$OUTPUT" disable ;; false) swaymsg output "$OUTPUT" enable ;; *) printf 'Output %s not found or jq parse error\n' "$OUTPUT" >&2 exit 1 ;; esac