summaryrefslogtreecommitdiffstats
path: root/autodetect.sh
diff options
context:
space:
mode:
authorGravatar Robin Obůrka <r.oburka@gmail.com> 2015-02-26 12:54:54 +0100
committerGravatar Robin Obůrka <r.oburka@gmail.com> 2015-02-26 12:54:54 +0100
commitbd12f4693487e70b67316bf14294414caf00418e (patch)
tree08d212dd8118088f7f1b741b1d8367eb955566fb /autodetect.sh
parentFix resolution parser and move it to function (diff)
downloaddisplay_autoset-bd12f4693487e70b67316bf14294414caf00418e.tar.xz
Unify API of the functions
Diffstat (limited to 'autodetect.sh')
-rwxr-xr-xautodetect.sh9
1 files 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")"