It seems that Ubuntu runs some script or command when I signal that I want to undock my laptop by pressing the undock button on the dock. Most visible thing that happens is that resolution on external display is changed.
After prepearing for undock my laptop is still connected to power, VGA-output and audio jacks through dock but not to any usb devices or optical drive. I'm running 11.04 on a ThinkPad X61s with X6 UltraBase.
What happens when I signal undocking?
This is what dmesg says after pressing undock button:
[81459.990682] ata1.00: disabled
[81459.990727] ata1.00: detaching (SCSI 0:0:0:0)
[81459.991722] ACPI: \_SB_.GDCK - undocking
[81460.009462] ehci_hcd 0000:00:1a.7: power state changed by ACPI to D0
[81460.020252] ehci_hcd 0000:00:1a.7: BAR 0: set to [mem 0xfe226c00-0xfe226fff] (PCI address [0xfe226c00-0xfe226fff])
[81460.020265] ehci_hcd 0000:00:1a.7: power state changed by ACPI to D0
[81460.020281] ehci_hcd 0000:00:1a.7: restoring config space at offset 0xf (was 0x300, writing 0x30b)
[81460.020309] ehci_hcd 0000:00:1a.7: restoring config space at offset 0x1 (was 0x2900000, writing 0x2900102)
[81460.020338] ehci_hcd 0000:00:1a.7: PME# disabled
[81460.020346] ehci_hcd 0000:00:1a.7: power state changed by ACPI to D0
[81460.020352] ehci_hcd 0000:00:1a.7: power state changed by ACPI to D0
[81460.020363] ehci_hcd 0000:00:1a.7: PCI INT C -> GSI 22 (level, low) -> IRQ 22
[81460.020372] ehci_hcd 0000:00:1a.7: setting latency timer to 64
[81460.020432] ehci_hcd 0000:00:1d.7: power state changed by ACPI to D0
[81460.040071] ehci_hcd 0000:00:1d.7: BAR 0: set to [mem 0xfe227000-0xfe2273ff] (PCI address [0xfe227000-0xfe2273ff])
[81460.040085] ehci_hcd 0000:00:1d.7: power state changed by ACPI to D0
[81460.040104] ehci_hcd 0000:00:1d.7: restoring config space at offset 0xf (was 0x400, writing 0x40b)
[81460.040133] ehci_hcd 0000:00:1d.7: restoring config space at offset 0x1 (was 0x2900000, writing 0x2900102)
[81460.040170] ehci_hcd 0000:00:1d.7: PME# disabled
[81460.040178] ehci_hcd 0000:00:1d.7: power state changed by ACPI to D0
[81460.040184] ehci_hcd 0000:00:1d.7: power state changed by ACPI to D0
[81460.040195] ehci_hcd 0000:00:1d.7: PCI INT D -> GSI 19 (level, low) -> IRQ 19
[81460.040204] ehci_hcd 0000:00:1d.7: setting latency timer to 64
[81460.040503] ehci_hcd 0000:00:1d.7: PCI INT D disabled
[81460.040552] ehci_hcd 0000:00:1d.7: PME# enabled
[81460.061657] ehci_hcd 0000:00:1d.7: power state changed by ACPI to D3
[81460.200414] usb 1-4: USB disconnect, address 14
[81462.220088] ehci_hcd 0000:00:1a.7: PCI INT C disabled
[81462.220169] ehci_hcd 0000:00:1a.7: PME# enabled
[81462.240115] ehci_hcd 0000:00:1a.7: power state changed by ACPI to D3
/etc/acpi/events/lenovo-undock
or some other similar file corresponding to your laptop defines the ACPI event code for your undock button and maps it to a call to/etc/acpi/undock.sh
./etc/acpi/undock.sh
runs through drivers that correspond to devices that hotplug through your docking station, and signals these drivers to disconnect.You could also use
udev
, see here.