Files
dotfiles/machines/desktop/config/sway/toggle-hdmi.sh

18 lines
346 B
Bash
Executable File

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