poor_mans_docking_station_using_usb_hub_in_monitor

>> cat vid.sh
#!/bin/sh

dual_monitors()
{
        # Move panels
        gconftool-2 --set /apps/panel/toplevels/panel_0/monitor --type=int 1
        gconftool-2 --set /apps/panel/toplevels/panel_1/monitor --type=int 1
        # Move virtualbox
        VBOX=`wmctrl -lG | egrep "winxp .* VirtualBox OSE" |   awk '{print $1}'`
        wmctrl -i -r $VBOX -e 0,1921,-1,-1,-1
        sh /home/nie/swap_sound.sh docked
}



xrandr   | egrep "VGA-0 connected" >/dev/null 2>&1

if [ $? -eq 0 ]
then
    xrandr --output VGA-0 --mode "1440x900"
    xrandr  --output VGA-0 --right-of LVDS
        dual_monitors
fi

xrandr   | egrep "DVI-0 connected" >/dev/null 2>&1

if [ $? -eq 0 ]
then
        xrandr --output DVI-0 --mode "1920x1200"
        xrandr --output DVI-0 --right-of LVDS
        dual_monitors
fi

COUNT=`xrandr | egrep disconnect | wc -l | awk '{print $1}'`

if [ $COUNT -eq 2 ]
then
        echo single
        xrandr --output DVI-0 --off
        xrandr --output VGA-0 --off
        gconftool-2 --set /apps/panel/toplevels/panel_0/monitor --type=int 0
        gconftool-2 --set /apps/panel/toplevels/panel_1/monitor --type=int 0
        sh /home/nie/swap_sound.sh undocked
fi

kbdrate -r 2 -d 250

and swap sound

> cat swap_sound.sh
#!/bin/sh

UNDOCKED="HDA Intel - STAC92xx Analog"
DOCKED="USB Headphone Set - USB Audio"

UNDOCKED_ID=`pacmd "list-sinks" | egrep "device.description|index:" | egrep -B1 "$UNDOCKED" | head -1 | awk '{print $NF}'`
DOCKED_ID=`pacmd "list-sinks" | egrep "device.description|index:" | egrep -B1 "$DOCKED" | head -1 | awk '{print $NF}'`

echo DOCKED_ID $DOCKED_ID
echo UNDOCKED_ID $UNDOCKED_ID

APPID=`echo "list-sink-inputs" | pacmd | egrep "index|application.name"  | egrep -B1 "amarokapp" | head -1 | awk '{print $NF}'`

if [ "$1" = "docked" ]
then
        echo move-sink-input $APPID $DOCKED_ID | pacmd
else
        echo move-sink-input $APPID $UNDOCKED_ID | pacmd
fi