summaryrefslogtreecommitdiffstats
path: root/.scripts/i3cmds/displayselect
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2018-11-05 17:51:24 -0500
committerLuke Smith <luke@lukesmith.xyz>2018-11-05 17:51:24 -0500
commit2f4c2a68a1cbebb0e06a5b3296e4bbb575c5fcb2 (patch)
tree4adda53569104861794d990ef99c85edc1ae2d8c /.scripts/i3cmds/displayselect
parentcd667e6aa111c86b40b9e3104605953e9b341332 (diff)
downloadeibhear-2f4c2a68a1cbebb0e06a5b3296e4bbb575c5fcb2.tar.gz
eibhear-2f4c2a68a1cbebb0e06a5b3296e4bbb575c5fcb2.tar.zst
eibhear-2f4c2a68a1cbebb0e06a5b3296e4bbb575c5fcb2.zip
scripts sorted
Diffstat (limited to '.scripts/i3cmds/displayselect')
-rwxr-xr-x.scripts/i3cmds/displayselect49
1 files changed, 49 insertions, 0 deletions
diff --git a/.scripts/i3cmds/displayselect b/.scripts/i3cmds/displayselect
new file mode 100755
index 0000000..e36d214
--- /dev/null
+++ b/.scripts/i3cmds/displayselect
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+# A UI for detecting and selecting all displays.
+# Probes xrandr for connected displays and lets user select one to use.
+# User may also select "manual selection" which opens arandr.
+# I plan on adding a routine from multi-monitor setups later.
+
+twoscreen() { # If multi-monitor is selected and there are two screens.
+ primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
+ secondary=$(echo "$screens" | grep -v "$primary")
+ direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
+ xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto
+ }
+
+morescreen() { # If multi-monitor is selected and there are more than two screens.
+ primary=$(echo "$screens" | dmenu -i -p "asdf")
+ secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:")
+ direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
+ tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:")
+ xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" --auto
+ }
+
+multimon() { # Multi-monitor handler.
+ case "$(echo "$screens" | wc -l)" in
+ 1) xrandr $(echo "$allposs" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;;
+ 2) twoscreen ;;
+ *) morescreen ;;
+ esac ;}
+
+# Get all possible displays
+allposs=$(xrandr -q | grep "connected")
+
+# Get all connected screens.
+screens=$(echo "$allposs" | grep " connected" | awk '{print $1}')
+
+# Get user choice including multi-monitor and manual selection:
+chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") &&
+case "$chosen" in
+ "manual selection") arandr ; exit ;;
+ "multi-monitor") multimon ;;
+ *) xrandr --output "$chosen" --auto $(echo "$screens" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;;
+esac
+
+# Fix feh background if screen size/arangement has changed.
+feh --bg-scale "$HOME/.config/wall.png"
+# Polybar users will want to uncomment this line, which reactivates polybar on all new displays:
+#polybar_launch
+# Re-remap keys if keyboard added (for laptop bases)
+remaps