diff options
author | Robin Obůrka <r.oburka@gmail.com> | 2015-03-27 18:35:49 +0100 |
---|---|---|
committer | Robin Obůrka <r.oburka@gmail.com> | 2015-03-27 18:35:49 +0100 |
commit | 585b329c8b9c3caa6593ac987eb2b6f96b74bfee (patch) | |
tree | ba6a93a89c0312357f8d488537993246c8d01546 /autodetect.sh | |
parent | Typo (diff) | |
download | display_autoset-585b329c8b9c3caa6593ac987eb2b6f96b74bfee.tar.xz |
Change definition of "profile"
Hash is computed from active displays
Diffstat (limited to 'autodetect.sh')
-rwxr-xr-x | autodetect.sh | 24 |
1 files 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 }')" |