0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

物理ディスプレイ前提のVNC環境構築メモ (HDMIダミープラグで任意の解像度を使う)

Posted at

はじめに

x11vnc などを使い、仮想ディスプレイではなく物理ディスプレイに出力している画面をVNCで操作したいケースは意外とある。

例えば、Android Emulator の仮想ディスプレイで描画不具合(OpenGLESでの描画領域が黒くなる)が発生することがあり、そのような不具合を回避するために、物理ディスプレイへの出力画面をVNC経由で操作する必要があった。

ところが、VNCで操作するPCを 普段ディスプレイを接続せずに使っている 場合、x11vnc がうまく動作しない。 そこで、HDMIのダミープラグ を使い、あたかも物理ディスプレイが接続されているかのようにOSに認識させることで、この問題を回避できる。

このダミープラグには、いくつかの解像度がプリセットされているため、デスクトップ環境が自動で適用できるが、プリセットの解像度と実際に使いたいディスプレイの解像度が一致しない場合もある。今回は、そのようなケースで、ダミープラグにプリセットされていない解像度を手動で設定した手順をメモとして残しておく。

解像度

ダミープラグの解像度

ディスプレイを接続して xrandr コマンドで解像度を確認する

xrandr
Screen 0: minimum 320 x 200, current 3440 x 1440, maximum 16384 x 16384
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-1 disconnected (normal left inverted right x axis y axis)
HDMI-2 connected primary 3440x1440+0+0 (normal left inverted right x axis y axis) 344mm x 195mm
   4096x2160     60.00    50.00    59.94    30.00    25.00    24.00    29.97    23.98  
   3840x2160     60.00    50.00    59.94    30.00    25.00    24.00    29.97    23.98  
   1920x1080    120.04    99.99    60.00    60.00    50.00    59.94    30.00    25.00    24.00    29.97    23.98  
   1400x1050     59.95  
   1280x1024     75.02    60.02  
   1440x900      59.90  
   1280x960      60.00  
   1152x864      75.00  
   1280x720      60.00    50.00    59.94  
   1024x768      75.03    70.07    60.00  
   832x624       74.55  
   800x600       72.19    75.00    60.32    56.25  
   640x480       75.00    72.81    66.67    60.00    59.94  
   720x400       70.08  
   3440x1440_60.00  59.94* 
HDMI-3 disconnected (normal left inverted right x axis y axis)

手持ちのディスプレイの解像度

ディスプレイを接続して xrandr コマンドで解像度を確認すると 3440x1440 であり、ダミープラグのプリセットに同じ解像度が存在しないことがわかる。

xrandr
Screen 0: minimum 320 x 200, current 3440 x 1440, maximum 16384 x 16384
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-1 disconnected (normal left inverted right x axis y axis)
HDMI-2 connected primary 3440x1440+0+0 (normal left inverted right x axis y axis) 795mm x 334mm 
3440x1440     60.00*+  50.00 
...

解像度の設定

xrandr のリストには 3440x1440 が表示されていても、内部的にそのモードが認識されていない場合があるため、手動でモードを追加して設定する。

以下の手順で進める。

1. cvt で Modeline を作成

cvt 3440 1440 60

出力例:

# 3440x1440 59.97 Hz (CVT) hsync: 88.82 kHz; pclk: 319.75 MHz
Modeline "3440x1440_60.00"  319.75  3440 3584 3936 4432  1440 1443 1453 1483 -hsync +vsync

2. xrandr で新しいモードを追加

xrandr --newmode "3440x1440_60.00" 319.75 3440 3584 3936 4432 1440 1443 1453 1483 -hsync +vsync

3. HDMI-2 にこのモードを追加

xrandr --addmode HDMI-2 "3440x1440_60.00"

4. 追加したモードを適用

xrandr --output HDMI-2 --mode "3440x1440_60.00"

5. スケールを適用

xrandr --output HDMI-2 --scale 1x1

もし 150% にしたい場合:

xrandr --output HDMI-2 --scale 1.5x1.5

トラブルシューティング

スケールが適用できない場合

Ubuntu標準のデスクトップ環境(GNOME)では、HiDPI(高DPI)ディスプレイに対して自動でスケーリング(例えば200%)を適用する仕組みがあり、物理サイズや解像度をもとに勝手にスケーリングされる場合がある。

この場合は、デスクトップ環境のディスプレイ設定からスケールを手動で設定する。

スクリーンショット 2025-04-25 8.38.07.png

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?