From 8e27c7f4b8730e7200124cf8b2055d3502f2c751 Mon Sep 17 00:00:00 2001 From: Anders Damsgaard Date: Sun, 23 Dec 2018 17:30:42 +0100 Subject: [PATCH 1/4] Add option to mirror displays with external resolution priority --- .scripts/i3cmds/displayselect | 37 ++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/.scripts/i3cmds/displayselect b/.scripts/i3cmds/displayselect index c5f751a..3ffc4f3 100755 --- a/.scripts/i3cmds/displayselect +++ b/.scripts/i3cmds/displayselect @@ -6,11 +6,38 @@ # 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 - } + + mirror=$(printf "no\\nyes" | dmenu -i -p "Mirror displays?") + # Mirror displays using native resolution of external display and a scaled + # version for the internal display + if [ "$mirror" = "yes" ]; then + external=$(echo "$screens" | dmenu -i -p "Select external display:") + internal=$(echo "$screens" | grep -v "$external") + + res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \ + tail -n 1 | awk '{print $1}') + res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" | \ + tail -n 1 | awk '{print $1}') + + res_ext_x=$(echo $res_external | sed 's/x.*//') + res_ext_y=$(echo $res_external | sed 's/.*x//') + res_int_x=$(echo $res_internal | sed 's/x.*//') + res_int_y=$(echo $res_internal | sed 's/.*x//') + + scale_x=$(echo "$res_ext_x / $res_int_x" | bc -l) + scale_y=$(echo "$res_ext_y / $res_int_y" | bc -l) + + xrandr --output "$external" --auto \ + --output "$internal" --auto --same-as "$external" \ + --scale "$scale_x"x"$scale_y" + else + + 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 + fi + } morescreen() { # If multi-monitor is selected and there are more than two screens. primary=$(echo "$screens" | dmenu -i -p "Select primary display:") From b6e21cdf77f7f2c0d9693998c88c60d18a990e64 Mon Sep 17 00:00:00 2001 From: Anders Damsgaard Date: Sun, 23 Dec 2018 17:51:28 +0100 Subject: [PATCH 2/4] Make sure native scaling is restored when selecting single display --- .scripts/i3cmds/displayselect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scripts/i3cmds/displayselect b/.scripts/i3cmds/displayselect index 3ffc4f3..9822b12 100755 --- a/.scripts/i3cmds/displayselect +++ b/.scripts/i3cmds/displayselect @@ -65,7 +65,7 @@ chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p 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' ' ') ;; + *) xrandr --output "$chosen" --auto --scale 1.0x1.0 $(echo "$screens" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; esac # Fix feh background if screen size/arangement has changed. From 505113640df05c22405a13c37baf2d153f91afb5 Mon Sep 17 00:00:00 2001 From: Tom Jansen Date: Sun, 23 Dec 2018 18:07:16 +0100 Subject: [PATCH 3/4] add vfat support to dmenumount --- .scripts/i3cmds/dmenumount | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.scripts/i3cmds/dmenumount b/.scripts/i3cmds/dmenumount index 431141f..661a524 100755 --- a/.scripts/i3cmds/dmenumount +++ b/.scripts/i3cmds/dmenumount @@ -19,7 +19,12 @@ mountusb() { \ chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?" | awk '{print $1}')" sudo -A mount "$chosen" && notify-send "$chosen mounted." && exit 0 getmount "/mnt /media /mount /home -maxdepth 5 -type d" - sudo -A mount "$chosen" "$mp" && notify-send "$chosen mounted to $mp." + partitiontype="$(lsblk -no "fstype" "$chosen")" + case "$partitiontype" in + "vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;; + *) sudo -A mount "$chosen" "$mp";; + esac + notify-send "$chosen mounted to $mp." } mountandroid() { \ From 5bf372c6b0f8128ee46a2b98f6fe098bad9b32ee Mon Sep 17 00:00:00 2001 From: Anders Damsgaard Date: Sun, 23 Dec 2018 19:11:22 +0100 Subject: [PATCH 4/4] Enforce native scale for xrandr commands --- .scripts/i3cmds/displayselect | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.scripts/i3cmds/displayselect b/.scripts/i3cmds/displayselect index 9822b12..0bd612e 100755 --- a/.scripts/i3cmds/displayselect +++ b/.scripts/i3cmds/displayselect @@ -11,7 +11,7 @@ twoscreen() { # If multi-monitor is selected and there are two screens. # Mirror displays using native resolution of external display and a scaled # version for the internal display if [ "$mirror" = "yes" ]; then - external=$(echo "$screens" | dmenu -i -p "Select external display:") + external=$(echo "$screens" | dmenu -i -p "Optimize resolution for:") internal=$(echo "$screens" | grep -v "$external") res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \ @@ -27,7 +27,7 @@ twoscreen() { # If multi-monitor is selected and there are two screens. scale_x=$(echo "$res_ext_x / $res_int_x" | bc -l) scale_y=$(echo "$res_ext_y / $res_int_y" | bc -l) - xrandr --output "$external" --auto \ + xrandr --output "$external" --auto --scale 1.0x1.0 \ --output "$internal" --auto --same-as "$external" \ --scale "$scale_x"x"$scale_y" else @@ -35,7 +35,7 @@ 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 + xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0 fi }