From 3a51227ee9974919457f49ba7b19440b8e26f09f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20Ob=C5=AFrka?= Date: Tue, 11 Oct 2016 21:53:35 +0200 Subject: autodetect: Query xrandr as function It should be useful later. E.g. to define some timeout. --- autodetect.sh | 8 ++++++-- 1 file 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 -- cgit v1.2.3