保存显示器设置?
有没有办法保存我的显示器设置? 我有一个外接显示器在工作,但每天早上我必须插入,重新安排窗口从并排到彼此顶部。 我可以保存吗?
所有监视器(热插拔或非插入)的配置都应该由gnome-settings-daemon
的xrandr
插件存储在$HOME/.config/monitors.xml
,这实际上是应用你在监视器capplet中进行的配置。
由于这似乎并不适合每个人,因此某处显然存在错误。 Urgh。
前三个步骤以您想要的方式连接外部显示器,第四步是保存设置。
-
连接外部显示器并检查其支持的分辨率:
xrandr -q
-
提供以下命令(这将禁用您的笔记本电脑显示器):
xrandr --output LVDS1 --off --output TV1 --off --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal
-
如果您想同时启用笔记本电脑和外部:
xrandr --output LVDS1 --mode yyyyXzzzz --pos 0x0 --rotate normal --output TV1 --off --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal
(yyyyXzzzz – 您的笔记本电脑分辨率。)
以上配置将克隆您的屏幕。 如果你愿意
--left-of
“--left-of
--right-of
/--left-of
”选项。 -
如果您在登录时需要此设置,请在
/etc/X11/Xsession.d/45custom_xrandr-settings
添加检查(您可能需要创建一个)。xrandr |grep VGA1 | grep " connected " | if [ $? -eq 0 ]; then xrandr --output LVDS1 --off --output TV1 --off --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal #Change the way u need ; fi
长话短说(即:做Nicolas Bernaerts建议的,但我省略了详细信息):监视器配置实际上保存在~/.config/monitors.xml
,但它不会在启动/登录时应用。
克服这个问题的步骤是:
使用错误的监视器配置登录。
删除当前监视器配置:
cd .config mv monitors.xml{,.bak}
使用“ 显示”应用程序根据需要排列显示器(我有一个侧面显示器逆时针旋转)。
按Apply后 ,将创建一个新的monitors.xml
。
现在,下载并生成可执行脚本和启动器,以强制基于新创建的配置文件的监视器配置:
$ sudo wget -O /usr/local/sbin/update-monitor-position https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/ubuntugnome/update-monitor-position $ sudo chmod +x /usr/local/sbin/update-monitor-position $ sudo wget -O /usr/share/applications/update-monitor-position.desktop https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/ubuntugnome/update-monitor-position.desktop $ sudo chmod +x /usr/share/applications/update-monitor-position.desktop
此时,可以通过启动更新监视器位置应用程序来修复监视器的配置。
如果您希望这是自动的,只需添加一个启动应用程序,其中包含以下条目:
- 名称:
Update Monitors Position
- 命令:
update-monitor-position 5
- 注释:
Force monitors position 5 seconds after login
Ubuntu 12.04会记住热插拔显示器设置。 但它们仅在您重新打开系统配置>显示小程序时应用。 至少对我来说就是这种情况,这绝对是一个错误。
在办公室,笔记本电脑上有3台显示器,家里有2台显示器。 两个办公室监视器设置为垂直,而其他监视器处于正常方向。
A. monitors.xml位于〜/ .config中。
- 删除它
- 在办公室设置中设置显示
- 将刚创建的“monitors.xml”重命名为“monitors-office.xml”。
B.获取shell脚本,“update-monitor-position”。
-
将“MONITOR_XML”定义“monitors.xml”更改为“monitors-office.xml”。
-
在可执行路径(/ usr / local / sbin /)中将其另存为“update-monitor-position-office”。
- 触摸权限 – >可执行文件“我”。
C.获取桌面快捷方式,“update-monitor-position.desktop”
- 将“Exec”定义,“update-monitor-position”更改为
“更新显示器位置办公”。 - 将其另存为“update-monitor-position-office.desktop”
- 触摸权限 – >可执行文件“我”。
更新监视器位置,office.desktop:
[Desktop Entry] Type=Application Exec=update-monitor-position-office Hidden=false NoDisplay=false X-GNOME-Autostart-enabled=true Name[en_US]=Office Monitors Position Name=Office Monitors Position Comment[en_US]=Force monitors position from monitor-office.xml Comment=Force monitors position from monitor-office.xml Icon=display
Shell脚本,update-monitor-position-office
#!/bin/bash # ------------------------------------------------- # Get monitors configuration from monitor.xml and apply it for current user session. # In case of multiple definitions in monitor.xml only first one is used. # # See http://bernaerts.dyndns.org/linux/74-ubuntu/309-ubuntu-dual-display-monitor-position-lost # for instructions # # Parameters : # $1 : waiting time in sec. before forcing configuration (optional) # # Revision history : # 19/04/2014, V1.0 - Creation by N. Bernaerts # 10/07/2014, V1.1 - Wait 5 seconds for X to fully initialize # 01/09/2014, V1.2 - Correct NULL file bug (thanks to Ivan Harmady) and handle rotation # 07/10/2014, V1.3 - Add monitors size and rate handling (idea from jescalante) # 08/10/2014, V1.4 - Handle primary display parameter # 08/12/2014, V1.5 - Waiting time in seconds becomes a parameter # ------------------------------------------------- # monitor.xml path MONITOR_XML="$HOME/.config/monitors-office.xml" # get number of declared monitors NUM=$(xmllint --xpath 'count(//monitors/configuration['1']/output)' $MONITOR_XML) # loop thru declared monitors to create the command line parameters for (( i=1; i<=$NUM; i++)); do # get attributes of current monitor (name and x & y positions) NAME=$(xmllint --xpath 'string(//monitors/configuration['1']/output['$i']/@name)' $MONITOR_XML 2>/dev/null) POS_X=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/x/text()' $MONITOR_XML 2>/dev/null) POS_Y=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/y/text()' $MONITOR_XML 2>/dev/null) ROTATE=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/rotation/text()' $MONITOR_XML 2>/dev/null) WIDTH=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/width/text()' $MONITOR_XML 2>/dev/null) HEIGHT=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/height/text()' $MONITOR_XML 2>/dev/null) RATE=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/rate/text()' $MONITOR_XML 2>/dev/null) PRIMARY=$(xmllint --xpath '//monitors/configuration['1']/output['$i']/primary/text()' $MONITOR_XML 2>/dev/null) # if position is defined for current monitor, add its position and orientation to command line parameters [ -n "$POS_X" ] && PARAM_ARR=("${PARAM_ARR[@]}" "--output" "$NAME" "--pos" "${POS_X}x${POS_Y}" "--fbmm" "${WIDTH}x${HEIGHT}" "--rate" "$RATE" "--rotate" "$ROTATE") # if monitor is defined as primary, adds it to command line parameters [ "$PRIMARY" = "yes" ] && PARAM_ARR=("${PARAM_ARR[@]}" "--primary") done # if needed, wait for some seconds (for X to finish initialisation) [ -n "$1" ] && sleep $1 # position all monitors xrandr "${PARAM_ARR[@]}"
不,没有办法在热插拔显示器上保存配置。 如果您在启动之前插入,GNOME应该记住每个设备上的配置(即,在工作时与家中的显示器连接)。