我有一个简单的applescript,可让您按应用在macOS Mojave上的暗模式和亮模式之间进行切换。
但是它无法在Apple Apps上运行,如果我在终端上运行该命令,它可以工作,但是专门为Apple应用程序使用do shell script
会出错。
否则效果很好。这是我将这种设置作为服务的代码:
on run {input, parameters}
tell application "System Events"
set bundleID to bundle identifier of first application process whose frontmost is true
set appname to name of first application process whose frontmost is true
end tell
set res to do shell script "defaults read " & bundleID & " NSRequiresAquaSystemAppearance"
if res is "0" then
do shell script "defaults write " & bundleID & " NSRequiresAquaSystemAppearance -bool Yes"
else
do shell script "defaults write " & bundleID & " NSRequiresAquaSystemAppearance -bool No"
end if
do shell script "killAll " & appname
do shell script "open -a " & appname
return input
end run