1

In some of my scripts I need to know if my Thinkpad is docked or not. So far I'm just checking if any of the peripherals attached to the docking station can be found. For example I use xrandr or get-edid to get the list of attached monitors and understand if the laptop is docked.

However I see in the syslog that the kernel can see the docking event but I don't want to parse syslog looking for "docking something".

Do you know some smart way to check from bash if the laptop is docked without relying on the attached peripherals? It would be cool if I could both catch the docking/undocking event when it happens and check the docking status at any time.

1

thanks to reddit I've got the solution to both the situations.

Apparently Dockd can be used to catch the docking event and also to query the docking status at any time.

Also /sys/ can be used. The branch /sys/devices/platform/dock.2/docked provides docking status as boolean value.

  • Welcome to Unix.SE! Please accept your own answer, once the timeout expires. Also note that the .2 in platform/dock.2 varies. – Stephen Kitt Jan 7 at 8:29

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.