切换深色模式
tell application "System Events"
tell appearance preferences
set dark mode to not dark mode
end tell
end tell
设置亮度:
# 提高亮度
osascript -e 'tell application "System Events"' -e 'key code 144' -e ' end tell'
# 降低亮度
osascript -e 'tell application "System Events"' -e 'key code 145' -e ' end tell'
获取亮度等级:
brightness
命令不支持 M1 芯片的MacBook,其他机型未测试
获得音量等级:
osascript -e 'get volume settings'
可能的输出:
# 静音
output volume:0, input volume:100, alert volume:100, output muted:true
# missing
output volume:missing value, input volume:100, alert volume:100, output muted:missing value
# 数值
output volume:28, input volume:100, alert volume:100, output muted:false