oooo so just got a pixel 9a –– idk if this was the trouble with other people, but on android 15 (previously just had a 6a running android 14), they output the user ID's diff so my prev script couldn't recognize it.
here is an udpated version, still following the same steps (1.) make sure adb is in your path; 2.) create script and chmod +x it; 3.) delete any existing work profile, make sure apps you want installed already are + edit script as normal; 4.) try to login to work profile; 5.) after crash, open up a work app, try to sign-in, start script, get taken to settings, should inject)
the main problem snag i'd imagine, which i kinda ran into, is that it's such a short interval that it will be blocked by adb if you're installing too many apps (despite shortening the interval). also, i tried to inject play store as having rights to install unknown apps, but despite it correctly setting it to allow, it still didn't work. with that said, all i really need is gmail + calendar, so it's good enough for me rn! code:
`#!/bin/bash
INTERVAL=0.05
PACKAGES=(
com.google.android.gms # Play Services
com.android.vending # Play Store
com.google.android.gm # Gmail
com.google.android.calendar # Calendar
com.google.android.apps.tachyon # Meet
com.google.android.apps.chrome # Chrome
com.google.android.apps.docs # Docs
com.google.android.apps.docs.editors.sheets # Sheets
com.google.android.apps.docs.editors.slides # Slides
)
echo "⏳ Waiting for Work profile..."
while true; do
USERS=$(adb shell pm list users 2>/dev/null)
WORK_LINE=$(echo "$USERS" | grep -i "Work profile")
if [[ -n "$WORK_LINE" ]]; then
USER_ID=$(echo "$WORK_LINE" | cut -d'{' -f2 | cut -d':' -f1)
if [[ -n "$USER_ID" ]]; then
echo "✅ Work profile user $USER_ID detected. Injecting ${#PACKAGES[@]} apps..."
for pkg in "${PACKAGES[@]}"; do
adb shell cmd package install-existing --user "$USER_ID" "$pkg"
done
echo "🎉 Done."
exit 0
fi
fi
sleep "$INTERVAL"
done
`