如何使xrandr定制永久化?

我曾经编辑过GDM的启动脚本(/ etc / gdm / Init / Default)来永久改变我的显示分辨率。

如何在Ubuntu Oneiric中使用LigthDM执行此操作?

我想你可以将显示模式添加到/etc/X11/xorg.conf

如果您没有xorg.conf ,则可以使用以下内容作为基础。 您需要使用正确的系统条目替换名称为ModelineDriverModes的条目。 根据您的硬件,您可能需要其他条目,例如,如果您的系统有多个图形芯片。

 Section "Monitor" Identifier "Monitor0" Modeline "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync Modeline "1024x768_60.00" 63.50 1024 1072 1176 1328 768 771 775 798 -hsync +vsync EndSection Section "Screen" Identifier "Screen0" Device "Card0" Monitor "Monitor0" SubSection "Display" Modes "1280x1024_60.00" "1024x768_60.00" EndSubSection EndSection Section "Device" Identifier "Card0" Driver "nvidia" EndSection 

如果您不知道系统正在使用的video驱动程序的名称,那么您可能会得到如下名称(如果您有英特尔图形芯片,驱动程序名称只是“英特尔”):

 lshw -class display | grep "driver" 

可以使用cvt生成模型:

 cvt   [refresh] 

修改/etc/lightdm/lightdm.conf以添加以下选项:

display-setup-script>在登录屏幕出现之前调用mycustomloginvideo.sh

session-setup-script>在用户桌面会话启动之前调用mycustomdesktopvideo.sh

 [SeatDefaults] greeter-session=unity-greeter user-session=ubuntu # for your login screen, eg LightDM (Ubuntu 11.10) or GDM (11.04 or earlier) display-setup-script=/usr/share/mycustomloginvideo.sh # for your desktop session session-setup-script=/usr/share/mycustomdesktopvideo.sh 

您可以使用“arandr”gui工具生成上述sh脚本,从当前会话的X配置中选择参数。

确保您的shell脚本是可执行的:

 chmod a+x /usr/share/mycustom*video.sh 

并且您可以通过在终端中运行它来测试它是否有效(即您的xrandr命令中没有任何拼写错误或配置错误):

 /usr/share/mycustomdesktopvideo.sh 

如果登录脚本因任何原因无效,则您的计算机可能无法完成登录屏幕的引导过程。 如果桌面脚本失败,则登录后可能无法访问桌面。如果要设置外部监视器,则断开连接后这些脚本将失败,并且X会话将无法启动。

有人发布了另一个解决方法,但我必须说它对我不起作用。 它可能适合你。 在我的情况下,它打破了统一,我只能移动我的鼠标光标。 应用程序指示器顶部面板看起来是空的,但在拔下我的LCD后,我能够删除添加的行,一切都恢复正常。

编辑文件/usr/sbin/lightdm-session

以下是该文件的第一部分现在的样子:

 #!/bin/sh # # LightDM wrapper to run around X sessions. echo "Running X session wrapper" # Load profile for file in "/etc/profile" "$HOME/.profile" "/etc/xprofile" "$HOME/.xprofile"; do if [ -f "$file" ]; then echo "Loading profile from $file"; . "$file" fi done xrandr --newmode "1368x768_60.00" 85.25 1368 1440 1576 1784 768 771 781 798 -hsync +vsync xrandr --addmode CRT1 1368x768_60.00 xrandr --output CRT1 --mode 1368x768_60.00 # Load resources 

请注意,应更改Xrandr设置以匹配您的设置。

我一直试图解决类似的问题一段时间,并找到一个适合我的解决方案,所以希望它会有所帮助……

我有一个旧的向往一个AOA110,我已经打破屏幕太多次,买了一台新的笔记本电脑决定我会尝试把它变成一个HTPC但我的外部显示器是不被X识别所以我不得不’调整’它多次以使其以正确的分辨率工作。

这是我做的:

在使用http://ubuntuforums.org/showthread.php?t=1112186教程到第5步之后,我能够在xrandr中找到一个可行且可接受的解决方案,但这不适用于LightDM登录屏幕。

不要按照上面的步骤使它坚持上面如何工作,但我认为这是在11.10中这样做的正确方法。 我在ArchWiki https://wiki.archlinux.org/index.php/Xorg上找到了这篇文章,我根据自己的需要进行了调整。

首先在这里创建一个文件: /etc/X11/xorg.conf.d/10-monitor.conf

然后为您的显示添加适当的X详细信息,这是我的看法:

 Section "ServerLayout" Identifier "DualSreen" Screen 0 "Screen0" Screen 1 "Screen1" RightOf "Screen0" #Screen1 at the right of Screen0 #Option "Xinerama" "1" #To move windows between screens EndSection Section "Monitor" Identifier "LVDS1" Option "ignore" "true" EndSection Section "Monitor" Identifier "VGA1" Option "Enable" "true" Modeline "1440x900_60.00" 106.47 1440 1520 1672 1904 900 901 904 932 -HSync +Vsync EndSection Section "Device" Identifier "Device0" Driver "intel" Screen 0 EndSection Section "Device" Identifier "Device1" Driver "intel" Screen 1 EndSection Section "Screen" Identifier "Screen0" Device "Device0" Monitor "VGA1" DefaultDepth 24 Option "TwinView" "0" SubSection "Display" Depth 24 Modes "1440x900_60.00" EndSubSection EndSection Section "Screen" Identifier "Screen1" Device "Device1" Monitor "LVDS1" DefaultDepth 24 Option "TwinView" "0" SubSection "Display" Depth 24 EndSubSection EndSection 

要添加的重要位在适当的Section "Monitor"下,包括使用gtf 1440 900 60.00找到的相应Modeline ,然后在相应的Section "Screen"下,包括正确的Modes

您会注意到我尝试做的不仅是将VGA1连接设置为合适的分辨率,还要告诉它不要使用我的LVDS1输出。 显然,您需要适当调整您的产品,以匹配正确的输出数量以及适合您设置的设备,屏幕和显示部分。

对于史诗般的post感到抱歉,我一直在调整xorg.conf文件已经有一段时间了,我一直在使用Hannspree显示器和我之前使用的旧的xorg.conf设置11.10只是不能正常工作这就是唯一的解决方案我发现有效。

祝好运!

我上面的笔记本电脑遇到了类似的问题,我想在对话中添加一些东西。 如果您不关心登录分辨率(我没有),但希望实际工作区是正确的分辨率,您可以将监视器信息添加到LightDM,但在登录之前不要打开全分辨率。

我刚在文件中为监视器添加了以下脚本: lighdmxrandr

 xrandr --newmode "1440x900_60.00" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync xrandr --addmode VGA1 1440x900_60.00 

然后我在/etc/lightdm/lightdm.conf调用它

 display-setup-script=/usr/bin/lightdmxrandr 

一旦我登录,我可以在显示器中设置我的显示器,它可以工作,即使我重新登录后(曾经给我一个很大的丑陋错误)。

作为Jon Roberts回答的增强,让我指定arandr在其sh脚本生成中不包括在当前会话中工作的所有参数。 例如,主监视器(如果您使用双监视器配置),不包括每个监视器的刷新率和伽玛设置。 我的会话脚本看起来像这样:

 #!/bin/sh xrandr --output LVDS --mode 1366x768 --pos 1600x432 --rotate normal --output HDMI-0 --off --output DVI-0 --off --output VGA-1 --mode 1600x1200 --rate 85 --pos 0x0 --rotate normal --primary xrandr --output VGA-1 --gamma 0.8:0.7:0.55 

我在第一行手动添加了–rate和–primary选项,然后手动添加第二行并进行了伽马校正,因为每当您将监视器切换到主要时,显然xrandr gamma设置都会丢失

我不知道在制作监视器主要时是否具有伽玛设置的特定行为是有意还是错误。

此外,会话shell脚本不是由lightdm调用,而是作为启动应用程序调用,因为似乎lightdm在为xrandr做好准备之前会调用脚本,并且会发生奇怪的事情。

我有一个问题,想要在我的新LXDE盒子上扩展显示(不是双克隆),找到了正确的命令,但无法使其永久化。

 xrandr --output VGA-0 --right-of DVI-0 

上述方法似乎都太难/不是正确的方法。

我最终发现了这个: http : //www.sudo-juice.com/change-lxde-screen-resolution-ubuntu-lubuntu/

这是一种享受,但我使用gedit代替:

 gksu gedit /etc/xdg/lxsession/LXDE/autostart 

然后在开头添加@符号末尾的行:

 @xrandr --output VGA-0 --right-of DVI-0 

希望有帮助并感谢sudo-juice。

PS注意双重-在xrandr命令中-- (在我的屏幕上没有太清楚地显示)。

创建一个新文档并将其命名为/home/yourusername/yourscriptname.sh输入

 #!/bin/bash xrandr --newmode "1600x900_60.00" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync xrandr --addmode VGA1 1600x900_60.00 xrandr --output VGA1 --mode 1600x900_60.00 unity --replace 

并将其保存在您的主文件夹中(这将分辨率设置为1600×900)

打开启动应用程序(或运行gnome-session-properties并单击“添加”。 在命令行中输入名称并键入:

 bash /home/yourusername/yourscriptname.sh 

保存它,现在每次登录时都会运行脚本,因此您需要先注销才能使其生效。 在终端中运行命令(例如bash /home/yourusername/yourscriptname.sh )也是检查脚本是否有效的好主意。

基于上面的响应,我做了一些测试,发现了一个对我有用的有用方法,然后我创建了一个简单的脚本,通过自动安装自动化它。 但它适用于任何其他情况。

创建scriptinstallxrandrfixed.sh添加以下行:

 #Variables for lightdm script and xrandr script to setup fixed resolution for old displays: xrandrscript=/usr/local/bin/xrandrscript.sh lightdmstartscript=/usr/share/lightdm/lightdm.conf.d/60-xrandrscript.conf #Added old style configuration for lightdm: sudo ln -s /usr/share/lightdm/lightdm.conf.d /etc/lightdm/lightdm.conf.d #A fix to some old displays in high school at Fray Bentos, fix to 1024x768 #Some useful information comes from: http://askubuntu.com/questions/63681/how-can-i-make-xrandr-customization-permanent sudo sh -c "echo '[SeatDefaults]' > $lightdmstartscript" # for your login screen, eg LightDM (Ubuntu 11.10) or GDM (11.04 or earlier) sudo sh -c "echo 'display-setup-script=$xrandrscript' >> $lightdmstartscript" # for your desktop session sudo sh -c "echo 'session-setup-script=$xrandrscript' >> $lightdmstartscript" sudo sh -c "echo 'xrandr --size 1024x768 --rate 60.0' > $xrandrscript" sudo chmod +x $xrandrscript 

它将为lightdm显示和会话创建脚本和文件。 别忘了给它执行权限

chmod + x scriptinstallxrandrfixed.sh

并执行

./scriptinstallxrandrfixed.sh(您必须放在拥有该文件的同一目录中。)

如果不在同一目录中:/path/to/script/scriptinstallxrandrfixed.sh

修改它以满足您的需求。 亲切的问候。 巴勃罗。