利用 xrandr 命令修改屏幕分辨率

問題背景

  • 電腦外接着一個 23‘ 的顯示器,分辨率爲 1920*1080ubuntu

  • 操做系統:ubuntu 14.04ruby

今天,經過 Setting->Displays 中選擇外接屏的分辨率時,發現最大隻有 1024×768,而且外接屏顯示 「Unknown Displays」,日了狗了。。。ide


解決方案

解決辦法主要是給這個 「Unknown Displays」 設置一個 1920*1080 的選項,下面藉助 xrandr 命令來實現。spa


先查看兩個屏幕支持的分辨率狀況

在終端輸入 xrandr操作系統

 
 
 
 
 
  • 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
$ 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)

注:.net

  • 上面顯示了兩個屏幕分辨率選項,後面標示 * 即爲屏幕當前分辨率
  • 這裏顯示好幾個接口:eDP1, DP1, HDMI1, DP2, HDMI2, VIRTUAL1,可是隻有 eDP1 和 DP2 有鏈接,而且 DP2 對應咱們外接屏(這個值後面會用到!)

利用 cvt 新建一個 modeline

代碼以下:code

 
 
 
 
 
  • 1
  • 1
$ cvt 1920 1080

而後屏幕上會返回兩行內容,賦值第二行中 ‘Modeline’ 後面的全部內容,並接到下面 xrandr --newmode 後面:orm

 
 
 
 
 
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3
$ 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

其中 」DP2「 即上面展現的外接端口,不用的接口這個名字可能不一樣,好比有的會是 VGA1,以上面 xrandr 的顯示結果爲準。server

以後,再進入 Setting->Displays, 發現那個 「Unknown Display」 的分辨率中,有了 「1920x1080」 這個選項,選中它,並 Apply 便可。blog

Section "InputDevice"Identifier "Generic Keyboard"Driver "kbd"Option "XkbRules" "xorg"Option "XkbModel" "pc104"Option "XkbLayout" "us"EndSectionSection "InputDevice"Identifier "Configured Mouse"Driver "mouse"EndSectionSection "Device"Identifier "Configured Video Device"EndSectionSection "Monitor"Identifier "Monitor0"VendorName "Unknown"ModelName "Unknown"HorizSync 30.0 - 83.0VertRefresh 50.0 - 75.0Option "DPMS"Modeline "1600x1200_60.00"  161.00  1600 1712 1880 2160  1200 1203 1207 1245 -hsync +vsyncModeline "1600x1228_60.00"  128.00  1600 1632 1664 1728  1200 1203 1207 1235 -hsync +vsyncModeline "1400x1050_60.00"  121.75  1400 1488 1632 1864  1050 1053 1057 1089 -hsync +vsyncModeline "1024x768_60.00"   63.50  1024 1072 1176 1328  768 771 775 798 -hsync +vsyncEndSectionSection "Screen"Identifier "Default Screen"Monitor "Monitor0"SubSection "Display"Modes "1600x1200" "1600x1228" "1400x1050" "1024x768" EndSubSectionEndSection

相關文章
相關標籤/搜索