试图让 Hammerspoon 在 OS X 中打开音乐应用程序时退出(杀死)它。(此应用程序已由 Apple 以一种很难更改的方式安装,并且每当连接蓝牙设备时它就会启动。基本上是烦人的英国媒体报道。)所以,我从 Hammerspoon “入门”页面https ://www.hammerspoon.org/go/ ...
function applicationWatcher(appName, eventType, appObject)
if (eventType == hs.application.watcher.launched) then
if (appName == "Music") then
hs.application:kill()
end
end
end
appWatcher = hs.application.watcher.new(applicationWatcher)
appWatcher:start()
这可以正确响应正在启动的音乐应用程序,但它会像这样出错......ERROR: LuaSkin: hs.application.watcher callback: /Users/seancamden/.hammerspoon/init.lua:142: method 'kill' is not callable (a nil value)
我怎样才能使这个方法可调用?或者,这样做的正确方法是什么?
https://www.hammerspoon.org/docs/hs.application.watcher.html https://www.hammerspoon.org/docs/hs.application.html#kill