![](/img/trans.png)
[英]bash - Mac OS X - how to run an application as multiple users?
[英]How to run bash script on wake mac os x
想要在唤醒 (osx) 时更改 Wi-Fi 设置。
我有脚本,但不想每次都手动运行它。
有没有办法在唤醒时运行它?
也许这会帮助你:
登录mac时运行脚本[关闭]
这个唤醒后运行脚本的功能可以通过强大的hammerspoon来实现:
function printf(s,...) print(s:format(...)) end
wather = hs.caffeinate.watcher.new(function(eventType)
-- screensDidWake, systemDidWake, screensDidUnlock
if eventType == hs.caffeinate.watcher.systemDidWake then
local output = hs.execute("/bin/echo -n hello", false)
hs.notify.new({title="TestTitle", informativeText=output}):send()
printf("%s, world", output)
end
end)
wather:start()
将这些脚本放到$HOME/.hammerspoon/init.lua
并重新加载hammerspoon,您可以在hammerspoon 控制台中查看上面的/bin/echo 输出。
有几个唤醒事件,包括screensDidWake,systemDidWake,screensDidUnlock。 有关详细信息,请参阅wather api 文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.