Hello everyone, I am hoping someone can help me with a script as well as udev rules. I am also hoping the solution to this can be helpful others, since docking stations can be a pain.
Anyway, here is a script I wrote after Googling for a while:
Code:
#!/bin/sh
xrandr --current | grep "VGA1 connected "
if [ $? -eq 0 ]; then
sleep 5s
xrandr --output LVDS1 --off --output VGA1 --auto
else
xrandr --output LVDS1 --auto --output VGA1 --off
fi
That script will switch my laptop to the appropriate monitor. If I'm docked, it will go to the external monitor, otherwise it will direct output to the laptops display. I set up a keyboard shortcut in XFCE (ALT+CTRL+=) and whenever I press that, it switches video to the appropriate place. So far, so good.
I also wrote a udev rule, hoping that I can automate this:
Code:
# Rules for docking / undocking
KERNEL=="dock.0", ATTR{docked}=="1", RUN+="/usr/local/bin/dock"
KERNEL=="dock.0", ATTR{docked}=="0", RUN+="/usr/local/bin/dock"
I saved that in /etc/udev/rules.d/81-docking.rules.
Unfortunately, that does not work. I still have to switch the output manually. Any idea what I may have done wrong? I never wrote a udev rule before.
Edit: I totally forgot to mention, this is on a Latitude D630. I'll be setting this type of thing up on a Latitude E6410 when I get it sorted out.