zoukankan      html  css  js  c++  java
  • 利用 xrandr 命令修改屏幕分辨率

    问题背景

    • 电脑外接着一个 23‘ 的显示器,分辨率为 1920*1080

    • 操作系统:ubuntu 14.04

    今天,通过 Setting->Displays 中选择外接屏的分辨率时,发现最大只有 1024×768,并且外接屏显示 “Unknown Displays”,日了狗了。。。


    解决方案

    解决办法主要是给这个 “Unknown Displays” 设置一个 1920*1080 的选项,下面借助 xrandr 命令来实现。


    先查看两个屏幕支持的分辨率情况

    在终端输入 xrandr

    $ xrandr
    Screen 0: minimum 320 x 200, current 3286 x 1080, maximum 32767 x 32767
    eDP1 connected primary 1366x768+0+312 (normal left inverted right x axis y axis) 309mm x 173mm
    1366x768      60.1*+
    1360x768      59.8    60.0
    1024x768      60.0
    800x600        60.3    56.2
    640x480        59.9
    DP1 disconnected (normal left inverted right x axis y axis)
    HDMI1 disconnected (normal left inverted right x axis y axis)
    DP2 connected 1024x768 (normal left inverted right x axis y axis) 0mm x 0mm
    1024x768      60.0*
    800x600        60.3    56.2
    848x480        60.0
    640x480        59.9
    HDMI2 disconnected (normal left inverted right x axis y axis)
    VIRTUAL1 disconnected (normal left inverted right x axis y axis)
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    注:

    • 上面显示了两个屏幕分辨率选项,后面标示 * 即为屏幕当前分辨率
    • 这里显示好几个接口:eDP1, DP1, HDMI1, DP2, HDMI2, VIRTUAL1,但是只有 eDP1 和 DP2 有连接,并且 DP2 对应我们外接屏(这个值后面会用到!)

    利用 cvt 新建一个 modeline

    代码如下:

    $ cvt 1920 1080
    • 1
    • 1

    然后屏幕上会返回两行内容,赋值第二行中 ‘Modeline’ 后面的所有内容,并接到下面 xrandr --newmode 后面:

    $ xrandr --newmode "1920x1080_60.00" 173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync
    $ xrandr --addmode DVI1 "1920x1080_60.00"
    $ xrandr -s 1920x1080 
    • 1
    • 2
    • 3
    • 1
    • 2
    • 3

    其中 ”DP2“ 即上面展示的外接端口,不用的接口这个名字可能不同,比如有的会是 VGA1,以上面 xrandr 的显示结果为准。

    之后,再进入 Setting->Displays, 发现那个 “Unknown Display” 的分辨率中,有了 “1920x1080” 这个选项,选中它,并 Apply 即可。

    Section "InputDevice"
    Identifier "Generic Keyboard"
    Driver "kbd"
    Option "XkbRules" "xorg"
    Option "XkbModel" "pc104"
    Option "XkbLayout" "us"
    EndSection


    Section "InputDevice"
    Identifier "Configured Mouse"
    Driver "mouse"
    EndSection


    Section "Device"
    Identifier "Configured Video Device"
    EndSection


    Section "Monitor"
    Identifier "Monitor0"
    VendorName "Unknown"
    ModelName "Unknown"
    HorizSync 30.0 - 83.0
    VertRefresh 50.0 - 75.0
    Option "DPMS"
    Modeline "1600x1200_60.00"  161.00  1600 1712 1880 2160  1200 1203 1207 1245 -hsync +vsync
    Modeline "1600x1228_60.00"  128.00  1600 1632 1664 1728  1200 1203 1207 1235 -hsync +vsync
    Modeline "1400x1050_60.00"  121.75  1400 1488 1632 1864  1050 1053 1057 1089 -hsync +vsync
    Modeline "1024x768_60.00"   63.50  1024 1072 1176 1328  768 771 775 798 -hsync +vsync




    EndSection


    Section "Screen"
    Identifier "Default Screen"
    Monitor "Monitor0"
    SubSection "Display"


    Modes "1600x1200" "1600x1228" "1400x1050" "1024x768" 
    EndSubSection
    EndSection

  • 相关阅读:
    1.Python基础语法
    Python学习4:商城购物
    Python学习3:猜年龄游戏进阶版
    Python学习2:猜年龄游戏
    python学习1:判断学生成绩等级
    K8S集群平滑回退或升级
    Xtrabackup工作原理
    Android App 侧边栏菜单的简单实现
    NoActionBar主题下如何添加OptionsMenu
    TabLayout+ViewPager制作简单导航栏
  • 原文地址:https://www.cnblogs.com/mao0504/p/6188110.html
Copyright © 2011-2022 走看看