From bd12f4693487e70b67316bf14294414caf00418e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20Ob=C5=AFrka?= Date: Thu, 26 Feb 2015 12:54:54 +0100 Subject: Unify API of the functions --- autodetect.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/autodetect.sh b/autodetect.sh index 9c11e85..f37575a 100755 --- a/autodetect.sh +++ b/autodetect.sh @@ -20,8 +20,9 @@ XRANDR="$(xrandr -q)" get_resolution() { grep -A1 "^$1\s*connected" | tail -n1 | awk '{print $1 }' } + detect_status() { - echo "$XRANDR" | sed -n -e "s/^$1\s*\([a-z]*\)\s*.*$/\1/p" + sed -n -e "s/^$1\s*\([a-z]*\)\s*.*$/\1/p" } detect_connected() { @@ -48,14 +49,14 @@ handle_non_exist_mode() { } ## Get notebook display status -NOTE_STATUS="$(detect_status "$NOTE_NAME")" +NOTE_STATUS="$(echo "$XRANDR" | detect_status "$NOTE_NAME")" ## Try to detect some external displays and theirs resolution EXT1_NAME="$(echo "$XRANDR" | grep -v "$NOTE_NAME" | detect_connected | head -n 1)" if [ -n "$EXT1_NAME" ]; then - EXT1_STATUS="$(detect_status "$EXT1_NAME")" + EXT1_STATUS="$(echo "$XRANDR" | detect_status "$EXT1_NAME")" EXT2_NAME="$(echo "$XRANDR" | grep -v "\($NOTE_NAME\|$EXT1_NAME\)" | detect_connected | head -n 1)" - [ -n "$EXT2_NAME" ] && EXT2_STATUS="$(detect_status "$EXT2_NAME")" + [ -n "$EXT2_NAME" ] && EXT2_STATUS="$(echo "$XRANDR" | detect_status "$EXT2_NAME")" fi NOTE_MAX="$(echo "$XRANDR" | get_resolution "$NOTE_NAME")" EXT1_MAX="$(echo "$XRANDR" | get_resolution "$EXT1_NAME")" -- cgit v1.2.3