IvanCampos/agents / skills/apple-music-player
apple-music-player
VerifiedPlay random songs or specific tracks in Music.app from the local Music library. Use when a user asks to play a random song by artist, random track from an album, random track from a playlist, or a specific track by name (optionally with artist).
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 1.6 KB |
| agents/openai.yaml | config | 292 B |
| scripts/play_random_music.shexecutable | script | 3.7 KB |
scripts/play_random_music.sh
View on GitHub#!/usr/bin/env bash
set -euo pipefail
usage() {
cat <<'USAGE'
Usage:
play_random_music.sh --artist "Artist Name"
play_random_music.sh --album "Album Name"
play_random_music.sh --playlist "Playlist Name"
play_random_music.sh --track "Song Name" [--artist "Artist Name"]
play_random_music.sh ... [--foreground]
Notes:
- Artist, album, and track matching use "contains" for partial matches.
- Playlist matching requires an exact playlist name.
- By default playback starts without bringing Music to foreground.
USAGE
}
mode=""
query=""
artist_filter=""
foreground="false"
while [[ $# -gt 0 ]]; do
case "$1" in
--artist)
if [[ -n "$mode" && "$mode" != "track" ]]; then
echo "Error: only one of --artist/--album/--playlist/--track may be used." >&2
exit 2
fi
if [[ "$mode" == "track" ]]; then
artist_filter="${2:-}"
else
mode="artist"
query="${2:-}"
fi
shift 2
;;
--foreground)
foreground="true"
shift
;;
--album)
if [[ -n "$mode" ]]; then
echo "Error: only one of --artist/--album/--playlist/--track may be used." >&2
exit 2
fi
mode="album"
query="${2:-}"
shift 2
;;
--playlist)
if [[ -n "$mode" ]]; then
echo "Error: only one of --artist/--album/--playlist/--track may be used." >&2
exit 2
fi
mode="playlist"
query="${2:-}"
shift 2
;;
--track)
if [[ -n "$mode" ]]; then
echo "Error: only one of --artist/--album/--playlist/--track may be used." >&2
exit 2
fi
mode="track"
query="${2:-}"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "Error: unknown argument: $1" >&2
usage >&2
exit 2
;;
esac
done
if [[ -z "$mode" || -z "$query" ]]; then
usage >&2
exit 2
fi
/usr/bin/osascript - "$mode" "$query" "$artist_filter" "$foreground" <<'APPLESCRIPT'
on run argv
if (count of argv) < 4 then
error "Expected 4 arguments: mode, query, artist filter, foreground flag."
end if
set mode to item 1 of argv
set query to item 2 of argv
set artistFilter to item 3 of argv
set foregroundFlag to item 4 of argv
tell application "Music"
if it is not running then
launch
end if
if foregroundFlag is "true" then
activate
end if
if mode is "artist" then
set lib to library playlist "Library"
try
set t to some track of lib whose artist contains query
on error
error "No artist matches: " & query
end try
play t
else if mode is "album" then
set lib to library playlist "Library"
try
set t to some track of lib whose album contains query
on error
error "No album matches: " & query
end try
play t
else if mode is "playlist" then
try
set pl to playlist query
on error
error "Playlist not found: " & query
end try
try
set t to some track of pl
on error
error "No tracks in playlist: " & query
end try
play t
else if mode is "track" then
set lib to library playlist "Library"
if artistFilter is not "" then
try
set t to first track of lib whose name contains query and artist contains artistFilter
on error
error "No track matches: " & query & " by " & artistFilter
end try
else
try
set t to first track of lib whose name contains query
on error
error "No track matches: " & query
end try
end if
play t
else
error "Unknown mode: " & mode
end if
end tell
end run
APPLESCRIPT
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |