Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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.

Thanks

share|improve this question
    
Although this is a very SuperUser-y question, you might get some better responses if you ask this on stackoverflow.com 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 mailto:fk@impress.de
# 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
echo
cp /etc/XF86Config_extern /etc/XF86Config
#
# Setup of PCMCIA Network Interface after start of cardmge
#
echo
echo "Setting up eth0 for use at Network ..."
echo
/sbin/ifconfig eth0 10.1.9.5 netmask 255.255.0.0 broadcast 10.1.255.255
/sbin/route add -net 10.1.0.0 gw 10.1.9.5
/sbin/route add default gw 10.1.10.1
;;

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

Look at how you can get notifications from X6 Ultrabase: http://www.thinkwiki.org/wiki/X6_UltraBase

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

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .