開発者であればマルチディスプレイで作業している人も多いはずです。そして抜き差しする度に設定を変えていたり、場合によっては作業する内容によって解像度を変えたりしているかも知れません。いずれにしてもディスプレイの設定変更はGUIで行うので面倒です。 そこで使ってみたいのがdisplayplacerです。CUIからディスプレイの設定変更が可能になります。

displayplacerの使い方

まずはlistを使ってディスプレイとその設定を取得します。

$ displayplacer list
Screen ID: 731393351
Type: 28 inch external screen
Resolution: 1920x1080
Origin: (0,0) - main display
Rotation: 0
Resolutions for rotation 0:
  mode 0: res=1920x1080x60 <-- current mode
    :
  mode 79: res=1024x640x60, scaled

Screen ID: 69733254
Type: MacBook built in screen
Resolution: 1440x900
Origin: (1920,180)
Rotation: 0 - rotate internal screen example (may crash computer, but will be rotated after rebooting): `displayplacer 'id:69733254 degree:90'`
Resolutions for rotation 0:
  mode 0: res=1440x900, scaled <-- current mode
    :
  mode 26: res=2880x1620

Execute the command below to set your screens to the current arrangement:

displayplacer 'id:731393351 res:1920x1080x60 scaling:off origin:(0,0) degree:0' 'id:69733254 res:1440x900 scaling:on origin:(1920,180) degree:0'

後はディスプレイとモードを指定するだけです。

$ displayplacer "id:731393351 mode:0"

画面の向きが設定できたりすると、そのパターンも増えます。モードでの指定の他、数字で細かく指定することもできるようです(ただしうまく動作するかはモニタ次第です)。CLIで変更できるので、会社と自宅など設定ファイル化できて便利そうです。

displayplacerはC製のオープンソース・ソフトウェア(MIT License)です。

jakehilborn/displayplacer: macOS command line utility to configure multi-display resolutions and arrangements. Essentially XRandR for macOS.