Last active
August 3, 2024 18:53
-
-
Save andrewpetrochenkov/1ab9807998e82dfbb7d774f98cf6df9c to your computer and use it in GitHub Desktop.
macOS frontmost app #app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| osascript <<EOF | |
| tell application "System Events" | |
| name of (first process whose frontmost is true) | |
| end tell | |
| EOF | |
| lsappinfo info -only name `lsappinfo front` | awk -F'"' '{print $4}' | |
| lsappinfo info -only pid `lsappinfo front` | awk -F'"=' '{print $2}' | |
| lsappinfo info -only bundlepath `lsappinfo front` | awk -F'"' '{print $4}' | |
| lsappinfo info -only bundleID `lsappinfo front` | awk -F'"' '{print $4}' | |
@NightMachinery I discovered a fix: https://stackoverflow.com/questions/24515436/how-to-get-current-foreground-applications-name-or-pid-in-os-x#comment138153740_24562352
In short, do lsappinfo info `lsappinfo front | sed 's/-/-0x/'` instead.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
lsappinfo info `lsappinfo front`has stopped working for me after updating to Sonoma. Does it work for you?