2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Ubersichtを複数ディスプレイに振り分けるAppleScript

Last updated at Posted at 2024-03-18

デスクトップに好きなWidgetを貼り付けられるユーティリティー「Übersicht」は、起動時のモニタ認識順で配置を割り振ってしまうようで、複数ディスプレイ環境では起動時に設定しなおす手間があります(2024/03/18現在のバージョン1.6(82))
結構な手間なので、AppleScriptでなんとかします。デフォルトで置いときたいディスプレイと、例外処理として他のディスプレイを指定できます。

※Bartenderを使っていない場合は該当コメント部分を削除してください。

MenuExtraクリックで最初のメニューを表示してから1.5秒のラグがあるのを解決できていません。なんだろう?
Clickでなく、Selectにすると一瞬で終わります。

use Uber : application id "tracesOf.Uebersicht"
set ubername to name of Uber

--「Show on」に続くディスプレイ名称。1番目がデフォルトディスプレイ
set myDisp to {"ASM-133UCJ", "Studio Display", "CS2731"}

-- 例外処理したいWidget名をメニュー表示内容通りに記載し、myDispリストの番号とセットのリストにする
set myWgDisp to {{"workingfolders-widget-workingfolders-coffee", 2}}

--Bartender等で隠している場合は表示させる。二回実行でメニューを展開したものを戻し、アイコンのみ表示させる
try
	tell application "Bartender" to activate "tracesOf.Uebersicht-Item-0"
	tell application "Bartender" to activate "tracesOf.Uebersicht-Item-0"
end try

--全Widgetを一度メインスクリーンのみ表示モードにしてから切り替える
tell Uber
	set myWidgets to id of every widget
	repeat with i in myWidgets
		set showOnMainScreen of widget id i to true
	end repeat
end tell


tell application "System Events"
	tell process ubername
		repeat with i in myWidgets
			
			--Menu Extraをクリックしてメニュー表示
			set myExtra to menu bar 2's menu bar item 1
			click myExtra
			
			--メニュー内のWidgetサブメニューを表示
			set myWidgetMenu to myExtra's menu 1's menu item i
			select myWidgetMenu
			
			--例外処理リストになければデフォルトディスプレイ名を設定
			set xCount to 1
			set myDispName to item 1 of myDisp
			repeat with x in myWgDisp
				if item 1 of x contains i then
					set myDispName to item (item 2 of x) of myDisp
					exit repeat
				end if
				set xCount to xCount + 1
			end repeat
			
			--ディスプレイ名称のあるメニューをクリック
			set myDispSel to myWidgetMenu's menu 1's menu item ("Show on " & myDispName)
			click myDispSel
		end repeat
	end tell
end tell
2
0
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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?