Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # --- 準備: プロセス停止 ---
- killall Music 2>/dev/null || true
- killall cfprefsd 2>/dev/null || true
- # --- libID を自動検出 ---
- local libid=""
- local p
- for p in \
- "$HOME/Library/Preferences/com.apple.Music.plist" \
- "$HOME/Library/Containers/com.apple.Music/Data/Library/Preferences/com.apple.Music.plist"
- do
- if [ -f "$p" ]; then
- libid=$(plutil -p "$p" 2>/dev/null | grep -Eo 'PPr4:LIB:[0-9a-f]+' | awk -F: '{print tolower($3)}' | head -1)
- [ -n "$libid" ] && break
- fi
- done
- if [ -z "$libid" ]; then
- # .musiclibrary の Preferences.plist から拾う(ホーム&外部ボリューム)
- while IFS= read -r libpkg; do
- [ -n "$libpkg" ] || continue
- local pref="$libpkg/Preferences.plist"
- if [ -f "$pref" ]; then
- libid=$(plutil -p "$pref" 2>/dev/null | awk -F'"' '/Library Persistent ID/ {print tolower($4)}' | head -1)
- [ -n "$libid" ] && break
- fi
- done < <(mdfind -name "Music Library.musiclibrary" -onlyin "$HOME/Music" 2>/dev/null; \
- mdfind -name "Music Library.musiclibrary" -onlyin "/Volumes" 2>/dev/null)
- fi
- if [ -z "$libid" ]; then
- echo "ERROR: libID を自動検出できませんでした。Music を一度起動→終了するか、手動でキーが1件作成されていることを確認してください。"
- return 1
- fi
- echo "libID=$libid"
- # --- 総数取得 ---
- local COUNT
- COUNT=$(osascript -e 'tell application "Music" to launch' \
- -e 'tell application "Music" to count of user playlists')
- if ! echo "$COUNT" | grep -qE '^[0-9]+$'; then
- echo "ERROR: プレイリスト件数を取得できませんでした。Automation 権限(Terminal→Music)をご確認ください。"
- return 2
- fi
- echo "playlists=$COUNT"
- # --- 1件ずつ PID を取り vMF=4 を設定 ---
- local i PID KEY
- for i in $(seq 1 "$COUNT"); do
- PID=$(osascript -e 'tell application "Music" to try
- return persistent ID of item '"$i"' of user playlists
- on error
- return ""
- end try' | tr '[:upper:]' '[:lower:]')
- if echo "$PID" | grep -qE '^[0-9a-f]{16}$'; then
- KEY="PPr4:LIB:${libid}:${PID}"
- defaults write com.apple.Music "$KEY" -dict-add viewModeForPlaylist -int 4
- printf 'OK\t%02d\t%s\n' "$i" "$PID"
- else
- printf 'SKIP\t%02d\n' "$i"
- fi
- done
- # --- 反映&サマリ ---
- killall cfprefsd 2>/dev/null || true
- plutil -p "$HOME/Library/Preferences/com.apple.Music.plist" \
- | grep -Eo 'PPr4:LIB:[0-9a-f]+:[0-9a-f]{16}' | wc -l
- plutil -p "$HOME/Library/Preferences/com.apple.Music.plist" \
- | grep -E '"viewModeForPlaylist" => 4' | wc -l
Advertisement
Comments
-
- macOS Ventura/Sonoma/Sequoiaで、プレイリストを開くとMusic.appがクラッシュしてしまう人向けのプログラム。
- ~/Library/Preferences/com.apple.Music.plist を編集し、プレイリストの表示設定を「曲ごとに表示」に統一します。
- A program for people whose Music.app crashes when opening playlists on macOS Ventura/Sonoma/Sequoia.
- It edits ~/Library/Preferences/com.apple.Music.plist to unify playlist view settings to “Songs.”
Add Comment
Please, Sign In to add comment