summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Robin Obůrka <r.oburka@gmail.com> 2016-10-11 21:53:35 +0200
committerGravatar Robin Obůrka <r.oburka@gmail.com> 2016-10-11 21:53:35 +0200
commit3a51227ee9974919457f49ba7b19440b8e26f09f (patch)
treef39caccbe0a80fea4877cc16bbe2211ade1c2085
parentautodetect: Try to fix restore process (diff)
downloaddisplay_autoset-3a51227ee9974919457f49ba7b19440b8e26f09f.tar.xz
autodetect: Query xrandr as function
It should be useful later. E.g. to define some timeout.
-rwxr-xr-xautodetect.sh8
1 files changed, 6 insertions, 2 deletions
diff --git a/autodetect.sh b/autodetect.sh
index 6f13330..6a7b6d4 100755
--- a/autodetect.sh
+++ b/autodetect.sh
@@ -54,12 +54,16 @@ handle_non_exist_mode() {
xrandr --dpi "$DPI" $(off_except "$1" "$2") --output $2 --mode $4 --output $1 --mode $3 --left-of $2
}
+query_xrandr() {
+ xrandr -q
+}
+
compute_hash() {
echo "$1" | sha1sum | cut -d' ' -f1
}
## Query current settings
-XRANDR="$(xrandr -q)"
+XRANDR="$(query_xrandr)"
HASH="$(compute_hash "$XRANDR")"
## Get notebook display status
@@ -130,7 +134,7 @@ elif [ "$EXT2_STATUS" = "disconnected" -a "$NOTE_STATUS" = "connected" -a "$EXT1
fi
## Query current status
-XRANDR="$(xrandr -q)"
+XRANDR="$(query_xrandr)"
HASH="$(compute_hash "$XRANDR")"
## Restore known profile