Skip to main content

A package for displaying Cmus current status in notifications

Project description

https://travis-ci.org/AntoineGagne/cmus-notify.svg?branch=master https://img.shields.io/pypi/v/cmus-notify.svg
Author:

Antoine Gagné

1 Requirements

To install this program, you must have the following:

  • python 3.5+

  • The Python library notify2

  • notify-send

2 Installation

To install this program, you can simply run the following command:

python setup.py install

This program can also be found on Pypi which means you can install it by downloading the wheel or by using the following command:

pip install cmus-notify

You can check if it installed correctly by doing the following command:

cmus_notify -h

It should display a message.

3 Hooking To Cmus

To hook this program to cmus, you have to create a shell script that have the following lines in it:

#! /bin/sh

cmus_notify "$*" &

Then, you must make the file executable by using the following command (assuming your script’s name is cmus_notify.sh):

chmod +x cmus_notify.sh

Finally, once you are in cmus, you can add the hook by using the following command:

:set status_display_program=<path-to-the-shell-script>

4 Customization

If you want you can specify the formatting of the notification by specifying format strings. For example:

#! /bin/sh

cmus_notify --title "Now playing: {title} by {artist}" --body "$(printf "<b>Album:</b> {album}\n<b>Duration:</b> {duration}")" "$*"

You can also specify a configuration to read these values from. By default, the program will search for a configuration file named ~/.cmus-notify. It has the following format:

[notifications]
    application_name = Cmus
    custom_notification = /home/user/.cmus/custom_notification.py

[format]
    title = Now playing: {title} by {artist}
    body = <b>Album:</b> {album}
           <b>Duration:</b> {duration}

The options accepts the same values as their command-line options equivalent.

5 Options

To view the full options, you can run the following command:

cmus_notify --help

which will display the following prompt:

usage: cmus_notify [-h] [-a APPLICATION_NAME] [-b BODY_FORMAT_STRING]
                   [-t TITLE_FORMAT_STRING] [-f CONFIGURATION_FILE]
                   [-c CUSTOM_NOTIFICATION]
                   INFORMATION

Display a notification about Cmus's current status

positional arguments:
  INFORMATION           Parse the given information

optional arguments:
  -h, --help            show this help message and exit
  -a APPLICATION_NAME, --application_name APPLICATION_NAME
                        The name of the application
  -b BODY_FORMAT_STRING, --body BODY_FORMAT_STRING
                        A format string that can be specified to tell the
                        software how to format the body. The syntax is the
                        same as Python's. The available options are specified
                        at the end of this help message. (i.e. 'Artist:
                        {artist}')
  -t TITLE_FORMAT_STRING, --title TITLE_FORMAT_STRING
                        A format string that can be specified to tell the
                        software how to format the title. The syntax is the
                        same as Python's. The available options are specified
                        at the end of this help message. (i.e. 'Now playing:
                        {title}')
  -f CONFIGURATION_FILE, --configuration_file CONFIGURATION_FILE
                        The path to the configuration file. If it is not
                        specified, the program will use the default values of
                        the other options.
  -c CUSTOM_NOTIFICATION, --custom_notification CUSTOM_NOTIFICATION
                        The path to a custom implementation of the
                        notification class. If it is not specified, the
                        standard implementation will be used (the one using
                        notify2).

Format String Parameters
========================

The available arguments to the format strings are the following:

  - album: The song's album
  - albumartist: The song's album's artist
  - artist: The song's artist
  - date: The song's release date
  - discnumber: The song's disc's number
  - duration: The song's duration
  - file: The song's file's path
  - status: Cmus current status
  - title: The song's title
  - tracknumber: The song's track number

6 Documentation

The project’s documentation can be found here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmus-notify-1.4.1.tar.gz (7.9 kB view details)

Uploaded Source

File details

Details for the file cmus-notify-1.4.1.tar.gz.

File metadata

  • Download URL: cmus-notify-1.4.1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9

File hashes

Hashes for cmus-notify-1.4.1.tar.gz
Algorithm Hash digest
SHA256 8ac845a6596c259286802fd983c34ab3cee9345b5892cf936448e43fc7bd8380
MD5 9c42f44b9113dc9ac43c549d23098d04
BLAKE2b-256 def0b8783781a59dfe85ea71ff069dbd8fa68533c9fc2f585d03ff39ca4eb044

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page