lsappinfo

[lsappinfo] kLSBundleIdentifierLowerCaseKey 小文字のバンドルID


サンプルコード

サンプルソース(参考)
行番号ソース
001#!/bin/bash
002#com.cocolog-nifty.quicktimer.icefloe
003#
004#################################################
005STR_BUNDLEID="COM.MICROSOFT.EDGEMAC"
006STR_BUNDLEID_LOWCASE=$(/bin/echo "$STR_BUNDLEID" | tr '[:upper:]' '[:lower:]')
007/bin/echo "LowCase小文字のバンドルID: ${STR_BUNDLEID_LOWCASE}"
008
009STR_CNT=$(/usr/bin/lsappinfo | grep -Eo '[0-9]+) "[^"]+" ASN:[^ ]+' | wc -l)
010/bin/echo "総プロセス数は${STR_CNT}"
011
012STR_CNT=$(/usr/bin/lsappinfo find kLSBundleIdentifierLowerCaseKey="$STR_BUNDLEID_LOWCASE" | grep -o ASN: | wc -l)
013/bin/echo "${STR_BUNDLEID_LOWCASE} のプロセス数は${STR_CNT}"
014
015if [ "$STR_CNT" -gt 0 ] ; then
016STR_RESPONSE=$(/usr/bin/lsappinfo find kLSBundleIdentifierLowerCaseKey="$STR_BUNDLEID_LOWCASE")
017/bin/echo ""
018/bin/echo "■ kLSBundleIdentifierLowerCaseKey プロセス一覧"
019/bin/echo "$STR_RESPONSE" | sed 's/": ASN:/": \nASN:/g'
020fi
021
022exit 0
023
024
025kCFBundleNameKey
026kLSASNKey
027kLSASNToBringForwardAtNextApplicationExitKey
028kLSAllowedToBecomeFrontmostKey
029kLSApplicationBackgroundOnlyTypeKey
030kLSApplicationBackgroundPriorityKey
031kLSApplicationCountKey
032kLSApplicationDesiresAttentionKey
033kLSApplicationForegroundPriorityKey
034kLSApplicationForegroundTypeKey
035kLSApplicationHasRegisteredKey
036kLSApplicationHasSignalledItIsReadyKey
037kLSApplicationInStoppedStateKey
038kLSApplicationInThrottledStateAfterLaunchKey
039kLSApplicationInformationSeedKey
040kLSApplicationIsHiddenKey
041kLSApplicationListSeedKey
042kLSApplicationReadyToBeFrontableKey
043kLSApplicationTypeKey
044kLSApplicationTypeToRestoreKey
045kLSApplicationUIElementTypeKey
046kLSApplicationVersionKey
047kLSApplicationWasTerminatedByTALKey
048kLSApplicationWouldBeTerminatedByTALKey
049kLSArchitectureKey
050kLSBundleIdentifierLowerCaseKey
051kLSBundlePathDeviceIDKey
052kLSBundlePathINodeKey
053kLSBundlePathKey
054kLSCheckInTimeKey
055kLSDebugLevelKey
056kLSDisplayNameKey
057kLSExecutableFormatCFMKey
058kLSExecutableFormatKey
059kLSExecutableFormatMachOKey
060kLSExecutableFormatPoundBangKey
061kLSExecutablePathDeviceIDKey
062kLSExecutablePathINodeKey
063kLSExecutablePathKey
064kLSExitStatusKey
065kLSFileCreatorKey
066kLSFileTypeKey
067kLSFlavorKey
068kLSFrontApplicationSeedKey
069kLSHiddenApplicationCountKey
070kLSLaunchTimeKey
071kLSLaunchedByLaunchServicesKey
072kLSLaunchedByLaunchServicesThruForkExecKey
073kLSLaunchedByLaunchServicesThruLaunchDKey
074kLSLaunchedByLaunchServicesThruSessionLauncherKey
075kLSLaunchedInQuarantineKey
076kLSMenuBarOwnerApplicationSeedKey
077kLSModifierLaunchedForPersistenceKey
078kLSModifierRefConKey
079kLSNotifyBecameFrontmostAnotherLaunchKey
080kLSNotifyBecameFrontmostFirstActivationKey
081kLSNotifyLaunchRequestLaunchModifiersKey
082kLSOriginalExecutablePathDeviceIDKey
083kLSOriginalExecutablePathINodeKey
084kLSOriginalExecutablePathKey
085kLSOriginalPIDKey
086kLSPIDKey
087kLSParentASNKey
088kLSParentASNWasInferredKey
089kLSPersistenceSuppressRelaunchAtLoginKey
090kLSPreviousASNKey
091kLSPreviousPresentationModeKey
092kLSPreviousValueKey
093kLSRecordingAppleEventsKey
094kLSRequiresCarbonKey
095kLSSessionIDKey
096kLSShellExecutablePathKey
097kLSUIDsInSessionKey
098kLSUIPresentationModeAllHiddenValue
099kLSUIPresentationModeAllSuppressedValue
100kLSUIPresentationModeContentHiddenValue
101kLSUIPresentationModeContentSuppressedValue
102kLSUIPresentationModeKey
103kLSUIPresentationModeNormalValue
104kLSUIPresentationOptionsKey
105kLSUnhiddenApplicationCountKey
106kLSVisibleApplicationCountKey
107kLSVisibleApplicationListSeedKey
108kLSWantsToComeForwardAtRegistrationTimeKey
109launchedThrottled
110
111
112
113applicationtype
114arch
115asn
116bundleid
117bundlelastcomponent
118bundlename
119bundlenamelc
120bundlepath
121changecount
122creator
123debuglevel
124displayname
125execpath
126executablepath
127filecreator
128filename
129filetype
130hidden
131isconnectedtowindowserver
132isready
133isregistered
134isstopped
135isthrottled
136launchedForPersistence
137launchedinquarantine
138name
139parentasn
140pid
141presentationmode
142presentationoptions
143psn
144recordingAppleEvents
145session
146shellpath
147supressRelaunch
148version
AppleScriptで生成しました

|

[lsappinfo]kLSApplicationTypeKey


サンプルコード

サンプルソース(参考)
行番号ソース
001#!/bin/bash
002#com.cocolog-nifty.quicktimer.icefloe
003#
004#################################################
005STR_CNT=$(/usr/bin/lsappinfo | grep -Eo '[0-9]+) "[^"]+" ASN:[^ ]+' | wc -l)
006/bin/echo "総プロセス数は${STR_CNT}"
007
008STR_CNT=$(/usr/bin/lsappinfo find kLSApplicationTypeKey="Foreground" | grep -o ASN: | wc -l)
009/bin/echo "Foregroundプロセス数は${STR_CNT}"
010
011STR_CNT=$(/usr/bin/lsappinfo find kLSApplicationTypeKey="BackgroundOnly" | grep -o ASN: | wc -l)
012/bin/echo "BackgroundOnlyプロセス数は${STR_CNT}"
013
014STR_CNT=$(/usr/bin/lsappinfo find kLSApplicationTypeKey="UIElement" | grep -o ASN: | wc -l)
015/bin/echo "UIElementプロセス数は${STR_CNT}"
016
017
018STR_RESPONSE=$(/usr/bin/lsappinfo find kLSApplicationTypeKey="Foreground")
019/bin/echo ""
020/bin/echo "■Foregroundプロセス一覧"
021/bin/echo "$STR_RESPONSE" | sed 's/": ASN:/": \nASN:/g'
022
023STR_RESPONSE=$(/usr/bin/lsappinfo find kLSApplicationTypeKey="BackgroundOnly")
024/bin/echo ""
025/bin/echo "■BackgroundOnlyプロセス一覧"
026/bin/echo "$STR_RESPONSE" | sed 's/": ASN:/": \nASN:/g'
027
028STR_RESPONSE=$(/usr/bin/lsappinfo find kLSApplicationTypeKey="UIElement")
029/bin/echo ""
030/bin/echo "■UIElementプロセス一覧"
031/bin/echo "$STR_RESPONSE" | sed 's/": ASN:/": \nASN:/g'
032
033exit 0
034
035
036kCFBundleNameKey
037kLSASNKey
038kLSASNToBringForwardAtNextApplicationExitKey
039kLSAllowedToBecomeFrontmostKey
040kLSApplicationBackgroundOnlyTypeKey
041kLSApplicationBackgroundPriorityKey
042kLSApplicationCountKey
043kLSApplicationDesiresAttentionKey,
044kLSApplicationForegroundPriorityKey
045kLSApplicationForegroundTypeKey
046kLSApplicationHasRegisteredKey
047kLSApplicationHasSignalledItIsReadyKey
048kLSApplicationInStoppedStateKey
049kLSApplicationInThrottledStateAfterLaunchKey
050kLSApplicationInformationSeedKey
051kLSApplicationIsHiddenKey
052kLSApplicationListSeedKey
053kLSApplicationReadyToBeFrontableKey
054kLSApplicationTypeKey
055kLSApplicationTypeToRestoreKey
056kLSApplicationUIElementTypeKey
057kLSApplicationVersionKey
058kLSApplicationWasTerminatedByTALKey
059kLSApplicationWouldBeTerminatedByTALKey
060kLSArchitectureKey
061kLSBundleIdentifierLowerCaseKey
062kLSBundlePathDeviceIDKey
063kLSBundlePathINodeKey
064kLSBundlePathKey
065kLSCheckInTimeKey
066kLSDebugLevelKey
067kLSDisplayNameKey
068kLSExecutableFormatCFMKey
069kLSExecutableFormatKey
070kLSExecutableFormatMachOKey
071kLSExecutableFormatPoundBangKey
072kLSExecutablePathDeviceIDKey
073kLSExecutablePathINodeKey
074kLSExecutablePathKey
075kLSExitStatusKey
076kLSFileCreatorKey
077kLSFileTypeKey
078kLSFlavorKey
079kLSFrontApplicationSeedKey
080kLSHiddenApplicationCountKey
081kLSLaunchTimeKey
082kLSLaunchedByLaunchServicesKey
083kLSLaunchedByLaunchServicesThruForkExecKey
084kLSLaunchedByLaunchServicesThruLaunchDKey
085kLSLaunchedByLaunchServicesThruSessionLauncherKey
086kLSLaunchedInQuarantineKey
087kLSMenuBarOwnerApplicationSeedKey
088kLSModifierLaunchedForPersistenceKey
089kLSModifierRefConKey
090kLSNotifyBecameFrontmostAnotherLaunchKey
091kLSNotifyBecameFrontmostFirstActivationKey
092kLSNotifyLaunchRequestLaunchModifiersKey
093kLSOriginalExecutablePathDeviceIDKey
094kLSOriginalExecutablePathINodeKey
095kLSOriginalExecutablePathKey
096kLSOriginalPIDKey
097kLSPIDKey
098kLSParentASNKey
099kLSParentASNWasInferredKey
100kLSPersistenceSuppressRelaunchAtLoginKey
101kLSPreviousASNKey
102kLSPreviousPresentationModeKey
103kLSPreviousValueKey
104kLSRecordingAppleEventsKey
105kLSRequiresCarbonKey
106kLSSessionIDKey
107kLSShellExecutablePathKey
108kLSUIDsInSessionKey
109kLSUIPresentationModeAllHiddenValue
110kLSUIPresentationModeAllSuppressedValue
111kLSUIPresentationModeContentHiddenValue
112kLSUIPresentationModeContentSuppressedValue
113kLSUIPresentationModeKey
114kLSUIPresentationModeNormalValue
115kLSUIPresentationOptionsKey
116kLSUnhiddenApplicationCountKey
117kLSVisibleApplicationCountKey
118kLSVisibleApplicationListSeedKey
119kLSWantsToComeForwardAtRegistrationTimeKey
120launchedThrottled
121
122
123
124applicationtype
125arch
126asn
127bundleid
128bundlelastcomponent
129bundlename
130bundlenamelc
131bundlepath
132changecount
133creator
134debuglevel
135displayname
136execpath
137executablepath
138filecreator
139filename
140filetype
141hidden
142isconnectedtowindowserver
143isready
144isregistered
145isstopped
146isthrottled
147launchedForPersistence
148launchedinquarantine
149name
150parentasn
151pid
152presentationmode
153presentationoptions
154psn
155recordingAppleEvents
156session
157shellpath
158supressRelaunch
159version
AppleScriptで生成しました

|

[lsappinfo]kCFBundleNameKey

LaunchServices ヘッダー一覧はこちら


サンプルコード

サンプルソース(参考)
行番号ソース
001#!/bin/bash
002#com.cocolog-nifty.quicktimer.icefloe
003#
004#################################################
005STR_BUNDLE_NAME="Microsoft Edge"
006STR_CNT=$(/usr/bin/lsappinfo find kCFBundleNameKey="$STR_BUNDLE_NAME" | grep -c ASN)
007/bin/echo "$STR_CNT"
008if [ "$STR_CNT" -eq 0 ]; then
009  /bin/echo "${STR_BUNDLE_NAME}は起動していません"
010else
011  /bin/echo "${STR_BUNDLE_NAME}は起動中です"
012fi
013exit 0
AppleScriptで生成しました

|

[lsappinfo]起動中のアプリケーションのステータスの詳細

バンドルIDを指定して、対象のアプリケーションが起動中か?調べられる

【スクリプトエディタで開く】|

#!/bin/bash
###kLSBundleIdentifierLowerCaseKeyはUTI バンドルIDは全部小文字で
sh-3.2$ /usr/bin/lsappinfo find kLSBundleIdentifierLowerCaseKey="com.apple.safari"
ASN:0x0-0x5f05f-"Safari":
sh-3.2$ /usr/bin/lsappinfo find kLSBundleIdentifierLowerCaseKey="com.apple.safari" | grep -c ASN
1

####bundleidmの時は通常でOK
sh-3.2$ /usr/bin/lsappinfo  find bundleid=com.apple.Safari
ASN:0x0-0x5f05f-"Safari":
sh-3.2$ /usr/bin/lsappinfo  find bundleid=com.apple.Safari | grep -c ASN
1

sh-3.2$ /usr/bin/lsappinfo | grep ") "
<<RES
1) "loginwindow" ASN:0x0-0x3003:
2) "universalaccessd" ASN:0x0-0x8008:
3) "BackgroundTaskManagementAgent" ASN:0x0-0x9009:
4) "WindowManager" ASN:0x0-0xa00a:
5) "Control Strip" ASN:0x0-0xb00b:
6) "CoreLocationAgent" ASN:0x0-0xc00c:
7) "Dock" ASN:0x0-0xd00d:
8) "SystemUIServer" ASN:0x0-0xe00e:
9) "コントロールセンター" ASN:0x0-0xf00f:
RES
sh-3.2$ /usr/bin/lsappinfo 
<<RES
1) "loginwindow" ASN:0x0-0x3003:
bundleID="com.apple.loginwindow"
bundle path="/System/Library/CoreServices/loginwindow.app"
executable path="/System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow"
pid = 386 type="UIElement" flavor=3 Version="2082.5.1" fileType="APPL" creator="lgnw" Arch=ARM64
checkin time
RES

起動していない場合はmdfind

【スクリプトエディタで開く】|

#!/bin/bash
###起動していない場合はmdfindでも
/usr/bin/mdfind -count kMDItemCFBundleIdentifier = com.apple.Safari
1

|

[lsappinfo]LaunchServices header


サンプルコード

サンプルソース(参考)
行番号ソース
001
002kCFBundleNameKey
003kLSASNKey
004kLSASNToBringForwardAtNextApplicationExitKey
005kLSAllowedToBecomeFrontmostKey
006kLSApplicationBackgroundOnlyTypeKey
007kLSApplicationBackgroundPriorityKey
008kLSApplicationCountKey
009kLSApplicationDesiresAttentionKey,
010kLSApplicationForegroundPriorityKey
011kLSApplicationForegroundTypeKey
012kLSApplicationHasRegisteredKey
013kLSApplicationHasSignalledItIsReadyKey
014kLSApplicationInStoppedStateKey
015kLSApplicationInThrottledStateAfterLaunchKey
016kLSApplicationInformationSeedKey
017kLSApplicationIsHiddenKey
018kLSApplicationListSeedKey
019kLSApplicationReadyToBeFrontableKey
020kLSApplicationTypeKey
021kLSApplicationTypeToRestoreKey
022kLSApplicationUIElementTypeKey
023kLSApplicationVersionKey
024kLSApplicationWasTerminatedByTALKey
025kLSApplicationWouldBeTerminatedByTALKey
026kLSArchitectureKey
027kLSBundleIdentifierLowerCaseKey
028kLSBundlePathDeviceIDKey
029kLSBundlePathINodeKey
030kLSBundlePathKey
031kLSCheckInTimeKey
032kLSDebugLevelKey
033kLSDisplayNameKey
034kLSExecutableFormatCFMKey
035kLSExecutableFormatKey
036kLSExecutableFormatMachOKey
037kLSExecutableFormatPoundBangKey
038kLSExecutablePathDeviceIDKey
039kLSExecutablePathINodeKey
040kLSExecutablePathKey
041kLSExitStatusKey
042kLSFileCreatorKey
043kLSFileTypeKey
044kLSFlavorKey
045kLSFrontApplicationSeedKey
046kLSHiddenApplicationCountKey
047kLSLaunchTimeKey
048kLSLaunchedByLaunchServicesKey
049kLSLaunchedByLaunchServicesThruForkExecKey
050kLSLaunchedByLaunchServicesThruLaunchDKey
051kLSLaunchedByLaunchServicesThruSessionLauncherKey
052kLSLaunchedInQuarantineKey
053kLSMenuBarOwnerApplicationSeedKey
054kLSModifierLaunchedForPersistenceKey
055kLSModifierRefConKey
056kLSNotifyBecameFrontmostAnotherLaunchKey
057kLSNotifyBecameFrontmostFirstActivationKey
058kLSNotifyLaunchRequestLaunchModifiersKey
059kLSOriginalExecutablePathDeviceIDKey
060kLSOriginalExecutablePathINodeKey
061kLSOriginalExecutablePathKey
062kLSOriginalPIDKey
063kLSPIDKey
064kLSParentASNKey
065kLSParentASNWasInferredKey
066kLSPersistenceSuppressRelaunchAtLoginKey
067kLSPreviousASNKey
068kLSPreviousPresentationModeKey
069kLSPreviousValueKey
070kLSRecordingAppleEventsKey
071kLSRequiresCarbonKey
072kLSSessionIDKey
073kLSShellExecutablePathKey
074kLSUIDsInSessionKey
075kLSUIPresentationModeAllHiddenValue
076kLSUIPresentationModeAllSuppressedValue
077kLSUIPresentationModeContentHiddenValue
078kLSUIPresentationModeContentSuppressedValue
079kLSUIPresentationModeKey
080kLSUIPresentationModeNormalValue
081kLSUIPresentationOptionsKey
082kLSUnhiddenApplicationCountKey
083kLSVisibleApplicationCountKey
084kLSVisibleApplicationListSeedKey
085kLSWantsToComeForwardAtRegistrationTimeKey
086launchedThrottled
087
088
089
090applicationtype
091arch
092asn
093bundleid
094bundlelastcomponent
095bundlename
096bundlenamelc
097bundlepath
098changecount
099creator
100debuglevel
101displayname
102execpath
103executablepath
104filecreator
105filename
106filetype
107hidden
108isconnectedtowindowserver
109isready
110isregistered
111isstopped
112isthrottled
113launchedForPersistence
114launchedinquarantine
115name
116parentasn
117pid
118presentationmode
119presentationoptions
120psn
121recordingAppleEvents
122session
123shellpath
124supressRelaunch
125version
AppleScriptで生成しました

|

その他のカテゴリー

Accessibility Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat python Acrobat Reader Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Adobe Adobe FDKO Adobe RemoteUpdateManager AppKit Apple AppleScript AppleScript do shell script AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript System Events AppleScript System Events Plist AppleScript Video Applications AppStore Archive Attributes Automator BackUp Barcode Barcode QR Barcode QR Decode Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome CIImage CityCode CloudStorage Color com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode UTF8 Error EXIFData ffmpeg File Finder Firefox Folder FolderAction Fonts GIF github Guide HTML HTML Entity Icon Illustrator Image Events Image2PDF ImageOptim iPhone iWork Javascript Jedit Json Label Leading Zero List locationd LRC lsappinfo LSSharedFileList m3u8 Mail MakePDF Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Mouse Music NetWork Notes NSArray NSArray Sort NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSColor NSColorList NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSPrintOperation NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth OneDrive PDF PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline perl Photoshop PlistBuddy pluginkit postalcode PostScript prefPane Preview Python QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver SF Symbols character id SF Symbols Entity sips Skype Slack Sound Spotlight sqlite SRT StandardAdditions Swift System Settings TCC TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code Wacom webarchive webp Wifi Windows XML XML EPUB XML OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML XMP YouTube zoom