2021-10-01 11:02:19 +02:00
|
|
|
#!/usr/bin/env bash
|
2022-07-29 19:51:39 +02:00
|
|
|
set -xv
|
2021-10-01 11:02:19 +02:00
|
|
|
|
|
|
|
# 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.
|
2022-06-09 08:55:24 +02:00
|
|
|
if [[ "${ACTION}" != "" && "${NAME}" != '"ZSA Technology Labs Inc ErgoDox EZ Shine Keyboard"' ]] &&
|
2022-07-29 19:51:39 +02:00
|
|
|
[[ "${ACTION}" != "" && "${NAME}" != '"ZSA Technology Labs ErgoDox EZ Shine Keyboard"' ]] &&
|
2022-06-09 08:55:24 +02:00
|
|
|
[[ "${ACTION}" != "" && "${NAME}" != '"ZSA Technology Labs Planck EZ Glow Keyboard"' ]]; then
|
2021-10-01 11:02:19 +02:00
|
|
|
exit 0
|
|
|
|
fi;
|
|
|
|
|
2022-04-09 21:23:50 +02:00
|
|
|
SWAYSOCK=/run/user/$(id -u)/sway-ipc.sock
|
2021-10-01 11:02:19 +02:00
|
|
|
DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u)/bus"
|
|
|
|
export SWAYSOCK
|
|
|
|
export DBUS_SESSION_BUS_ADDRESS
|
|
|
|
|
2022-07-29 19:51:39 +02:00
|
|
|
if [[ "${ACTION}" == "add" ]]; then
|
|
|
|
ICON=$(readlink -f ~/.nix-profile/share/icons/gnome/48x48/devices/computer.png)
|
|
|
|
else
|
|
|
|
ICON=$(readlink -f ~/.nix-profile/share/icons/gnome/48x48/devices/display.png)
|
|
|
|
fi;
|
2021-10-01 11:02:19 +02:00
|
|
|
|
2022-07-29 19:51:39 +02:00
|
|
|
TITLE="${ACTION} ${NAME}"
|
|
|
|
/home/bascht/.nix-profile/bin/notify-send -t 3000 --icon="${ICON}" "Docking event" "$TITLE"
|
2022-06-09 08:55:24 +02:00
|
|
|
|
2021-10-01 11:02:19 +02:00
|
|
|
sleep 0.5
|
|
|
|
|
2022-06-09 08:55:24 +02:00
|
|
|
# Home and at my main desk
|
|
|
|
if swaymsg -t get_inputs | grep "ZSA Technology Labs Inc ErgoDox EZ Shine"; then
|
|
|
|
if grep closed /proc/acpi/button/lid/LID/state; then
|
|
|
|
swaymsg output eDP-1 disable
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Home and on the side desk
|
2022-06-10 08:16:24 +02:00
|
|
|
elif swaymsg -t get_inputs | grep "ZSA Technology Labs Planck EZ Glow"; then
|
2021-10-07 09:21:23 +02:00
|
|
|
if grep closed /proc/acpi/button/lid/LID/state; then
|
|
|
|
swaymsg output eDP-1 disable
|
|
|
|
fi
|
2022-06-09 08:55:24 +02:00
|
|
|
|
|
|
|
# Whereever else
|
2021-10-01 11:02:19 +02:00
|
|
|
else
|
2022-08-11 16:34:00 +02:00
|
|
|
if ! swaymsg -t get_outputs | jq -e '.[] | select(.name == "eDP-1" and .active == true)'
|
|
|
|
swaymsg output eDP-1 enable
|
|
|
|
fi
|
2021-10-01 11:02:19 +02:00
|
|
|
fi;
|