Last active
April 22, 2024 12:33
-
-
Save andrewp-as-is/1ab9807998e82dfbb7d774f98cf6df9c to your computer and use it in GitHub Desktop.
macOS app frontmost
This file contains 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
#!/usr/bin/env bash | |
{ set +x; } 2>/dev/null | |
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}' | |
This file contains 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
#!/usr/bin/env bash | |
{ set +x; } 2>/dev/null | |
osascript <<EOF | |
tell application "System Events" | |
name of (first process whose frontmost is true) | |
end tell | |
EOF |
@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?