How to detect and run custom scripts on docking / un-docking of ThinkPad?

6

I'd like to run custom scripts on docking or un-docking my ThinkPad X220.

Obvious place is some udev rule, but what events or attributes should I use? Another option is acpi. Is it better option? What else comes as viable alternative? I am running Debian, a mix between squeeze, backports, wheeze... and sid. Is there any native solution?

Matej Kovac

Posted 2013-02-22T08:27:48.553

Reputation: 366

I have no way to test this myself but here's a suggestion: look through the messages generated by the kernel dmesg or syslog messages to check what messages are generated when you dock/undock. If you do see a notification you should be able to tie the event that generates the message to your script. – dinesh – 2013-02-23T16:56:56.723

Answers

1

I found the right tool on top of udev (and other low level interfaces like sysfs), configurable to everyone's taste. It's called laptop-mode-tools one of zilions of Debian packages (available for other distros at http://www.samwel.tk/laptop_mode/).

Matej Kovac

Posted 2013-02-22T08:27:48.553

Reputation: 366

0

You can also use ACPI events to hook into the docking/undocking events if you install the ThinkPad kernel module: https://feeding.cloud.geek.nz/posts/hooking-into-docking-undocking-events-to-run-scripts/

Francois Marier

Posted 2013-02-22T08:27:48.553

Reputation: 126