Extension Attributes for Chrome Apps

Bongardino
New Contributor III

Trying to create extension attributes to verify the presence of Chrome Apps but I'm baffled. To clarify for anyone who man be unfamiliar, Chrome Apps are different than extensions, they're applications that run on the Google Chrome web browser.

Chrome apps are stored in /Users/~/Applications/Chrome Apps/

BUT

The directory names displayed in Finder do not match the actual file names, aka the ones displayed in terminal.

As an example

FINDER /Users/~/Applications/Chrome Apps/Authy.app TERMKNAL (ls -al) Profile 12 gaedmjdfmmahhbjefcbgaolhhanlaolb.app

See screenshots for further clarification

So, my question becomes, how do I create an extension attribute for something when Im not sure what the filename will be? Can I grep the display filename as opposed to the actual file name?5581343fe8654278965e92f417f446e6
8d183ca084ed4a20b8c7a398bb1c532c

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

I didn't have any Chrome "apps" installed until I saw your post. I installed the Authy app like in your example to take a look. Looks like the info you're looking for is contained in the app's Info.plist as a CrAppModeShortcutName attribute

Using this as an example, I would get the actual display name by doing the following:

$ defaults read ~/Applications/Chrome Apps.localized/Default gaedmjdfmmahhbjefcbgaolhhanlaolb.app/Contents/Info.plist CrAppModeShortcutName
$ Authy

Its also something Spotlight (mdls and mdfind) can read since these are stored right in a standard Spotlight indexed location. I might use mdfind and mdls then to pull that information.

Based on this, the script can cycle through any app bundles inside the "Chrome Apps" directory and pull that name from each one and place them into an array. And then print the array at the end.

Try the following script to see if it does what you want:

#!/bin/bash

for User in $(ls /Users/); do
    if [ -d "/Users/$User/Applications/Chrome Apps.localized" ]; then
        while read appBundle; do
            appDisplayName=$(mdls "$appBundle" -name kMDItemDisplayName | awk -F'"' '{print $2}')
            list+=("$appDisplayName")
        done < <(mdfind -onlyin "/Users/$User/Applications/Chrome Apps.localized" -name kMDItemKind == "Application")
    fi
done

echo "<result>$(printf '%s
' "${list[@]}")</result>"

View solution in original post

2 REPLIES 2

mm2270
Legendary Contributor III

I didn't have any Chrome "apps" installed until I saw your post. I installed the Authy app like in your example to take a look. Looks like the info you're looking for is contained in the app's Info.plist as a CrAppModeShortcutName attribute

Using this as an example, I would get the actual display name by doing the following:

$ defaults read ~/Applications/Chrome Apps.localized/Default gaedmjdfmmahhbjefcbgaolhhanlaolb.app/Contents/Info.plist CrAppModeShortcutName
$ Authy

Its also something Spotlight (mdls and mdfind) can read since these are stored right in a standard Spotlight indexed location. I might use mdfind and mdls then to pull that information.

Based on this, the script can cycle through any app bundles inside the "Chrome Apps" directory and pull that name from each one and place them into an array. And then print the array at the end.

Try the following script to see if it does what you want:

#!/bin/bash

for User in $(ls /Users/); do
    if [ -d "/Users/$User/Applications/Chrome Apps.localized" ]; then
        while read appBundle; do
            appDisplayName=$(mdls "$appBundle" -name kMDItemDisplayName | awk -F'"' '{print $2}')
            list+=("$appDisplayName")
        done < <(mdfind -onlyin "/Users/$User/Applications/Chrome Apps.localized" -name kMDItemKind == "Application")
    fi
done

echo "<result>$(printf '%s
' "${list[@]}")</result>"

Bongardino
New Contributor III

This did it!

Thanks @mm2270 !

I changed it a bit and ended up with the following

CHROMEAPP="Dial"
currentuser=$(stat -f '%Su' /dev/console | /usr/bin/cut -d ' ' -f 4)

output=$(find /Users/$currentuser/Applications/Chrome Apps.localized -regex '.*/Contents/Info.plist$' -print0 | xargs -0 -I{} defaults read "{}" CrAppModeShortcutName | grep $CHROMEAPP)

if [[ $? == 0 ]]; then
    echo "<result>Installed</result>"
else
    echo "<result>Not_Found</result>"
fi