我使用的是 Thinkpad T510,我经常在 ThinkPad Mini Dock Plus Series 3 (EU) 中启动它。问题是,如果我在盖子关闭的情况下启动它,我可以看到 grub,我可以看到 Ubuntu 启动画面,但之后我的外接显示器(通过 VGA 连接)会关闭,我必须打开盖子并手动告诉 NVIDIA 驱动程序使用外接屏幕并关闭内置 LCD 面板。有没有办法将其放入 udev 规则中,或者类似的东西以避免手动切换?
答案1
有一些工具可以自动化它,比如 RandR、disper、displex 或者这个http://gnomefiles.org/content/show.php/Laptop+external+display+hotplugging?content=138742
答案2
我根据自己的需要调整了一个脚本。
您可以忽略 wacom 命令。这些命令只是为了将平板电脑的输入层与屏幕方向相匹配。
#!/bin/bash
#!/bin/sh
# wait for the dock state to change
sleep 2.0
DOCKED=$(cat /sys/devices/platform/dock.0/docked)
case "$DOCKED" in
"0")
#undocked event - lets remove all connected outputs apart from LVDS
for output in $(/usr/bin/xrandr -d :0.0 --verbose|grep " connected"|grep -v LVDS|awk '{print $1}')
do
/usr/bin/xrandr -d :0.0 --output $output --off
done
xrandr --output LVDS1 --rotation normal
xsetwacom set "Wacom ISDv4 90 Pen stylus" MapToOutput LVDS1
xsetwacom set "Wacom ISDv4 90 Pen eraser" MapToOutput LVDS1
# rotates the tablet input to the according position (half=180°, (c)cw=(counter)clockwise, none=normal)
xsetwacom set "Wacom ISDv4 90 Pen stylus" rotate none
# if multiouch present set: xsetwacom set "Wacom ISDv4 E6 Finger touch" rotate half
xsetwacom set "Wacom ISDv4 90 Pen eraser" rotate none
;;
"1")
## rotates internal Laptop Display LVDS1 to inverted
xrandr --output HDMI2 --auto --above LVDS1
xrandr --output LVDS1 --rotation inverted
xsetwacom set "Wacom ISDv4 90 Pen stylus" MapToOutput LVDS1
xsetwacom set "Wacom ISDv4 90 Pen eraser" MapToOutput LVDS1
# rotates the tablet input to the according position (half=180°, (c)cw=(counter)clockwise, none=normal)
xsetwacom set "Wacom ISDv4 90 Pen stylus" rotate half
# if multiouch present set: xsetwacom set "Wacom ISDv4 E6 Finger touch" rotate half
xsetwacom set "Wacom ISDv4 90 Pen eraser" rotate half
;;
esac
exit 0
它识别 /sys/devices/platform/dock.0 中的状态文件,其值 1 表示对接还是 0 表示未对接,并触发 xrandr 使用内置显示器 LVDS1 将显示输出调整为扩展桌面,并配置上面的外部显示器 HDMI2。