monitor

ひっさしぶりにFreeBSDにデスクトップ環境をインストールしたら、かんたんに2画面表示できるようになってて驚いた。
方法は簡単。
xrandrコマンドを使うだけ。
マニュアルはここ
以下、ワイのノートPCでの例を示す。

まずは引数なし、追加のモニタ接続も無しでxrandr
ディスプレイ用ポートの一覧が表示される。
この例ではノートPCなので、メインディスプレイと、そのほかにポートが2つ認識された。
加えて、「メインディスプレイであるeDP-1には1366x768ドットのモニタが繋がっている」というようにも認識されている。

 jd@dyna /u/h/jd> xrandr
Screen 0: minimum 320 x 200, current 1366 x 768, maximum 8192 x 8192
eDP-1 connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 293mm x 164mm
   1366x768      60.00*+
   1024x768      60.04    60.00  
   960x720       60.00  
   928x696       60.05  
   896x672       60.01  
   800x600       60.00    60.32    56.25  
   700x525       59.98  
   640x512       60.02  
   640x480       60.00    59.94  
   512x384       60.00  
   400x300       60.32    56.34  
   320x240       60.05  
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
HDMI-2 disconnected (normal left inverted right x axis y axis)

次に外部モニタを繋いでもう一回xrandr
すると結果が変わり、HDMI-2に1920x1080ドットのモニタが繋がったと認識された。

jd@dyna /u/h/jd> xrandr
Screen 0: minimum 320 x 200, current 1366 x 768, maximum 8192 x 8192
eDP-1 connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 293mm x 164mm
   1366x768      60.00*+
   1024x768      60.04    60.00  
   960x720       60.00  
   928x696       60.05  
   896x672       60.01  
   800x600       60.00    60.32    56.25  
   700x525       59.98  
   640x512       60.02  
   640x480       60.00    59.94  
   512x384       60.00  
   400x300       60.32    56.34  
   320x240       60.05  
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
HDMI-2 connected (normal left inverted right x axis y axis)
   1920x1080     60.00 +  50.00    59.94  
   1920x1080i    60.00    50.00    59.94  
   1600x900      60.00  
   1280x1024     60.02  
   1280x720      60.00    50.00    59.94  
   1024x768      60.00  
   800x600       60.32  
   720x576       50.00  
   720x480       60.00    59.94  
   640x480       60.00    59.94  

あとは簡単で、xrandrに出力先を--output <ポート>で指定し、解像度は--autoで指定。
さらに、外部モニタ表示位置を相対位置で示す。
上記の通りワイの場合eDP-1がメイン画面なので、外部モニタをメイン画面の;

  • 右なら: --right-of eDP-1
  • 左なら: --left-of eDP-1
  • 上なら: --above-of eDP-1
  • 下なら: --below-of eDP-1

と指定する

jd@dyna /u/h/jd> xrandr --output HDMI-2 --auto --right-of eDP-1
jd@dyna /u/h/jd>

これで冒頭の通り表示される。