Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've recently purchased a Lenovo X200s laptop with a docking station which I used with Ubuntu 9.10. When the laptop is docked, I use a keyboard and trackball. I would like to have some different configuration options when the laptop is docked vs. when it is not docked. Is there some event I can hook up to and run a script when the laptop gets docked/undocked? Otherwise, is there anyway to find out if the laptop is docked? Kind of like an "is_docked" command.


share|improve this question
Although this is a very SuperUser-y question, you might get some better responses if you ask this on in a programmer-y way – Josh Hunt Jan 3 '10 at 9:31

See the article Linux Laptop-HOWTO, and especially the chapter Docking Station / Port Replicator, where a script is described that detects the docking state of the laptop.

The basic idea is to examine /proc for devices that are only available when in docked state.

In the script below, if the laptop is in docking-station then 4 PCMCIA slots are available, while if it is standalone then only 2 slots are available:

# check, if Laptop is in docking-station (4 PCMCIA slots available)
# or if it is standalone (2 slots available)
# Start after cardmgr has started
# Friedhelm Kueck
# 08-Sep-1998
# Find No. of Sockets
SOCKETS=`tail -1 /var/run/stab | cut -d ":" -f 1`

case "$SOCKETS" in

"Socket 3")
echo Laptop is in Dockingstation ...
echo Disabeling internal LCD Display for X11
cp /etc/XF86Config_extern /etc/XF86Config
# Setup of PCMCIA Network Interface after start of cardmge
echo "Setting up eth0 for use at Network ..."
/sbin/ifconfig eth0 netmask broadcast
/sbin/route add -net gw
/sbin/route add default gw

"Socket 1")
echo Laptop is standalone
echo Disabling external Monitor for X11
cp /etc/XF86Config_intern /etc/XF86Config
echo Network device NOT setup
share|improve this answer

Look at how you can get notifications from X6 Ultrabase:

I don't know about X200 Ultrabase, but I guess this should be very similar.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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