home
NOTE: Under Construction - I'm in the middle of upgrading my site and lots of stuff is kinda broken. Please forgive the mess.

Get The Name Of The Current Mac App In OSA/JXA JavaScript

October 2022

Run this to get the name of the currnet app

Code
#!/usr/bin/env osascript -l JavaScript

const appName = Application("System Events").processes.whose(
  {frontmost: {'=': true }}
)[0].name()

console.log(appName)
Results
iTerm2
  • When run in Emacs Org Mode the return value is blank. I'm guessing that has to do with the way it does the execution process

  • I spent an hour figuring out that the reason I couldn't get the name to was due to running it in Emacs. I love having executable source code blocks in my grimoire, but sometimes you run into things like that

═══ § ═══

Footnotes And References