在扩展坞中启动时自动使用外接显示器

use*_*899 7 nvidia thinkpad lenovo vga 12.04

我使用的是 Thinkpad T510,我经常在 ThinkPad Mini Dock Plus Series 3 (EU) 中启动它。问题是,如果我在关闭盖子的情况下启动它,我可以看到 grub,我可以看到 Ubuntu 启动画面,但之后我的外部显示器(通过 VGA 连接)关闭,我必须打开盖子并告诉NVIDIA 驱动程序手动使用外部屏幕并关闭内置 LCD 面板。有没有办法将它放入 udev 规则或类似的规则中以避免手动切换?

Cmo*_*les 1

有一些工具可以自动化它,例如 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\n
Run Code Online (Sandbox Code Playgroud)\n\n

它标识 /sys/devices/platform/dock.0 中的状态文件,无论其值为 1(表示对接)还是 0(表示未对接),都会触发 xrandr 使用内置显示器 LVDS1 将显示输出调整到扩展桌面并配置外部显示器HDMI2以上。

\n