Table of Contents

Mac自动化

参考资料:

  1. macOS开机自启动执行脚本 https://www.cnblogs.com/x-kq/p/17952462

构建一个「可执行」的单位

打开「Automator」,创建「Application」
我们基本上使用ZShell脚本实现所有功能,所以选择:「Actions」「Library」「Utilities」「Run Shell Scripts」,然后编写Shell脚本即可
最后选择Save,可以保存为app格式的文件

常用脚本命令

# osascript 命令,是 macOS 自带的 AppleScript 执行工具
 
 
# 通知标题和内容
title="任务完成"
message="备份已成功完成!"
 
# 使用 AppleScript 弹出通知
osascript -e "display notification \"${message}\" with title \"${title}\""
 
# 静音
osascript -e "set volume output muted true"
 
# 设定音量([0, 100])
osascript -e "set volume output volume 50"

自动执行

在登录时自动执行

在这里添加启动项:「Settings」「General」「Login Items」「Login Items」