fix display.sh
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQT/foVVmI9pK13hPWFohAcXSWbK8wUCZvVjKwAKCRBohAcXSWbK 891BAQCo9YqpM1V/0Bf4fjC0UAySbFcQbPAkrhVqVOO/DdVHmAD9FW0T4doEM9qJ vqqEUjtrn7WLlsb83JEx2dV7n59jKA0= =20UT -----END PGP SIGNATURE-----
1 files changed,
8 insertions(+),
9 deletions(-)
jump to
M
display.sh
→
display.sh
@@ -1,7 +1,6 @@
#!/bin/sh # stateful script to manage dual monitor setups -# c read_cfg() { if [ -f ~/.config/xrandr ]; then@@ -9,9 +8,6 @@ . ~/.config/xrandr
fi if [ -z "${PRIMARY_MONITOR}" ]; then PRIMARY_MONITOR=$(get_default_monitor) - fi - if [ -z "${SECONDARY_MONITOR}" ]; then - SECONDARY_MONITOR=$(get_default_monitor) fi if [ -z "${MONITOR_RELATION}" ]; then MONITOR_RELATION="solo"@@ -30,13 +26,16 @@ }
apply_monitor_cfg() { xrandr --output ${PRIMARY_MONITOR} --auto --primary - if [ ${PRIMARY_MONITOR} != ${SECONDARY_MONITOR} ]; then + if [ ! -z "${SECONDARY_MONITOR}" ] && [ "${SECONDARY_MONITOR}" != "${PRIMARY_MONITOR}" ]; then case ${MONITOR_RELATION} in solo) xrandr --output ${SECONDARY_MONITOR} --off ;; - left_of|right_of|above|below) - xrandr --output ${SECONDARY_MONITOR} --auto ${MONITOR_RELATION} ${PRIMARY_MONITOR} ;; + left-of|right-of|above|below) + xrandr --output ${SECONDARY_MONITOR} --auto --${MONITOR_RELATION} ${PRIMARY_MONITOR} ;; esac + else + echo "SECONDARY_MONITOR is not set, or same as PRIMARY_MONITOR:" + show_cfg fi }@@ -50,8 +49,8 @@ printf " secondary: set secondary monitor\n"
printf " relation: set monitor relation\n" printf " reconfigure: set monitor config based on the relation\n" printf " relations:\n" - printf " solo: disable secondary monitor if different from primary\n" - printf " left_of,right_of,above,below: secondary monitor has named relation to primary\n" + printf " solo: disable secondary monitor\n" + printf " left-of,right-of,above,below: secondary monitor has named relation to primary\n" } read_cfg