Skip to main content

mocassino

Lightweight audio player based on MOC for Raspberry Pi Zero 2 devices with Pimoroni Pirate Audio hats

Overview

mocassino is a background service turning a Raspberry Pi device with a Pimoroni Pirate Audio hat into a small standalone audio player.

The service handles the four buttons of the hat, pilots its display, and delegates the playback to MOC (music on console), which it controls by running mocp commands.

Features

  • Playback control with the buttons of the hat: play/pause, previous/next track, seek backward/forward, volume down/up
  • Playback information on the display of the hat: artist, title, and album of the current track, playback progress, volume, and the icons of the actions of the buttons
  • Menu to browse the music root directory and play a directory or a single FLAC, MP3, OGG, or WAV file
  • Menu to change most of the settings of the running service
  • Settings stored in a YAML configuration file
  • Simulator window replacing the buttons and the display, to run the service on a PC without the hardware

Requirements

  • A Raspberry Pi device with a Pimoroni Pirate Audio hat, with MOC (music on console) installed
  • Python 3.13 or later
  • A package/virtual environment manager tool (e.g., micromamba, conda, uv, etc.)

Installation

First, download the install script:

cd /tmp
curl -kO https://raw.githubusercontent.com/pettarin/mocassino/refs/heads/main/install.sh

Inspect all the available options with --help:

bash install.sh --help

Then install the service, adding the relevant options as needed. The following commands require privilege elevation, for instance with sudo:

# install the service with the default options,
# which should be fine for most users
sudo bash install.sh

# install the service, with some custom options set
# (this examples is useful on a Raspberry Pi Zero 2 with DietPi OS)
sudo bash install.sh --display-orientation 180 --library-directory-path /music --run-as-group audio --run-as-user dietpi

By default, the service runs as the mocassino user (see --run-as-user). If the user to run the service as does not exist, the installation script creates it as a system user, adding it to the audio, gpio, and spi groups. The installation script also installs /etc/sudoers.d/999_mocassino, allowing that user to reboot or shut down the host and to restart the service without being prompted for a password.

The last steps of the installation script start the service and then prints its status. If successful, you should see the interface drawn on the display of the hat (see screenshots below).

To uninstall the service and remove all files created by it:

sudo bash install.sh --uninstall

# also remove the user created by the installation script, if any
sudo bash install.sh --uninstall --uninstall-user

Developers And Advanced Users

mocassino is published on PyPI as the same-name package mocassino.

Developers and advanced users might want to setup a development environment instead of relying on the installation script described above. See the DEVELOPMENT documentation for the details.

Usage

The installation script installs mocassino to be run in background via a systemd service, which is started automatically when the device boots up and after the installation.

The MOC server is started automatically, if it is not already running.

By default, mocassino restores both the playback and volume state that were saved the last time the service ran. It is possible to change this behavior in the Settings menu (see below).

Buttons

TODO add a picture of the board here

Button Location
A Top Left
B Bottom Left
X Top Right
Y Bottom Right

Playback Mode

TODO add screenshots here

The default actions for the four buttons of the hat are:

Button Short Click Long/Hold Click
A Play/pause Open the menu
B Next track Previous track
X Volume up Seek forward
Y Volume down Seek backward

Menu Mode

TODO add screenshots here

The default actions for the four buttons of the hat are:

Button Short Click Long/Hold Click
A Back one level (None)
B Select (None)
X Up Select
Y Down Select

Configuration Files

The permanent settings, including the action of each button, are stored in the ~/.config/mocassino/configuration.yaml file, an example of which is located at res/configuration/configuration.yaml. Most of the settings can be changed directly through the service menus, thus not requiring a local or SSH connection to the device running mocassino.

The state of the player is stored in the ~/.config/mocassino/state.yaml file, an example of which is located at res/configuration/state.yaml. Regular users do not need to alter this file.

CLI Usage

The CLI Usage guide describes all the commands, subcommands, and most of the options of the CLI tool mocassino.

Releases And Changelog

The list of releases and their changes is contained in the CHANGELOG document.

Development

Consult the DEVELOPMENT document to learn how to set up a development environment, run the tests, and browse the project structure.

The CONTRIBUTING document explains how to report issues and propose changes.

License

This project is licensed under the GNU General Public License v3.0 or later (GPLv3+).

See the LICENSE file for details.

The bundled Roboto Regular font is licensed under the SIL Open Font License 1.1, see the OFL.txt file for details.

Authors

  • Alberto Pettarin (Web)

Metadata

Release files for mocassino 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mocassino 0.0.8
File Size Uploaded Provenance Actions
mocassino-0.0.8.tar.gz 355.3 kB Without provenance Details for mocassino-0.0.8.tar.gz

Release files / mocassino-0.0.8.tar.gz

Download URL mocassino-0.0.8.tar.gz
Size 355.3 kB
Tags Source
SHA-256 checksum
How to use checksums
921a56c44e5d36d4b306d4bffb974406938bf0bf0f4fb8225f6362c47066fc76
BLAKE2b-256 checksum
How to use checksums
5618d27e502a87a8c0443656d4213536a1dca7507b96cc002e038cb2bda2200d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.0

Security for mocassino 0.0.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page