From: Phillip Berndt Date: Sun, 20 Jul 2014 10:38:40 +0000 (+0200) Subject: Inform users about virtual configurations, prevent name collisions, prefer existing... X-Git-Tag: 1.0~134 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=9c9a60325749758c1aa86cd4a9648a041e3986ef;hp=8c7260f4209ed7bd572c51c3898f81cc7e6c519b;p=deb_pkgs%2Fautorandr.git Inform users about virtual configurations, prevent name collisions, prefer existing configuration files over virtual configurations --- diff --git a/autorandr b/autorandr index e455700..37f6eed 100755 --- a/autorandr +++ b/autorandr @@ -49,6 +49,9 @@ DISPER=/usr/bin/disper XDPYINFO=/usr/bin/xdpyinfo PROFILES=~/.autorandr/ CONFIG=~/.autorandr.conf +RESERVED_PROFILE_NAMES=`cat < setting largest common mode" - common_cfg_xrandr - else + if [ -f "$CONF" ]; then echo " -> loading profile $PROFILE" + if [ -n $IS_VIRTUAL_PROFILE ]; then + echo " -> Warning: Existing profile overrides virtual profile with same name" >&2 + fi $LOAD_METHOD "$CONF" + else + # Virtual profiles + if [ $PROFILE = "common" ]; then + echo " -> setting largest common mode" + common_cfg_xrandr + fi fi if [ -x "$PROFILES/$PROFILE/postswitch" ]; then @@ -315,6 +325,9 @@ Usage: $SCRIPTNAME [options] When called by the name "autodisper" or "auto-disper", the script uses "disper" instead of "xrandr" to detect, configure and save the display configuration. + If xrandr is used, the following virtual configurations are available: + ${RESERVED_PROFILE_NAMES} + EOH exit } @@ -341,6 +354,10 @@ done CURRENT_SETUP="$(setup_fp)" if [ -n "$SAVE_PROFILE" ]; then + if echo "$RESERVED_PROFILE_NAMES" | grep -q " $SAVE_PROFILE "; then + echo "Cannot save current configuration as profile '${SAVE_PROFILE}': This configuration name is a reserved virtual configuration." + exit 1 + fi echo "Saving current configuration as profile '${SAVE_PROFILE}'" mkdir -p "$PROFILES/$SAVE_PROFILE" echo "$CURRENT_SETUP" > "$PROFILES/$SAVE_PROFILE/setup"