From b3bdb1f6027d0140ffa08b89618cf862c872615f Mon Sep 17 00:00:00 2001 From: Iris Lightshard Date: Thu, 26 Sep 2024 07:35:39 -0600 Subject: [PATCH] fix display.sh --- display.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/display.sh b/display.sh index d641147..3463146 100755 --- a/display.sh +++ b/display.sh @@ -1,7 +1,6 @@ #!/bin/sh # stateful script to manage dual monitor setups -# c read_cfg() { if [ -f ~/.config/xrandr ]; then @@ -10,9 +9,6 @@ read_cfg() { 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" fi @@ -30,13 +26,16 @@ get_default_monitor() { 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 @@ helpme() { 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