使用Xrandr添加newmode – “800x480_60.00”

我将5英寸800×480 tft连接到Portwell WADE-8020 mini-ITX嵌入式系统板上的LVDS连接器。 我想建立一个XMBC / Kodi盒子,用于从我的freenas PC上播放我的音乐,tft显示播放的内容,我得到了这样的票价……

sudo xrandr --newmode "800x480_60.00" 29.50 800 824 896 992 480 483 493 500 -hsync +vsync`enter code here 

然后,

 sudo xrandr --addmode LVDS1 800x480_60.00 

现在我得到了正确的分辨率,我现在屏幕顶部有一个黑带。

 sudo xrandr --output LVDS1 --set "scaling mode" "Full aspect" 

但是这并没有解决问题,我也知道我需要用google来修改/ bin / sh文件所以我不需要在每次启动时都这样做。 但我不知道如何,因为我对Linux很新。

 #!/bin/sh xrandr --newmode "800x480_60.00" 29.50 800 824 896 992 480 483 493 500 -hsync +vsync xrandr --addmode LVDS1 800x480_60.00 

方法1:使用启动应用程序

您可以创建可执行 脚本文件并将其添加到启动应用程序列表中。 下面是我的系统中后续步骤的结果截图 。

1.创建将包含脚本文件的目录。 例如,此目录可以放在您的主目录中,并且可以命名为.autorun-startup

 mkdir ~/.autorun-startup 

2.创建脚本文件并使其可执行:

  • 我们将此文件custom-screen-resolution.sh

     nano ~/.autorun-startup/custom-screen-resolution.sh 

    在这个例子中使用了Nano文本编辑器(你可以使用ctrl + o保存编辑,然后使用ctrl + x退出),但是你可以使用自己喜欢的文本编辑器。

  • 脚本 custom-screen-resolution.sh的内容应如下所示:

     #!/bin/sh # To calculate the modeline use: cvt 800 640 60 # To view the available modes and the output names use: xrandr # Create new mode: xrandr --newmode "800x480_60.00" 29.50 800 824 896 992 480 483 493 500 -hsync +vsync # Sdd the new mode to the lisct of modes of certain output: xrandr --addmode LVDS1 800x480_60.00 # Set the new mode as current for the certain output: xrandr --output LVDS1 --mode 800x480_60.00 
  • 将可执行权限设置为custom-screen-resolution.sh文件( 或使用Nautilus ):

     chmod +x ~/.autorun-startup/custom-screen-resolution.sh 

3.打开应用程序“ 启动应用程序” ,单击“ 添加”按钮添加新条目并填充参数值:

 Name: Custom Screen Resolution Command: /home//.autorun-startup/custom-screen-resolution.sh Comment: Add Custom Screen Resolution 

保存条目和关闭启动应用程序。


方法2:使用XDG Utils

  • 此方法允许您在系统启动系统范围内(对所有用户)执行上述命令。 为此,您必须创建.desktop文件并将其放置在适当的位置,更具体地说,根据示例进入目录/etc/xdg/autostart/ 我在这里找到了这种方法,但也有可用的和其他方法如何使用XDG Utils工具包。

1.创建一个包含.desktop文件的目录:

 sudo mkdir -p /etc/xdg/autostart 

2.创建.desktop文件并使其可执行:

  • 我们将此文件称为custom-screen-resolution.desktop

     sudo nano /etc/xdg/autostart/custom-screen-resolution.desktop 
  • custom-screen-resolution.desktop文件的内容应如下所示:

     [Desktop Entry] Name=Custom Screen Resolution Exec=sh -c 'xrandr --newmode "800x480_60.00" 29.50 800 824 896 992 480 483 493 500 -hsync +vsync; xrandr --addmode LVDS1 800x480_60.00; xrandr --output LVDS1 --mode 800x480_60.00' Terminal=false Type=Application Categories=Application 

    确保custom-screen-resolution.desktop在系统范围内具有读权限 。

  • 将可执行权限设置为custom-screen-resolution.desktop文件。 在这种情况下,如果您想通过“双击”测试文件,则此步骤是可选的,您需要它。

注1: .desktop文件可以使用上述方法中创建的脚本 。 为此,请按如下所示更改Exec确保custom-screen-resolution.sh在系统范围内具有读取权限 ):

 Exec=/home//.autorun-startup/custom-screen-resolution.sh 

注意2:在目录/home//.autorun-startup创建.desktop文件,然后创建指向 /etc/xdg/autostart的符号链接 :

 sudo ln -s /home//.autorun-startup/custom-screen-resolution.desktop /etc/xdg/autostart/ 

进一步阅读

添加分辨率:

  • 如何将显示器设置为其未在分辨率列表中列出的原始分辨率?
  • 如何使xrandr定制永久化?
  • X.org配置文件在哪里? 如何在那里配置X?
  • 如何在显示设置中添加分辨率?
  • 如何使用Ubuntu 14.04在笔记本电脑上永久性地添加分辨率,用于连接VGA电缆的辅助显示器?

启动命令:

  • 启动命令
  • 如何在启动时运行脚本?
  • 不同如何在启动时运行脚本
  • 我怎样才能编写一个将在启动时运行的shell脚本,并在应用程序启动时引入延迟
  • 使用/ etc / environment中的bash脚本添加路径到PATH环境变量