diff options
author | Adam T. Carpenter <atc@53hor.net> | 2020-12-27 08:44:24 -0500 |
---|---|---|
committer | Adam T. Carpenter <atc@53hor.net> | 2020-12-27 08:44:24 -0500 |
commit | 5ac1d40fe8a9f968d7937d3a30824883d0547d21 (patch) | |
tree | 5b9131883d9d418fb200377f99c802031d3e1543 | |
parent | 45f61ff80062ec9137c0d77f3b732bc1a4f59179 (diff) | |
download | scripts-5ac1d40fe8a9f968d7937d3a30824883d0547d21.tar.xz scripts-5ac1d40fe8a9f968d7937d3a30824883d0547d21.zip |
fixed up docking mechanism
-rwxr-xr-x | dockd.sh | 65 | ||||
-rwxr-xr-x | i3-filescmd.sh | 2 |
2 files changed, 45 insertions, 22 deletions
@@ -1,7 +1,14 @@ #!/bin/sh +#set -x +# To dock: +# - set DP-2 (external monitor) to primary output +# - restart i3 to get scaling correct via themer +# - set default sound unit to external speakers +# - disable laptop lid close sleep +# - disable auto locking and sleeping dock() { - echo Docking... + notify-send Docking... xrandr \ --output DP-0 --off \ --output DP-1 --off \ @@ -9,18 +16,21 @@ dock() { --output DP-3 --off \ --output DP-4 --off \ --output VGA-0 --off - killall xautolock - xautolock \ - -notify 10 \ - -time 10 \ - -locker "i3lock -n -f -c 000000 -i ~/.local/share/wallpapers/lock.png; sleep 0.2" \ - -notifier "notify-send -t=10000 '10 seconds to lock...'" + themer.sh -r sysctl hw.snd.default_unit=1 - echo Docked + doas sysctl hw.acpi.lid_switch_state=NONE + killall xautolock + notify-send Docked. } +# To un-dock: +# - set DP-3 (internal screen) to primary output +# - restart i3 to get scaling correct via themer +# - set default sound unit to builtin speakers +# - enable laptop lid close sleep +# - enable auto locking and sleeping undock() { - echo Undocking... + notify-send Undocking... xrandr \ --output DP-0 --off \ --output DP-1 --off \ @@ -28,6 +38,9 @@ undock() { --output DP-3 --primary --mode 1920x1080 --transform none --pos 0x0 --rotate normal --dpi 96 \ --output DP-4 --off \ --output VGA-0 --off + themer.sh -r + sysctl hw.snd.default_unit=4 + doas sysctl hw.acpi.lid_switch_state=S3 killall xautolock xautolock \ -killtime 10 \ @@ -35,20 +48,30 @@ undock() { -notify 10 \ -time 10 \ -locker "i3lock -n -f -c 000000 -i ~/.local/share/wallpapers/lock.png; sleep 0.2" \ - -notifier "notify-send -t=10000 '10 seconds to lock...'" - sysctl hw.snd.default_unit=4 - echo Undocked + -notifier "notify-send -t=10000 '10 seconds to lock...'" & + notify-send Undocked } -while : -do - is_lid_open=$(sysctl -n dev.acpi_lid.0.state) +contains() { + string="$1" + sub="$2" + [ "${string#*$sub}" != "$string" ] && return 0 || return 1 +} - if [ "$is_lid_open" != "$was_lid_open" ] - then - was_lid_open=$is_lid_open - [ "$is_lid_open" = "0" ] && dock || undock - fi +# start assuming undocked +undock - sleep 10 +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 done + diff --git a/i3-filescmd.sh b/i3-filescmd.sh index fc4a53c..ac47cdf 100755 --- a/i3-filescmd.sh +++ b/i3-filescmd.sh @@ -1,3 +1,3 @@ #!/bin/sh -alacritty -e zsh -c "cat ~/.config/wpg/sequences && vifm" +alacritty -e zsh -c "cat ~/.config/wpg/sequences && vifm ~/downloads ~" |