summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2020-12-27 08:44:24 -0500
committerAdam T. Carpenter <atc@53hor.net>2020-12-27 08:44:24 -0500
commit5ac1d40fe8a9f968d7937d3a30824883d0547d21 (patch)
tree5b9131883d9d418fb200377f99c802031d3e1543
parent45f61ff80062ec9137c0d77f3b732bc1a4f59179 (diff)
downloadscripts-5ac1d40fe8a9f968d7937d3a30824883d0547d21.tar.xz
scripts-5ac1d40fe8a9f968d7937d3a30824883d0547d21.zip
fixed up docking mechanism
-rwxr-xr-xdockd.sh65
-rwxr-xr-xi3-filescmd.sh2
2 files changed, 45 insertions, 22 deletions
diff --git a/dockd.sh b/dockd.sh
index 235035a..b77494d 100755
--- a/dockd.sh
+++ b/dockd.sh
@@ -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 ~"