46 lines
1.5 KiB
Bash
46 lines
1.5 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Watch for the Keyboard instead of the Thinkpad dock since this keeps us from tripping
|
|
# into weird race conditions as the docks usb hub takes a few seconds to settle.
|
|
if [[ "${ACTION}" != "" && "${NAME}" != '"ZSA Technology Labs Inc ErgoDox EZ Shine Keyboard"' ]] &&
|
|
[[ "${ACTION}" != "" && "${NAME}" != '"ZSA Technology Labs ErgoDox EZ Shine Keyboard"' ]]; then
|
|
[[ "${ACTION}" != "" && "${NAME}" != '"ZSA Technology Labs Planck EZ Glow Keyboard"' ]]; then
|
|
exit 0
|
|
fi;
|
|
|
|
SWAYSOCK=/run/user/$(id -u)/sway-ipc.sock
|
|
DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u)/bus"
|
|
export SWAYSOCK
|
|
export DBUS_SESSION_BUS_ADDRESS
|
|
|
|
TITLE="Docking Station: ${ACTION} ${NAME}"
|
|
/home/bascht/.nix-profile/bin/notify-send -t 3000 "$TITLE"
|
|
|
|
|
|
sleep 0.5
|
|
|
|
# Home and at my main desk
|
|
if swaymsg -t get_inputs | grep "ZSA Technology Labs Inc ErgoDox EZ Shine"; then
|
|
nmcli connection up "thinkpad-dock"
|
|
nmcli connection down "dorhamm-wifi"
|
|
if grep closed /proc/acpi/button/lid/LID/state; then
|
|
swaymsg output eDP-1 disable
|
|
fi
|
|
|
|
|
|
# Home and on the side desk
|
|
elif swaymsg -t get_inputs | grep "ZSA Technology Labs Planck EZ Glow"; then
|
|
nmcli connection up "dorhamm-docking"
|
|
nmcli connection down "dorhamm-wifi"
|
|
if grep closed /proc/acpi/button/lid/LID/state; then
|
|
swaymsg output eDP-1 disable
|
|
fi
|
|
|
|
# Whereever else
|
|
else
|
|
nmcli connection up "dorhamm-wifi"
|
|
nmcli connection down "dorhamm-docking"
|
|
nmcli connection down "thinkpad-dock"
|
|
swaymsg output eDP-1 enable
|
|
fi;
|