Cardinalv1.0

Linux Music Folder Player with Media Keys

Why Cardinal? A red, and a songbird.

Runs on: Any Linux desktop. On COSMIC the keyboard shortcuts install themselves.

✨ Install with Claude's help

Not sure how to install this? Let an AI assistant walk you through it, step by step, on your own system.

  1. Copy the instructions below.
  2. Open Claude (a free account works) and paste them in.
  3. Answer its questions and follow along, doing the typing yourself.

Claude in a web browser cannot reach your computer: it reads the instructions, asks about your system, and tells you what to type and what each command does, one step at a time. You stay in control of everything that actually runs.

Using Claude Code? That is the version that runs in a terminal on your own machine, so it can do the downloading and installing itself, asking before each step. Paste this into it instead:

Open in Claude Code ↗needs the Claude Desktop app

Linux Music Folder Player with Media Keys (Cardinal)

Point it at the folder your music lives in and it shuffles everything in there, all the way down through the sub-folders. Start it with a keyboard shortcut, stop it with the same one, and your keyboard's own Play and Next keys work on it.

music, at the command line

Everything else — the panel button, the media keys, the COSMIC shortcuts — drives these same commands.

Please test before relying on it

This is shared as-is, with no warranty. It works on my own computers, but your system, settings and software versions may differ, so please try it in a safe setting first. If something doesn't work, you can ask Claude (or another AI coding assistant) to look into it, and I'd appreciate hearing what you found and how you fixed it. You are also welcome to just let me know at support@veered.org, and I'll look into it.

Information for nerds: requirements and install

Debian / Ubuntu / Pop!_OS package names:

sudo apt install mpv python3
# optional
sudo apt install libnotify-bin                # notifications
sudo apt install python3-gi python3-pydbus    # so the Play/Pause keys reach it
sudo apt install playerctl                    # so other players still get the keys when this one is not running

Install

./install.sh                           # commands only, library = ~/Music
./install.sh --dir ~/Audio/Library     # choose the folder
./install.sh --shortcuts               # Super+M play/pause, Super+N next (below)
./install.sh --shortcuts fkeys         # F9 play/pause, F10 next instead
./install.sh --shortcuts --media-keys  # also take over the Play/Pause media keys

Everything goes to ~/.local/bin, ~/.local/share/cosmic-tools/music and ~/.config/cosmic-tools. Make sure ~/.local/bin is on your PATH.

Uninstall with ./uninstall.sh (it removes the shortcuts it added, after a backup). --purge also deletes settings and the resume position.

How you use it

music                   shuffle the whole library in this terminal
music TEXT              only files whose path contains TEXT (case-insensitive)
music bg [TEXT]         start in the background
music start             pause/resume if playing, otherwise start in the background
music next | prev       skip
music toggle            pause / resume
music stop              stop and remember the position
music now               print the current track (exit status 1 if nothing plays)
music bass [dB]         show or set the bass shelf (-12 .. 12)
music rescan            rebuild the track list cache
music set-dir PATH      save a new library folder
music --dir PATH ...    use another folder for one command

In the terminal player: > next, < previous, space pause, 9/0 volume, q quit.

Information for nerds: settings and environment

~/.config/cosmic-tools/music.conf (sourced by bash):

KeyDefaultMeaning
MUSIC_ROOT"$HOME/Music"Library folder. music set-dir writes it, using $HOME for paths inside your home
MUSIC_MPV_OPTSemptyExtra mpv options, e.g. "--volume=70"
MUSIC_NOTIFY1Desktop notifications

Environment variables: MUSIC_ROOT overrides the file for one run, MUSIC_DRYRUN=1 lists matching files instead of playing, MUSIC_SOCKET changes the IPC socket (default $XDG_RUNTIME_DIR/mpv-music.sock).

Files used: track list cache in ~/.cache/cosmic-tools/music/, resume position in ~/.local/state/cosmic-tools/music-last, bass setting in ~/.config/cosmic-tools/music-bass.

COSMIC shortcuts

Two keys are all you need: one starts, pauses and resumes, the other skips. To stop completely (and remember the position), run music stop.

PresetPlay / pause (starts if stopped)Next trackNotes
--shortcuts (or --shortcuts super)Super+MSuper+NSuper+M replaces COSMIC's default Maximize shortcut; double-click a title bar to maximize instead.
--shortcuts fkeysF9F10COSMIC takes plain F-keys before applications see them, so F9/F10 no longer work inside apps.
--play-key K --next-key Kyour choiceyour choicee.g. --play-key Super+Ctrl+m --next-key Super+Ctrl+n

With --media-keys it also makes Play and Pause run music-playpause, which controls music while it runs and otherwise forwards the key with playerctl play-pause. That replaces COSMIC's built-in handling of those two keys, so it is opt-in.

How the edit is done (tools/cosmic-shortcuts.py):

You can also create the keyboard shortcuts yourself, in the custom shortcuts section of the Keyboard Shortcuts page in COSMIC Settings. Avoid plain Alt combinations: many applications treat them as menu accelerators.

To see or manage custom shortcuts:

python3 ~/.local/share/cosmic-tools/music/cosmic-shortcuts.py list
python3 ~/.local/share/cosmic-tools/music/cosmic-shortcuts.py add --bind "Super+p=$HOME/.local/bin/music-start" --dry-run

License

MIT, see the top-level LICENSE.

Information for nerds: conventions
  • The installer is per-user: it writes to ~/.local/bin, ~/.local/share/cosmic-tools and ~/.config/cosmic-tools, never to system directories, and needs no sudo.
  • Any step that edits a COSMIC config file makes a timestamped backup under ~/.config/cosmic-tools/backups/ first.
  • Configuration files are plain text with comments.
Information for nerds: the source code

Everything this project is made of, as committed: the code, its README files and its license. No build step or account needed to read it.

⬇ Download source (.zip)

cardinal-music-player.zip · 113 KB · released under the license stated on this page.

Please test before relying on these tools. They are shared as-is, with no warranty. They work on my own computers, but your system, settings and software versions may differ, so please try them in a safe setting first. If something doesn't work, you can ask Claude (or another AI coding assistant) to look into it, and I'd appreciate hearing what you found and how you fixed it. You are also welcome to just let me know at support@veered.org, and I'll look into it.