From 3e084966b78af04d22bd94c2f17a5c0a744b1372 Mon Sep 17 00:00:00 2001 From: Sebastian Schulze Date: Thu, 9 Jun 2022 08:55:24 +0200 Subject: [PATCH] [bin] Rework thinkpad-dock script to work on both Laptops --- bin/executable_thinkpad-dock | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/bin/executable_thinkpad-dock b/bin/executable_thinkpad-dock index 1fdbcdf..19e993d 100644 --- a/bin/executable_thinkpad-dock +++ b/bin/executable_thinkpad-dock @@ -2,8 +2,8 @@ # 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 [[ "${NAME}" != '"ZSA Technology Labs Inc ErgoDox EZ Shine Keyboard"' ]] && - [[ "${NAME}" != '"ZSA Technology Labs Planck EZ Glow Keyboard"' ]]; then +if [[ "${ACTION}" != "" && "${NAME}" != '"ZSA Technology Labs Inc ErgoDox EZ Shine Keyboard"' ]] && + [[ "${ACTION}" != "" && "${NAME}" != '"ZSA Technology Labs Planck EZ Glow Keyboard"' ]]; then echo "Skipping superfluous events for ${NAME}" >> /tmp/thinkpad.log exit 0 fi; @@ -16,16 +16,30 @@ export DBUS_SESSION_BUS_ADDRESS TITLE="Docking Station: ${ACTION} ${NAME}" /home/bascht/.nix-profile/bin/notify-send -t 3000 "$TITLE" + sleep 0.5 -if [[ "$ACTION" == "add" ]]; then +# 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 Inc 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;