]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/blobdiff - autorandr
fix load() causing 'exit 1' on missing optional file $PROFILES/postswitch
[deb_pkgs/autorandr.git] / autorandr
index feababdbb03e1f3bd5fa9f8df999cc7b18c25a39..90d110831ba0a9efe1c3f2aeefdeb3aa1ae799e0 100755 (executable)
--- a/autorandr
+++ b/autorandr
@@ -212,19 +212,22 @@ load_cfg_disper() {
 load() {
        local PROFILE="$1"
        local CONF="$PROFILES/$PROFILE/config"
-       if [ -e "$CONF" ] ; then
-               [ -x "$PROFILES/preswitch" ] && \
-                       "$PROFILES/preswitch" "$PROFILE"
-               [ -x "$PROFILES/$PROFILE/preswitch" ] && \
-                       "$PROFILES/$PROFILE/preswitch" "$PROFILE"
-
-               echo " -> loading profile $PROFILE"
-               $LOAD_METHOD "$CONF"
-
-               [ -x "$PROFILES/$PROFILE/postswitch" ] && \
-                       "$PROFILES/$PROFILE/postswitch" "$PROFILE"
-               [ -x "$PROFILES/postswitch" ] && \
-                       "$PROFILES/postswitch" "$PROFILE"
+       [ -f "$CONF" ] || return 1
+       if [ -x "$PROFILES/preswitch" ]; then
+               "$PROFILES/preswitch" "$PROFILE"
+       fi
+       if [ -x "$PROFILES/$PROFILE/preswitch" ]; then
+               "$PROFILES/$PROFILE/preswitch" "$PROFILE"
+       fi
+
+       echo " -> loading profile $PROFILE"
+       $LOAD_METHOD "$CONF"
+
+       if [ -x "$PROFILES/$PROFILE/postswitch" ]; then
+               "$PROFILES/$PROFILE/postswitch" "$PROFILE"
+       fi
+       if [ -x "$PROFILES/postswitch" ]; then
+               "$PROFILES/postswitch" "$PROFILE"
        fi
 }