itunesnp

Print the currently playing Music.app track in 'Now Playing' format.

View on GitHub

itunesnp

NPM Version NPM Downloads GitHub tag (with filter) License GitHub commits since latest release (by SemVer including pre-releases) CodeQL QA Tests Coverage Status Dependabot Stargazers pre-commit Prettier TypeScript Yarn eslint vitest

@Tatsh Buy Me A Coffee Libera.Chat Mastodon Follow Patreon

Print the currently playing Music.app track in Now Playing: <artist> - <track> format. Handy for IRC /np commands.

Installation

Install globally and run itunesnp.

yarn global add itunesnp
# or
npm install --global itunesnp

Usage

itunesnp

Sample output:

Now Playing: Daft Punk - Around the World

Nothing is printed when Music is not running, paused, or stopped. The command still exits successfully so it can be used unconditionally in shell-out hooks.

IRC clients

For IRC clients that support shelling out, point the /np (or similar) command at itunesnp. As an example, for X-Chat Aqua you can either add a user command from the menu or edit ~/.xchat2/commands.conf:

NAME NP
CMD exec -o itunesnp

Then restart the client and type /np. The command name can be anything (upper-case).

Quassel

Quassel invokes scripts in ~/Library/Application Support/Quassel/scripts/ via its /exec command. The Linux build ships an mpris script there, so installing itunesnp under that name lets a single client-side alias work on both Linux and macOS.

mkdir -p "$HOME/Library/Application Support/Quassel/scripts"
cp "$(yarn global bin)/itunesnp" \
    "$HOME/Library/Application Support/Quassel/scripts/mpris"
chmod +x "$HOME/Library/Application Support/Quassel/scripts/mpris"

In Preferences → Aliases, add an alias named np (or any name you like) that expands to /exec mpris. Arguments after mpris are ignored. Type /np in a chat and the metadata is broadcast publicly. This replaces the older quassel-itunes-np CoffeeScript shim.

Quassel Aliases preferences pane showing an np entry that expands to /exec mpris.

Development

yarn               # install dependencies.
yarn test          # run vitest with coverage.
yarn webpack       # bundle src/index.ts to dist/index.js.
yarn qa            # lint, spell-check, and prettier check.

The CLI is written in TypeScript and bundled with webpack. JXA global types come from jxa-types.