From 8584c55f197b70ce66e8e214ad720a6b623ebfdb Mon Sep 17 00:00:00 2001 From: "Adam T. Carpenter" Date: Thu, 31 Dec 2020 10:04:32 -0500 Subject: using nvidia-settings to configure outputs instead of xrandr --- dockd.sh | 45 ++++++++++++--------------------------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/dockd.sh b/dockd.sh index 2ac4ef6..62167f2 100755 --- a/dockd.sh +++ b/dockd.sh @@ -8,13 +8,7 @@ # - disable laptop lid close sleep # - disable auto locking and sleeping dock() { - xrandr \ - --output DP-0 --off \ - --output DP-1 --off \ - --output DP-2 --primary --mode 2560x1440 --pos 0x0 --rotate normal --dpi 96 \ - --output DP-3 --off \ - --output DP-4 --off \ - --output VGA-0 --off + nvidia-settings --assign CurrentMetaMode="DP-2:nvidia-auto-select +0+0 { ForceCompositionPipeline = On }" themer.sh -r sysctl hw.snd.default_unit=1 doas sysctl hw.acpi.lid_switch_state=NONE @@ -29,13 +23,7 @@ dock() { # - enable laptop lid close sleep # - enable auto locking and sleeping undock() { - xrandr \ - --output DP-0 --off \ - --output DP-1 --off \ - --output DP-2 --off \ - --output DP-3 --primary --mode 1920x1080 --transform none --pos 0x0 --rotate normal --dpi 96 \ - --output DP-4 --off \ - --output VGA-0 --off + nvidia-settings --assign CurrentMetaMode="DP-3:nvidia-auto-select +0+0 { ForceCompositionPipeline = On }" themer.sh -r sysctl hw.snd.default_unit=4 doas sysctl hw.acpi.lid_switch_state=S3 @@ -50,26 +38,17 @@ undock() { notify-send Undocked } -contains() { - string="$1" - sub="$2" - [ "${string#*$sub}" != "$string" ] && return 0 || return 1 -} - -# start assuming undocked -undock - while sleep 5 do - xrandr=$(xrandr) - - # if DP-2 is disconnected and primary then undock - contains "$xrandr" "DP-2 disconnected primary" \ - && undock \ - && continue - # if DP-2 is connected but isn't primary then dock - contains "$xrandr" "DP-3 connected primary" \ - && contains "$xrandr" "DP-2 connected" \ - && dock + case "$(xrandr)" in + "DP-2 disconnected primary") + # if DP-2 is disconnected and primary then undock + undock + ;; + "DP-2 connected (") + # if DP-2 is connected but isn't primary then dock + dock + ;; + esac done -- cgit v1.2.3