]> 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 1635ce5c5a2847935033584067d0c21cd8535564..90d110831ba0a9efe1c3f2aeefdeb3aa1ae799e0 100755 (executable)
--- a/autorandr
+++ b/autorandr
@@ -135,13 +135,15 @@ current_cfg_xrandr() {
                if (($4 == "left") || ($4 == "right")) {
                        split(A[1], B, "x");
                        A[1] = B[2]"x"B[1];
+               }
+               print "mode "A[1];
+               print "pos "A[2]"x"A[3];
+               if ($4 !~ /^\(/) {
                        print "rotate "$4;
                }
                else {
                        print "rotate normal";
                }
-               print "mode "A[1];
-               print "pos "A[2]"x"A[3];
                next;
        }
        # disconnected or disabled displays
@@ -210,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
 }