aboutsummaryrefslogtreecommitdiff
path: root/misc/bin/display_toggle.sh
diff options
context:
space:
mode:
Diffstat (limited to 'misc/bin/display_toggle.sh')
-rwxr-xr-xmisc/bin/display_toggle.sh20
1 files changed, 12 insertions, 8 deletions
diff --git a/misc/bin/display_toggle.sh b/misc/bin/display_toggle.sh
index b2c7e5c..e7dfcf5 100755
--- a/misc/bin/display_toggle.sh
+++ b/misc/bin/display_toggle.sh
@@ -1,11 +1,14 @@
#!/bin/bash
-# Assuming there are two displays. A small one (e.g. laptop) and a big
-# one (e.g. monitor). Identify the displays, and toggle between 3
-# states: small one only -> both with the big one to the left of the
-# small one -> big one only
-# small one: <20 inch
-# big one: >20 inch
+# toggle display arrangements.
+
+# If there is only one monitor, then run xrandr --auto
+
+# Otherwise assume there are two displays. A small one (e.g. laptop)
+# and a big one (e.g. monitor). Identify the displays, and toggle
+# between 3 states: small one only -> both with the big one to the
+# left of the small one -> big one only small one: <20 inch big one:
+# >20 inch
# Make sure the variables from pipe can be assigned
# https://stackoverflow.com/questions/42963395/bash-assign-variable-from-pipe
@@ -21,9 +24,10 @@ xrandr | grep " connected " | while IFS=$'\n' read -r line; do
fi
done
+# Only one monitor: run xrandr --auto
if (( i == 1 )); then
- echo "Only one connected display"
- exit 1
+ xrandr --auto
+ exit 0
fi
regex="^.*/([0-9]+)x.*/([0-9]+).* ([^ ]+)$"