Make sure the installer launches BGMApp as the logged-in user.

This commit is contained in:
Kyle Neideck 2019-08-17 15:20:47 +10:00
parent e6e784b013
commit 4c7eba30af
No known key found for this signature in database
GPG key ID: CAA8D9B8E39EC18C

View file

@ -55,9 +55,15 @@ bash "post_install.sh" "$xpc_helper_path" "BGMXPCHelper.xpc/Contents/MacOS/BGMXP
# That way, if the user moves BGMApp and then installs a newer version of Background Music, the
# installer will try to find the old version of BGMApp and put the new one in the same place.
#
# Use launchctl to make sure we don't run BGMApp as the installer user.
#
# If we can't open BGMApp, it very likely didn't install properly, so we fail the install.
open -b com.bearisdriving.BGM.App || \
logged_in_user_id="$(id -u "${USER}")"
launchctl asuser "${logged_in_user_id}" \
open -b com.bearisdriving.BGM.App || \
launchctl asuser "${logged_in_user_id}" \
open "${dest_volume}/Applications/Background Music.app" || \
osascript -e 'tell application "Background Music" to activate' || \
exit 1
# The installer plays a sound when it finishes, so give BGMApp a second to launch.