macOSのディスプレイ解像度を変更するコマンド

コマンドからDisplay解像度を変更する方法です。

“cscreen”という便利なコマンドがあります。

Install

brew install cscreen
Error:
  homebrew-core is a shallow clone.
  homebrew-cask is a shallow clone.
To `brew update`, first run:
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
These commands may take a few minutes to run due to the large size of the repositories.
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!
==> Downloading https://www.pyehouse.com/wp-content/uploads/2012/09/cscreenIntel.dmg
######################################################################## 100.0%
==> Installing Cask cscreen
==> Linking Binary 'cscreen' to '/usr/local/bin/cscreen'.
🍺  cscreen was successfully installed!

解像度変更(2048×1280へ変更する場合)

cscreen -s1 -x 2048 -y 1280

対応解像度一覧

cscreen -s1 -v
DisplayID  Index     Depth     Width     Height  Refresh
 4280e40       1        32      2560       1600     0
 4280e40       2        32      1280        800     0
 4280e40       3        32      2880       1800     0
 4280e40       4        32      2048       1280     0
 4280e40       5        32      1650       1050     0
 4280e40       6        32      1440        900     0
 4280e40       7        32      1152        720     0
 4280e40       8        32      1024        768     0
 4280e40       9        32       840        524     0
 4280e40      10        32       800        600     0
 4280e40      11        32       640        480     0
use -h to display all usage options

現在の解像度

cscreen -l
DisplayID  Index     Depth     Width     Height  Refresh
 4280e40       1        32      2048       1280     0
use -h to display all usage options

参考にさせていただきました。ありがとうございます。