Thanks to visit codestin.com
Credit goes to Github.com

Skip to content
/ mpdl Public

Command-line client for [Music Player Daemon (MPD)](https://www.musicpd.org/) with monitoring capabilities, GNTP/Growl notifications, and MPC-like functionality.

License

Notifications You must be signed in to change notification settings

cumulus13/mpdl

Repository files navigation

mpdl - Advanced MPD CLI Client

Go Version License Platform

Command-line client for Music Player Daemon (MPD) with monitoring capabilities, GNTP/Growl notifications, and MPC-like functionality.

Features

✨ Core Features:

  • 🎡 Complete MPD control (play, pause, stop, next, previous)
  • πŸ“ Playlist management (add, delete, clear, list)
  • πŸ”Š Volume and playback mode control
  • πŸ“Š Beautiful colored terminal output
  • πŸ”„ Automatic reconnection on connection loss
  • πŸ–₯️ Cross-platform support (Windows, Linux, macOS)

🎬 Monitor Mode:

  • πŸ‘€ Real-time monitoring of MPD status
  • πŸ“’ Desktop notifications via GNTP/Growl
  • 🎨 Album artwork support
  • ⌨️ Keyboard shortcuts for quick control
  • πŸ”” Song change and state notifications

βš™οΈ Advanced:

  • πŸ“„ TOML configuration file support
  • πŸ”§ MPD config file editing (local MPD)
  • 🌍 Environment variable support
  • πŸ” Debug mode for troubleshooting
  • 🎯 MPC-compatible commands

Installation

From Source

git clone https://github.com/cumulus13/mpdl.git
cd mpdl
go build -o mpdl

Using Go Install

go install github.com/cumulus13/mpdl@latest

Pre-built Binaries

Download the latest release from the releases page.

Quick Start

# Show help
mpdl --help

# Start playback
mpdl play

# Add a song to playlist
mpdl add ~/Music/song.mp3

# Show current playlist
mpdl list

# Monitor MPD with notifications
mpdl monitor

# Show current status
mpdl status

Configuration

Configuration File

Create a configuration file at ~/.config/mpdl/config.toml (Linux/macOS) or %APPDATA%\mpdl\config.toml (Windows):

[mpd]
host = "localhost"
port = "6600"
password = ""
timeout = 10
music_root = "/home/user/Music"  # or "C:/Musics" on Windows
config_path = "/home/user/.config/mpd/mpd.conf"

[gntp]
host = "localhost"
port = 23053
password = ""
icon_mode = "binary"  # binary, dataurl, fileurl, httpurl
enabled = true

[display]
show_album_art = true
use_color = true

Environment Variables

export MPD_HOST="localhost"
export MPD_PORT="6600"
export MPD_PASSWORD=""
export MPD_TIMEOUT="10"
export MPD_MUSIC_ROOT="/home/user/Music"
export DEBUG="1"  # Enable debug mode

Usage

Playback Commands

mpdl play [POS]        # Start playback (optionally at position)
mpdl pause             # Toggle pause
mpdl stop              # Stop playback
mpdl next              # Next song (alias: n)
mpdl prev              # Previous song (aliases: previous, p)
mpdl seek [+/-]TIME    # Seek to position (e.g., 30, +10, -5)

Playlist Commands

mpdl add PATH          # Add song/directory to playlist
mpdl del PATH          # Delete songs matching PATH (aliases: delete)
mpdl clear             # Clear playlist
mpdl list              # Show current playlist (aliases: ls, playlist)

Information Commands

mpdl current           # Show current song
mpdl status            # Show player status (alias: st)

Options Commands

mpdl volume [VOL]      # Set volume (0-100) or show current
mpdl repeat [on|off]   # Toggle or set repeat mode
mpdl random [on|off]   # Toggle or set random mode
mpdl single [on|off]   # Toggle or set single mode

Database Commands

mpdl update [PATH]     # Update music database

Config Commands (Local MPD Only)

mpdl get-config KEY          # Get MPD config value
mpdl set-config KEY VALUE    # Set MPD config value

Examples:

mpdl get-config music_directory
mpdl set-config volume_normalization yes

Monitor Mode

mpdl monitor           # Start monitoring mode (aliases: mon, m)

Keyboard Shortcuts in Monitor Mode:

  • p - Play/Pause
  • s - Stop
  • n - Next song
  • b - Previous song (back)
  • q - Quit monitor

Examples

Basic Usage

# Connect to MPD and show status
mpdl status

# Add all MP3 files from a directory
mpdl add ~/Music/Artist/Album

# Delete all songs from an artist
mpdl del "Artist Name"

# Set volume to 75%
mpdl volume 75

# Enable shuffle mode
mpdl random on

Monitor Mode with Notifications

# Start monitoring with default settings
mpdl monitor

# Start monitoring with custom config
mpdl --config ~/.config/mpdl/config.toml monitor

# Monitor with debug output
mpdl --debug monitor

Using with Remote MPD

# Connect to remote MPD server
mpdl --mpd-host 192.168.1.100 --mpd-port 6600 status

# Or set environment variables
export MPD_HOST="192.168.1.100"
export MPD_PORT="6600"
mpdl play

Configuration Management

# View MPD music directory
mpdl get-config music_directory

# Enable audio normalization
mpdl set-config volume_normalization yes

# Set audio output
mpdl set-config audio_output_format "44100:16:2"

GNTP/Growl Notifications

mpdl supports desktop notifications via GNTP (Growl Notification Transport Protocol). To use this feature:

  1. Install a GNTP-compatible notification system:

  2. Enable GNTP in your config file:

[gntp]
host = "localhost"
port = 23053
enabled = true
icon_mode = "binary"  # Recommended for Windows
  1. Start monitor mode:
mpdl monitor

Notifications will show:

  • Album artwork (if available)
  • Song title, artist, and album
  • Playback time and bitrate
  • Player state changes

Platform-Specific Notes

Windows

  • Default music root: C:\Musics
  • Default MPD config: %APPDATA%\mpd\mpd.conf
  • Use binary icon mode for GNTP notifications

Linux

  • Default music root: ~/Music
  • Default MPD config: ~/.config/mpd/mpd.conf
  • May require libmpd package

macOS

  • Default music root: ~/Music
  • Default MPD config: ~/.config/mpd/mpd.conf
  • Growl notifications supported

Troubleshooting

Connection Issues

# Enable debug mode
mpdl --debug status

# Check MPD is running
systemctl status mpd  # Linux
# or
net start mpd  # Windows

# Test connection manually
telnet localhost 6600

Permission Issues (Config Editing)

The get-config and set-config commands only work with local MPD installations where you have read/write access to the MPD configuration file.

GNTP Notifications Not Working

  1. Verify GNTP server is running
  2. Check firewall settings
  3. Try different icon modes:
    mpdl --config config.toml monitor
    # Edit config.toml and change icon_mode

Development

Building from Source

git clone https://github.com/cumulus13/mpdl.git
cd mpdl
go mod download
go build -o mpdl

Running Tests

go test ./...

Building for Multiple Platforms

# Linux
GOOS=linux GOARCH=amd64 go build -o mpdl-linux-amd64

# Windows
GOOS=windows GOARCH=amd64 go build -o mpdl-windows-amd64.exe

# macOS
GOOS=darwin GOARCH=amd64 go build -o mpdl-darwin-amd64
GOOS=darwin GOARCH=arm64 go build -o mpdl-darwin-arm64

Dependencies

  • gompd - MPD client library
  • go-gntp - GNTP notification library
  • toml - TOML parser
  • term - Terminal utilities

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘€ Author

Hadi Cahyadi

Buy Me a Coffee

Donate via Ko-fi

Support me on Patreon

Acknowledgments

  • MPD developers for the excellent music player daemon
  • gompd library maintainers
  • All contributors to this project

Related Projects

  • MPD - Music Player Daemon
  • MPC - Official MPD command-line client
  • ncmpcpp - NCurses MPD client

Changelog

See CHANGELOG.md for release history.

Support

About

Command-line client for [Music Player Daemon (MPD)](https://www.musicpd.org/) with monitoring capabilities, GNTP/Growl notifications, and MPC-like functionality.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published