From 79de974d7a658d2a8f3e27f5af10e7d918c5de44 Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Wed, 13 May 2026 13:43:30 +0100 Subject: feat(waybar): add dock indicator next to battery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Detects the ThinkPad USB-C Dock Gen2 by its built-in ethernet adapter (USB 17ef:a387) — the dock's USB hubs share product IDs with internal ThinkPad hubs but the ethernet only exists when the dock is attached. The custom/dock module sits to the left of battery; collapses to empty text when undocked so the bar stays clean on the go. Green dock glyph when docked. --- dot_config/waybar/executable_dock-status.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 dot_config/waybar/executable_dock-status.sh (limited to 'dot_config/waybar/executable_dock-status.sh') diff --git a/dot_config/waybar/executable_dock-status.sh b/dot_config/waybar/executable_dock-status.sh new file mode 100644 index 0000000..501bb7d --- /dev/null +++ b/dot_config/waybar/executable_dock-status.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# Detect a Lenovo ThinkPad USB-C Dock Gen2 by its distinctive built-in +# ethernet adapter (17ef:a387). The dock's USB hubs share product IDs +# with internal ThinkPad hubs on some models, but the ethernet is only +# present when the dock is physically attached. +# +# Output is a single waybar JSON record. When undocked, "text" is empty +# so waybar collapses the module — no clutter on the bar when on the go. + +set -eu + +docked=0 +for dev in /sys/bus/usb/devices/*/; do + [ -f "$dev/idVendor" ] && [ -f "$dev/idProduct" ] || continue + v=$(cat "$dev/idVendor") + p=$(cat "$dev/idProduct") + if [ "$v" = "17ef" ] && [ "$p" = "a387" ]; then + docked=1 + break + fi +done + +if [ "$docked" -eq 1 ]; then + printf '{"text":"󰧹","tooltip":"Docked: ThinkPad USB-C Dock Gen2","class":"docked","alt":"docked"}\n' +else + printf '{"text":"","tooltip":"Undocked","class":"undocked","alt":"undocked"}\n' +fi -- cgit v1.3.1