From 585b329c8b9c3caa6593ac987eb2b6f96b74bfee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20Ob=C5=AFrka?= Date: Fri, 27 Mar 2015 18:35:49 +0100 Subject: Change definition of "profile" Hash is computed from active displays --- autodetect.sh | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/autodetect.sh b/autodetect.sh index 526ff8d..bade06d 100755 --- a/autodetect.sh +++ b/autodetect.sh @@ -64,13 +64,7 @@ EXT2_MAX="$(echo "$XRANDR" | get_resolution "$EXT2_NAME")" ## Main "profiles" logic ## Start with some special command -if [ "$COMMAND" = "profile" ]; then - HASH="${NOTE_NAME}${NOTE_STATUS}${NOTE_MAX}" - [ -n "$EXT1_NAME" ] && HASH="${HASH}${EXT1_NAME}${EXT1_STATUS}${EXT1_MAX}" - [ -n "$EXT2_NAME" ] && HASH="${HASH}${EXT2_NAME}${EXT2_STATUS}${EXT2_MAX}" - echo "$(echo "$HASH" | sha1sum | awk '{ print $1 }')" - -elif [ "$COMMAND" = "none" ]; then +if [ "$COMMAND" = "none" ]; then # String "killthemall" should be something that is NOT real screen name xrandr $(off_except "killthemall") --output "$NOTE_NAME" --mode "$NOTE_MAX" @@ -112,3 +106,19 @@ elif [ "$EXT2_STATUS" = "disconnected" -a "$NOTE_STATUS" = "connected" -a "$EXT1 xrandr --dpi "$DPI" $(off_except "$NOTE_NAME") --output "$NOTE_NAME" --mode "$NOTE_MAX" fi + +## Query current status +XRANDR="$(xrandr -q)" + +## Compute HASH of this profile +NOTE_ACTIVE="$(echo "$XRANDR" | detect_active "$NOTE_NAME")" +HASH_DATA="${NOTE_NAME}${NOTE_STATUS}${NOTE_MAX}${NOTE_ACTIVE}" +if [ -n "$EXT1_NAME" ]; then + EXT1_ACTIVE="$(echo "$XRANDR" | detect_active "$EXT1_NAME")" + HASH_DATA="${HASH_DATA}${EXT1_NAME}${EXT1_STATUS}${EXT1_MAX}${EXT1_ACTIVE}" +fi +if [ -n "$EXT2_NAME" ]; then + EXT2_ACTIVE="$(echo "$XRANDR" | detect_active "$EXT2_NAME")" + HASH_DATA="${HASH_DATA}${EXT2_NAME}${EXT2_STATUS}${EXT2_MAX}${EXT2_ACTIVE}" +fi +HASH="$(echo "$HASH_DATA" | sha1sum | awk '{ print $1 }')" -- cgit v1.2.3