Tag Archives: linux

docking stations and linux

Ever got annoyed that switching the screens (laptop to desktop monitor and back) can be a bit tedious if there is not 100% hardware or software support?  Automatic switching might work sometimes, sometimes not. Using the functions keys may or may not work. Manually going into the settings menu and navigating with mouse several clicks everyday just to get the setup working is not very pleasing. My solution to this is a neat little bash script (named switchmon.sh in the following):

myvar="$(xrandr -q)"
if [[ $myvar == "ext" ]]
xrandr --output HDMI2 --auto;
xrandr --output LVDS1 --off;
xrandr --output HDMI2 --off;
xrandr --output LVDS1 --auto;

It is easy to use: simply run

switchmon.sh ext

in your console to switch to the external monitor. If you run switchmon.sh without argument it takes you back to the laptop screen.

You likely need to adjust --output to what is actually connected at your place. Check this with:

xrandr --current

while using the docking station. If you bother, set the script to run using hotkeys. It can surely be extended for various purposes, but it suffices for my needs for now.