有一些工具可以自动化它,例如 RandR、分散、displex 或这个http://gnomefiles.org/content/show.php/Laptop+external+display+hotplugging?content=138742
小智 1
我根据自己的需要调整了自己的脚本。
\n\n您可以忽略 wacom 命令。这些只是为了将平板电脑的输入层与屏幕方向相匹配。
\n\n#!/bin/bash\n#!/bin/sh\n# wait for the dock state to change\nsleep 2.0\nDOCKED=$(cat /sys/devices/platform/dock.0/docked)\ncase "$DOCKED" in\n "0")\n #undocked event - lets remove all connected outputs apart from LVDS\n for output in $(/usr/bin/xrandr -d :0.0 --verbose|grep " connected"|grep -v LVDS|awk \'{print $1}\')\n do\n /usr/bin/xrandr -d :0.0 --output $output --off\n done\n xrandr --output LVDS1 --rotation normal\n xsetwacom set "Wacom ISDv4 90 Pen stylus" MapToOutput LVDS1\n xsetwacom set "Wacom ISDv4 90 Pen eraser" MapToOutput LVDS1\n # rotates the tablet input to the according position (half=180\xc2\xb0, (c)cw=(counter)clockwise, none=normal)\n xsetwacom set "Wacom ISDv4 90 Pen stylus" rotate none\n # if multiouch present set: xsetwacom set "Wacom ISDv4 E6 Finger touch" rotate half\n xsetwacom set "Wacom ISDv4 90 Pen eraser" rotate none\n ;;\n "1")\n ## rotates internal Laptop Display LVDS1 to inverted\n xrandr --output HDMI2 --auto --above LVDS1\n xrandr --output LVDS1 --rotation inverted\n xsetwacom set "Wacom ISDv4 90 Pen stylus" MapToOutput LVDS1\n xsetwacom set "Wacom ISDv4 90 Pen eraser" MapToOutput LVDS1\n # rotates the tablet input to the according position (half=180\xc2\xb0, (c)cw=(counter)clockwise, none=normal)\n xsetwacom set "Wacom ISDv4 90 Pen stylus" rotate half\n # if multiouch present set: xsetwacom set "Wacom ISDv4 E6 Finger touch" rotate half\n xsetwacom set "Wacom ISDv4 90 Pen eraser" rotate half\n ;;\nesac\nexit 0\nRun Code Online (Sandbox Code Playgroud)\n\n它标识 /sys/devices/platform/dock.0 中的状态文件,无论其值为 1(表示对接)还是 0(表示未对接),都会触发 xrandr 使用内置显示器 LVDS1 将显示输出调整到扩展桌面并配置外部显示器HDMI2以上。
\n