V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
miracleyin
V2EX  ›  Ubuntu

求 ubuntu 不同分辨率显示器的优雅解决办法

  •  
  •   miracleyin · 2021-08-09 21:47:47 +08:00 via iPhone · 2381 次点击
    这是一个创建于 962 天前的主题,其中的信息可能已经有所发展或是发生改变。
    最近出售了一台 2k 显示器,又购置了一台新的 4k 显示器,原来不是很明显的分辨率问题现在暴露了出来。
    在 ubuntu20.04 下,笔记本内建 1080p 显示器和外置显示器无法良好协同工作:
    1. 将主显示器设置为外置显示器,并对其使用合适的放缩倍率时,内建显示器会一致放大;
    2. 外置显示器帧数被限制在 30 帧;
    3. 在某些设置情况下,会使得内建显示器无法输出图像,只有把英伟达显卡驱动卸载才可使用,但重装驱动以后,内建显示器继续无法输出。
    笔记本是 intel 核显,英伟达独显,外置显示器使用 typec 连接。
    翻阅了论坛的帖子,采用了如 xrandr 方法(会导致情况 3 ),切换英伟达显卡设置等操作,并没有好的现象
    希望大家可以提供一些建议,个人希望不要涉及到到太大的魔改,工作电脑…不敢折腾了
    10 条回复    2021-08-13 12:11:27 +08:00
    wangbenjun5
        1
    wangbenjun5  
       2021-08-09 22:45:07 +08:00   ❤️ 1
    没试过这种场景,我记得笔记本的话安装英伟达独显驱动之后是没法自动切换,安装独显驱动之后有一个英伟达的驱动面板,在这里手动切换后重启。

    一般 CPU 核显很难支持 4k 60,所以会锁 30 帧,你得确认一下自己是否切换到独显了。至于缩放倍率这块的问题,我记得 xrandr 确实可以办到,但是没操作过。。。
    shynome
        2
    shynome  
       2021-08-09 22:50:47 +08:00
    https://github.com/shynome/shynome.github.io/issues/32#issuecomment-652166507
    我是用 xrandr 解决的, 你可以参考下. (不清楚你参考的方法是哪个)
    miracleyin
        3
    miracleyin  
    OP
       2021-08-10 08:50:10 +08:00
    @wangbenjun5 谢谢您,可能是我没看懂 xrandr 的文档~
    miracleyin
        4
    miracleyin  
    OP
       2021-08-10 09:16:17 +08:00
    @shynome 谢谢您,我目前不太清楚怎么用 xrandr 解决,而且会出现笔记本屏幕失效,看了您的方法以后好像有一点不适用。主要在于 [xrog.conf] 这个文件内容不一致。
    shynome
        5
    shynome  
       2021-08-10 09:22:19 +08:00 via Android
    xorg.conf 要清空用下面这段
    把下面配置的 BusID 改成上一步生成的默认配置中的 BusID, 然后替换 /etc/X11/xorg.conf 原有的内容
    ```
    Section "ServerLayout"
    Identifier "layout"
    Screen 0 "nvidia"
    Inactive "intel"
    EndSection

    Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "<BusID for NVIDIA device here>"
    EndSection

    Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
    # Uncomment this line if your computer has no display devices connected to
    # the NVIDIA GPU. Leave it commented if you have display devices
    # connected to the NVIDIA GPU that you would like to use.
    #Option "UseDisplayDevice" "none"
    EndSection

    Section "Device"
    Identifier "intel"
    Driver "modesetting"
    EndSection

    Section "Screen"
    Identifier "intel"
    Device "intel"
    EndSection
    ```
    之后跑下面这段代码
    ```
    xrandr --setprovideroutputsource modesetting NVIDIA-0
    xrandr --auto
    ```
    @miracleyin
    miracleyin
        6
    miracleyin  
    OP
       2021-08-10 10:08:29 +08:00
    @shynome 这是我默认生成的配置,似乎没有[BusID]这个值,并且我的内置显示器又挂了..

    Section "ServerLayout"
    Identifier "Layout0"
    Screen 0 "Screen0" 0 0
    InputDevice "Keyboard0" "CoreKeyboard"
    InputDevice "Mouse0" "CorePointer"
    EndSection

    Section "Files"
    EndSection

    Section "InputDevice"

    # generated from default
    Identifier "Mouse0"
    Driver "mouse"
    Option "Protocol" "auto"
    Option "Device" "/dev/psaux"
    Option "Emulate3Buttons" "no"
    Option "ZAxisMapping" "4 5"
    EndSection

    Section "InputDevice"

    # generated from default
    Identifier "Keyboard0"
    Driver "kbd"
    EndSection

    Section "Monitor"
    Identifier "Monitor0"
    VendorName "Unknown"
    ModelName "Unknown"
    Option "DPMS"
    EndSection

    Section "Device"
    Identifier "Device0"
    Driver "nvidia"
    VendorName "NVIDIA Corporation"
    EndSection

    Section "Screen"
    Identifier "Screen0"
    Device "Device0"
    Monitor "Monitor0"
    DefaultDepth 24
    SubSection "Display"
    Depth 24
    EndSubSection
    EndSection
    shynome
        7
    shynome  
       2021-08-10 10:23:53 +08:00 via Android
    你可以谷歌下怎么找到 BusID
    miracleyin
        8
    miracleyin  
    OP
       2021-08-10 10:36:37 +08:00
    @shynome 好的,谢谢您。
    miracleyin
        9
    miracleyin  
    OP
       2021-08-10 11:13:20 +08:00
    该问题已经解决,目前找到个人觉得 ubuntu 20.04 最好的方案如下:
    1. 使用默认的桌面
    2. 在缩放时,要注意讲两个桌面底边对齐,这样就不会出现两台显示器,修改其中一台,另一台显示器 发生 变化
    3. 使用 hdmi 作为输出时可以达到 60hz,并注意要将独立显卡作为外接显示器输入
    miracleyin
        10
    miracleyin  
    OP
       2021-08-13 12:11:27 +08:00
    关于 3, hdmi 也不是必须选项,新的显示器将 usb 3 输出设置成 usb 2 也可以达到 60hz 。
    目前只需要一根线可以实现笔记本 Ubuntu,mba 以及外设的 io,很好用!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1186 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 18:23 · PVG 02:23 · LAX 11:23 · JFK 14:23
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.