LSAPPINFO(8) LSAPPINFO(8)

lsappinfo - Control and query CoreApplicationServices about the app state on the system

lsappinfo [options] [ command [command options] ] ...

There are different ways to indicate what application the commands operate on, collectively called the app-specifier. This may be one of the following.

Any string from this set will map to the corresponding constant from the LaunchServices header files.

kCFBundleNameKey
kLSASNKey
kLSASNToBringForwardAtNextApplicationExitKey
kLSAllowedToBecomeFrontmostKey
kLSApplicationBackgroundOnlyTypeKey
kLSApplicationBackgroundPriorityKey
kLSApplicationCountKey
kLSApplicationDesiresAttentionKey,
kLSApplicationForegroundPriorityKey
kLSApplicationForegroundTypeKey
kLSApplicationHasRegisteredKey
kLSApplicationHasSignalledItIsReadyKey
kLSApplicationInStoppedStateKey
kLSApplicationInThrottledStateAfterLaunchKey
kLSApplicationInformationSeedKey
kLSApplicationIsHiddenKey
kLSApplicationListSeedKey
kLSApplicationReadyToBeFrontableKey
kLSApplicationTypeKey
kLSApplicationTypeToRestoreKey
kLSApplicationUIElementTypeKey
kLSApplicationVersionKey
kLSApplicationWasTerminatedByTALKey
kLSApplicationWouldBeTerminatedByTALKey
kLSArchitectureKey
kLSBundleIdentifierLowerCaseKey
kLSBundlePathDeviceIDKey
kLSBundlePathINodeKey
kLSBundlePathKey
kLSCheckInTimeKey
kLSDebugLevelKey
kLSDisplayNameKey
kLSExecutableFormatCFMKey
kLSExecutableFormatKey
kLSExecutableFormatMachOKey
kLSExecutableFormatPoundBangKey
kLSExecutablePathDeviceIDKey
kLSExecutablePathINodeKey
kLSExecutablePathKey
kLSExitStatusKey
kLSFileCreatorKey
kLSFileTypeKey
kLSFlavorKey
kLSFrontApplicationSeedKey
kLSHiddenApplicationCountKey
kLSLaunchTimeKey
kLSLaunchedByLaunchServicesKey
kLSLaunchedByLaunchServicesThruForkExecKey
kLSLaunchedByLaunchServicesThruLaunchDKey
kLSLaunchedByLaunchServicesThruSessionLauncherKey
kLSLaunchedInQuarantineKey
kLSMenuBarOwnerApplicationSeedKey
kLSModifierLaunchedForPersistenceKey
kLSModifierRefConKey
kLSNotifyBecameFrontmostAnotherLaunchKey
kLSNotifyBecameFrontmostFirstActivationKey
kLSNotifyLaunchRequestLaunchModifiersKey
kLSOriginalExecutablePathDeviceIDKey
kLSOriginalExecutablePathINodeKey
kLSOriginalExecutablePathKey
kLSOriginalPIDKey
kLSPIDKey
kLSParentASNKey
kLSParentASNWasInferredKey
kLSPersistenceSuppressRelaunchAtLoginKey
kLSPreviousASNKey
kLSPreviousPresentationModeKey
kLSPreviousValueKey
kLSRecordingAppleEventsKey
kLSRequiresCarbonKey
kLSSessionIDKey
kLSShellExecutablePathKey
kLSUIDsInSessionKey
kLSUIPresentationModeAllHiddenValue
kLSUIPresentationModeAllSuppressedValue
kLSUIPresentationModeContentHiddenValue
kLSUIPresentationModeContentSuppressedValue
kLSUIPresentationModeKey
kLSUIPresentationModeNormalValue
kLSUIPresentationOptionsKey
kLSUnhiddenApplicationCountKey
kLSVisibleApplicationCountKey
kLSVisibleApplicationListSeedKey
kLSWantsToComeForwardAtRegistrationTimeKey
launchedThrottled

Likewise, these short strings also make to the corresponding constants.

allowedtobecomefrontmost
applicationTypeToRestore
applicationWasTerminatedByTAL
applicationtype
arch
asn
bundleid
bundlelastcomponent
bundlename
bundlenamelc
bundlepath
changecount
creator
debuglevel
displayname
execpath
executablepath
filecreator
filename
filetype
hidden
isconnectedtowindowserver
isready
isregistered
isstopped
isthrottled
launchedForPersistence
launchedinquarantine
name
parentasn
pid
presentationmode
presentationoptions
psn
recordingAppleEvents
session
shellpath
supressRelaunch
version

In numerous places a key can be set to a value. The format of value can be any of the following

Notifications are sent out by LaunchServices when various conditions arrive. Each notification has a type, called the notification-code, a dictionary of data items which are specific to the notification, a time the notification was sent, and an optional affected ASN.

launch

Sent when an application is launched

creation

Sent when an entry for an application is created on the system and associated with an ASN.

birth

Sent when an

death

Sent when an application exits.

abnormaldeath

Sent when an application exits with a non-zero exit status.

childDeath

Sent when an application exits, with affected ASN set to the parent ASN of the application which exited.

abnormalChildDeath

Sent when an application exits with a non-zero exit status, with affected ASN set to the parent ASN of the application which exited.

launchFailure

Sent when an application launch fails, after a launch notification has been sent out.

appCreation

Sent when an application is "created", which happens immediately after the application is created and certain items are added into the application information dictionary.

childAppCreation

Sent when an application is "created", which happens immediately after the application is created and certain items are added into the application information dictionary, with affected ASN set to the asn of the parent ASN of this application.

appReady

Sent when an applications signals to LaunchServices that it is ready to accept hide/show events, generally when it has entered its main runloop.

childAppReady

Sent when an applications signals to LaunchServices that it is ready to accept hide/show events, generally when it has entered its main runloop, with affected ASN set to the parent ASN of the application which signalled ready.

readyToAcceptAppleEvents

Sent when an application signals that it is ready to accept AppleEvents.

Sent when talagentd decides that all applications which were launched for persistence have registered.

becameFrontmost

Sent when an application is made into the front application.

lostFrontmost

Sent when an application which previously was the front application is no longer the front application.

orderChanged

Sent when the front-to-back order of the application list changes.

bringForwardRequest

Someone has requested that the application with affected ASN make itself frontmost.

menuBarAcquired

Sent when the application which is responsible for drawing the menu bar (generally the frontmost foreground application) changes

menuBarLost

Sent when the application which was responsible for drawing the menu bar (generally the frontmost foreground application) is no longer responsible

hidden

Sent when the application is hidden

shown

Sent when the application is shown

showRequest

Someone has requested that the application with the affected application asn should show (un-hide) itself.

hideRequest

Someone has requested that the application with the affected application asn should hide itself.

pullwindowsforward

Someone has requested that the application with the affected application asn should show itself and pull all of its windows forward.

appInfoChanged

Sent when the information for the application is changed.

appInfoKeyAdded

Sent when a key is added to the information for the application. The data for the notification will include the key being added and its value.

appInfoKeyChanged

Sent when a value for an item in the application information is changed. The data for the notification will include the key being changes and its new and old value.

appInfoKeyRemoved

Sent when the value for an item in the application information is removed. The data for the notification will include the key being removed and its value.

appTypeChanged

Sent when the "ApplicationType" key in the application information is changed.

appNameChanged

Sent when the application name in the application information is changed.

wantsAttentionChanged

Sent when the LSWantsAttention key in the application information is changed.

presentationModeChanged

Sent when an application changes its presentation mode.

pidChanged

Sent when an application changes its pid. In practice this can never happen, except when LaunchServices launches a process which itself forks or spawns a new process, and then checks-in from that new pid.

frontPresentationModeChanged

Sent when the presentation mode of the system changes, generally when the foreground application changes its own presentation mode or when the front application changes and the old and new applications have different presentation modes.

presentationModeChangedBecauseFrontApplicationChanged

Sent when the presentation mode of the system changes only because the front application changed and the old and new applications have different presentation modes.

Sent when a formally stopped application is started.

sessionLauncherRegister

Sent when the ASN of the session launcher application registers with LaunchServices.

sessionLauncherUnregistered

Sent when the application registered as the session launcher unregisters or exits.

nextAppToBringForwardAtQuitRegistered

Sent when the meta-information item for the next application to bring forward ASN is changed

Sent when the system process (generally loginwindow) registers with LaunchServices.

systemProcessUnregistered

Sent when the system process (generally loginwindow) unregisters with LaunchServices.

frontReservationCreated

Sent when a front-reservation is created.

frontReservationDestroyed

Sent when a front reservation is destroyed.

permittedFrontASNsChanged

Sent when the array of permitted-front-applications changes.

suppressRelaunch

Sent when an application changes its "LSSupressRelaunch" key.

terminatedByTALChanged

Sent when an application changes its "TerminatedByTAL" key.

launchedThrottledChanged

Sent when an application changes * applicationWouldBeTerminatedByTALChanged * applicationProgressValueChanged * applicationVisualNotification * wakeup

Request that the application with affected ASN resume running its main runloop.

sessionCreated

Sent when a session is created, generally when the first application registers inside the session. Affected ASN is always NULL, since this does not refer to any particular application.

sessionDestroyed

Sent when a session is destroyed. Affected ASN is always NULL, since this does not refer to any particular application.

invalid

This represents an invalid notification code, and is never sent.

all

This represents all notification codes, and is never sent, but gets used when specifying which notifications to listen for.

List all of the running applications

lsappinfo list

Show all the notifications which are being sent out

lsappinfo listen +all forever

Show the notifications sent out whenever the front application is changed, for the next 60 seconds

lsappinfo listen +becameFrontmost wait 60

Launch TextEdit.app, asyncronously, and don´t bring it to the front

lsappinfo launch nofront=true async=true /Applications/TextEdit.app/

Find the ASN for the running application "TextEdit", by bundle id

lsappinfo find bundleid=com.apple.TextEdit

Find the ASN for the running application "TextEdit", by name

lsappinfo find name="TextEdit"

Show the information for the running application "TextEdit"

lsappinfo info "TextEdit"

04/01/2013