3

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.

Justin Tanner
  • 14,062
  • 17
  • 82
  • 103

1 Answers1

7

See the hs.application.frontmostApplication() function: http://www.hammerspoon.org/docs/hs.application.html#frontmostApplication :)

Justin Tanner
  • 14,062
  • 17
  • 82
  • 103
Chris Jones
  • 456
  • 2
  • 8