]> git.sthu.org Git - shutils.git/commitdiff
X: Add xrandr scripts
authorStefan Huber <shuber@sthu.org>
Sun, 17 Dec 2023 09:27:11 +0000 (10:27 +0100)
committerStefan Huber <shuber@sthu.org>
Sun, 17 Dec 2023 09:27:11 +0000 (10:27 +0100)
X/xrandr-exttomirror [new file with mode: 0755]
X/xrandr-exttoright [new file with mode: 0755]
X/xrandr-single [new file with mode: 0755]

diff --git a/X/xrandr-exttomirror b/X/xrandr-exttomirror
new file mode 100755 (executable)
index 0000000..4f1d3ec
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+set -e
+
+MAIN=$(xrandr | grep eDP | cut -f1 -d" ")
+if [ "${MAIN}" = "" ]; then
+       echo "Could not find main display."
+       exit 1
+fi
+
+OTHER=$(xrandr | grep "\<connected\>" | grep -v eDP | cut -f1 -d" ")
+if [ "${OTHER}" = "" ]; then
+       echo "Could not find external display."
+       exit 1
+fi
+
+echo "Set ${MAIN} as mirror of ${OTHER}"
+
+xrandr --output ${OTHER} --auto --output ${MAIN} --same-as ${OTHER} --primary
diff --git a/X/xrandr-exttoright b/X/xrandr-exttoright
new file mode 100755 (executable)
index 0000000..fca0aa6
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+set -e
+
+MAIN=$(xrandr | grep eDP | cut -f1 -d" ")
+if [ "${MAIN}" = "" ]; then
+       echo "Could not find main display."
+       exit 1
+fi
+
+OTHER=$(xrandr | grep "\<connected\>" | grep -v eDP | cut -f1 -d" ")
+if [ "${OTHER}" = "" ]; then
+       echo "Could not find external display."
+       exit 1
+fi
+
+echo "Bring ${OTHER} right of ${MAIN}"
+
+xrandr --output ${MAIN} --auto --primary; xrandr --output ${OTHER} --auto; xrandr --output ${OTHER} --auto --right-of ${MAIN}
diff --git a/X/xrandr-single b/X/xrandr-single
new file mode 100755 (executable)
index 0000000..174a0df
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+set -e
+
+MAIN=$(xrandr | grep eDP | cut -f1 -d" ")
+if [ "${MAIN}" = "" ]; then
+       echo "Could not find main display."
+       exit 1
+fi
+
+echo "Set ${MAIN} as primary"
+xrandr --output ${MAIN} --auto --primary
+
+OTHER=$(xrandr | grep "\<connected\>" | grep -v eDP | cut -f1 -d" ")
+if [ "${OTHER}" = "" ]; then
+       echo "Could not find external display."
+       exit 1
+fi
+
+echo "Set ${OTHER} off"
+xrandr --output ${OTHER} --off