Skip to content

Instantly share code, notes, and snippets.

@dstar4138
Created January 24, 2013 04:49
Show Gist options
  • Save dstar4138/4617737 to your computer and use it in GitHub Desktop.
Save dstar4138/4617737 to your computer and use it in GitHub Desktop.
dock-undock script for w520 with the mini dock plus. To install, place in /etc/init.d/. and run 'update-rc.d dock-undock.sh defaults'.
#!/bin/sh
### BEGIN INIT INFO
# Provides: dock-undock.sh
# Required-Start: $local_fs $remote_fs $bumblebeed
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Check if laptop is docked or undocked and change XOrg.
# Description: Check if laptop is docked or undocked and change XOrg config.
### END INIT INFO
set -e
DOCKED=`hwinfo | grep "ThinkPad Mini Dock Plus Series 3" | wc -l`
LOG=/var/log/docked_status.log
if [ $DOCKED -gt 0 ]; then
cp /etc/X11/xorg.conf.docked /etc/X11/xorg.conf
YN="{DOCKED}"
echo ON | tee /proc/acpi/bbswitch
else
cp /etc/X11/xorg.conf.undocked /etc/X11/xorg.conf
YN="{UNDOCKED}"
echo OFF | tee /proc/acpi/bbswitch
fi
echo "[`date`] DOCK STATUS = $YN" >> $LOG
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment