2024年12月3日火曜日

Macにおけるメインディスプレイの変更

MacOSでディスプレイ2台を使用しており、時々に応じてメインディスプレイを切り替えたい時のためのショートカットアプリを作成。 


必要なアプリのインストール

Homebrewで、displayplacerを書きコマンドでインストールする。

 brew install displayplacer


Display IDのチェック

下記コマンドにより、Display IDを調べる。

  displayplacer -list

表示結果の最後に、id;xxxxxx-xxx-xxx-xxx-xxxxx res;....のような表示があり、id;xxxxxx-xxx-xxx-...の数字の部分がディスプレイIDとなるため、メモしておく。


ショートカットアプリでショートカット作成

下記のショートカットアプリを作成。

内容としては、シェルスクリプトでメインディスプレイ(DELL S2722QC)の設定を行い、全てのウィンドウをメインディスプレイに移動させている。

メインディスプレイにするには、origin:(0,0)と設定したディスプレイがメインとなる。

サブディスプレイには1920x1080のモバイルディスプレイを使用しており、画面の位置関係はorigin(3840x1080)を原点とした位置(右下)に設定している。




シェルスクリプトの内容

ディスプレイidや解像度、周波数、origin(x,y)は環境に合わせて設定する必要あり。

#/bin/bash

disp_dell="id:xxxxxxxx"
disp_mobile="id:xxxxxxxx"

key=disp_status

if [ ${key} = "D001" ]; then
command="/opt/homebrew/bin/displayplacer \"${disp_dell} res:3840x2160 hz:60 color_depth:8 enabled:true scaling:off origin:(0,0) degree:0\" \"${disp_mobile} res:1920x1080 hz:60 color_depth:8 enabled:true scaling:on origin:(3840,1080) degree:0\""
elif [ ${key} = "D002" ]; then
command="/opt/homebrew/bin/displayplacer \"${disp_mobile} res:1920x1080 hz:60 color_depth:8 enabled:true scaling:on origin:(0,0) degree:0\" \"${disp_dell} res:3840x2160 hz:60 color_depth:8 enabled:true scaling:off origin:(-3840,-1080) degree:0\""
elif [ ${key} = "D003" ]; then
command="/opt/homebrew/bin/displayplacer \"${disp_dell} res:3840x2160 hz:60 color_depth:8 enabled:true scaling:off origin:(0,0) degree:0\""
elif [ ${key} = "D004" ]; then
command="/opt/homebrew/bin/displayplacer \"${disp_mobile} res:1920x1080 hz:60 color_depth:8 enabled:true scaling:on origin:(0,0) degree:0\" \"${disp_dell} res:3840x2160 hz:60 color_depth:8 enabled:off scaling:off origin:(-3840,-1080) degree:0\""
fi

eval ${command}


0 件のコメント:

コメントを投稿

Kindle関連: EpubファイルをMobiに変更するショートカット

 事前準備 aozoraEpub3とkindlegenを使用する。 aozoraEpub3をダウンロードし、適当なフォルダに保存。 AmazonからKindle previewerをダウンロード、インストールし、kindlegenをaozoraEpub3のフォルダに保存する。 シ...