summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2020-12-31 10:04:32 -0500
committerAdam T. Carpenter <atc@53hor.net>2020-12-31 10:04:32 -0500
commit8584c55f197b70ce66e8e214ad720a6b623ebfdb (patch)
tree725d3e56b1dc8bfac20729b52fe897b6bfdc39f4
parent96140b0354597ca0b535e55e250c0b4d89fb1766 (diff)
downloadscripts-8584c55f197b70ce66e8e214ad720a6b623ebfdb.tar.xz
scripts-8584c55f197b70ce66e8e214ad720a6b623ebfdb.zip
using nvidia-settings to configure outputs instead of xrandr
-rwxr-xr-xdockd.sh45
1 files 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