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>"
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