A simple command-line Apple Music controller script which includes a "Now Playing" widget function, a playback function, and a list-out function for your Mac's Music.app library, written in sh.
First off, thank you for this! Nice to be able to have a CLI interface without the Music app in your face.
Is there a way to completely disable album art display? I would like to have the np output by itself and not have a big black square on the left side of the output.
When I start am np I get the following error: bash: line 0: read: .5: invalid timeout specification
It appears zsh (at least the version i'm running can't handle decimal numbers. If I change the following line input=$(bash -c "read -n 1 -t .5 input; echo \$input | xargs")
to input=$(bash -c "read -n 1 -t 1 input; echo \$input | xargs")
the error disappears.
macOS 12.6.1 and zsh 5.8.1 (x86_64-apple-darwin21.0)
Would you consider adding the ability to search for content by pattern? This would just require adding a command-line option that would accept a pattern and then grepping that pattern from the osascript output.
For example,
am list -a -r '.*Monk.*'
would search for every artist with the string "Monk" in it, which would capture "Thelonious Monk," as well as "The Thelonious Monk Quartet," etc.
Maybe easier to just have it be a substring rather than regexp match so -r 'monk' would return everything that has "monk" anywhere in it.
This script works well for music already in the user's library. Might you consider expanding it to play content that isn't yet in the library? I think this should be possible with AppleScript. At a minimum, you can open a itms:// item from the shell which will cause that URL to start playing in Music.app, even if it's not currently in the library. These links can be found by web-searching for the album/artist/track name + music.apple.com, and then replacing https:// with itms://
Nice work! When I run the zsh am.sh np, I got these two lines of error message keep blinking. And the keyboard shortcut seems not working. Any idea how to fix it? Thank you!
Describe the bug
each line of the player begins at between 27 and 32 spaces from the left edge of the terminal
To Reproduce
running zsh am.sh np (default usage)
Expected behavior
text should be left justified
Desktop (please complete the following information):
OS: iOS Monterey
I cannot determine from the code what's causing the indenting. This behavior is probably by design, not a bug, but either way I would appreciate knowing how to adjust the appearance of the player, particularly, the indentation. Thanks very much. Really love this player.