|
#!/usr/bin/env bash |
|
# ------------------------------------------------------------------------------ |
|
# gpmdp-to-ydp.sh | Copyright (C) 2020 eth-p |
|
# https://gist.github.com/eth-p/427a78b7aca4416161d5b8d07d2a73c7 |
|
# |
|
# This script will convert and rebrand Google Play Music Desktop Player |
|
# to Youtube Music. This is purely a sylistic change. |
|
# ------------------------------------------------------------------------------ |
|
HERE="$(cd "$(dirname "$0")" && pwd)" |
|
set -e |
|
shopt -s nullglob |
|
if [[ "$(uname -s)" != "Darwin" ]]; then |
|
echo "This script is only designed to run on MacOS." |
|
exit 1 |
|
fi |
|
# ------------------------------------------------------------------------------ |
|
GPMDP_APP="/Applications/Google Play Music Desktop Player.app" |
|
YTM_APP="/Applications/YouTube Music.app" |
|
YTM_APP_FRAMEWORKS="${YTM_APP}/Contents/Frameworks" |
|
YTM_APP_PLIST="${YTM_APP}/Contents/Info.plist" |
|
# ------------------------------------------------------------------------------ |
|
rename_package() { |
|
local before="$1" |
|
local after="$2" |
|
local filename="$(basename "$after" | sed 's/\..*$//')" |
|
local info_plist="${after}/Contents/Info.plist" |
|
|
|
# Rename the package. |
|
if [[ -d "$before" ]]; then |
|
echo "Renaming: ${before}" |
|
mv "$before" "$after" |
|
fi |
|
|
|
# Rename the executable. |
|
local executable="${after}/Contents/MacOS/$(defaults read "$info_plist" CFBundleExecutable)" |
|
mv "$executable" "$(dirname "$executable")/${filename}" |
|
plutil -replace CFBundleExecutable -string "$filename" "${info_plist}" |
|
} |
|
# ------------------------------------------------------------------------------ |
|
|
|
# Change the icon. |
|
cp "${HERE}/icon.icns" "${GPMDP_APP}/Contents/Resources/icon.icns" |
|
plutil -replace CFBundleIconFile -string "icon.icns" "${GPMDP_APP}/Contents/Info.plist" |
|
|
|
# Rename the application package and frameworks. |
|
rename_package "$GPMDP_APP" "$YTM_APP" |
|
for framework in "${YTM_APP_FRAMEWORKS}/Google Play Music Desktop Player"*; do |
|
dir="$(dirname "$framework")" |
|
name="$(basename "$framework" | sed 's/^Google Play Music Desktop Player//')" |
|
|
|
rename_package "$framework" "${dir}/Youtube Music${name}" |
|
done |
|
|
|
# Update the plist. |
|
plutil -replace CFBundleDisplayName -string "YouTube Music" "$YTM_APP_PLIST" |
|
plutil -replace CFBundleName -string "YouTube Music" "$YTM_APP_PLIST" |
|
|