I can get the application name after the user switches focus with the following code:
function applicationWatcher(appName, eventType, appObject)
if (eventType == hs.application.watcher.activated) then
print(appName)
end
end
local appWatcher = hs.application.watcher.new(applicationWatcher)
But I'd like this appName
right after hammerspoon initializes.
See the hs.application.frontmostApplication()
function: http://www.hammerspoon.org/docs/hs.application.html#frontmostApplication :)