MacOS Tahoe26.1自制定时休眠app

1.打开自动操作

2.文稿类型选择应用程序

3.接着选择实用工具-运行AppleScript

4.替换默认代码

Swift 复制代码
on run
	-- 弹出输入框
	set theMinutes to text returned of (display dialog "请输入多少分钟后让 Mac 进入睡眠:" default answer "30" buttons {"取消", "确定"} default button "确定" cancel button "取消" with title "定时休眠")
	
	-- 检查是否取消
	if theMinutes is "" then return
	
	-- 转换为秒
	set secondsToWait to theMinutes * 60
	
	-- 使用 do shell script 并允许自动认证(避免手动输入密码)
	do shell script "sleep " & secondsToWait & " && pmset sleepnow" user name "your_username" password "your_password" with administrator privileges
	
end run

替换 your_username 为你的帐户名, your_password为你的登录密码

5.保存及修改图标

6.测试运行,以分钟为单位,确定后开始执行

相关推荐
Mintimate5 小时前
WorkBuddy 上手: 让脚本项目 Homebrew CN 变成会排障的 Agent
macos·边缘计算·agent
fthux2 天前
如果你用 Mac,那你可能需要 Noti Shift
macos·开源·github
counterxing4 天前
最近发现一个 Mac 工具,有点像把 Raycast、语音输入法、截图和录屏塞到了一起
macos·ai编程·claude
元Y亨H12 天前
MacBook Air 开发神器:IDEA 与 PyCharm 极简安装及环境配置
macos
yuanyxh12 天前
macOS 应用 - 纯对话生成
前端·macos·ai编程
AI创界者14 天前
PilotTTS 一键整合包(Win/Mac):8G 显存畅跑,实测解锁情绪与副语言的精准控制
人工智能·macos·aigc·音视频
AirDroid_cn14 天前
系统终端与iTerm2字体看起来不一样?macOS Sequoia统一渲染指南
macos
JiaWen技术圈15 天前
2026 年的 macOS 磁盘清理方法
macos
lichong95115 天前
让AI自己用电脑!Cua:后台操作鼠标键盘,Mac/Windows/Linux全支持
人工智能·macos·ai·计算机外设·agent·提示词