summaryrefslogtreecommitdiffstats
path: root/autodetect.sh
diff options
context:
space:
mode:
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")"