Giter Club home page Giter Club logo

mpd-notification's Introduction

mpd-notification

Notify about tracks played by mpd

This runs in background and produces notifications whenever mpd produces an event, that is new track is played or playback is paused or stopped. Notifications look like this:

Notification

This now even supports album artwork:

Notification with Artwork

Read below for the details.

Requirements

To compile and run mpd-notification you need:

To use mpd-notification you probably want mpd, the music player daemon itself. ;)

Some systems may require additional development packages for the libraries. Look for libnotify-devel, libmpdclient-devel or similar.

Build and install

Building and installing is very easy. Just run:

make

followed by:

make install

This will place an executable at /usr/bin/mpd-notification, documentation can be found in /usr/share/doc/mpd-notification/. Additionally a systemd unit file is installed to /usr/lib/systemd/user/.

Usage

Just run mpd-notification to run it once. A systemd user service can be started and/or enabled with systemctl --user start mpd-notification or systemctl --user enable mpd-notification.

mpd-notification accepts some arguments:

  • -h: show help
  • -H HOST: connect to HOST
  • -m MUSIC-DIR: use MUSIC-DIR for artwork lookup
  • --notification-file-workaround: write artwork to file for notification daemons that do required it
  • -p PORT: connect to PORT
  • -s PIXELS: scale image to a maximum size PIXELS x PIXELS pixels, keeping ratio
  • -t TIMEOUT: notification timeout, TIMEOUT in seconds
  • -v: verbose output
  • -V: print version information

Configuration

Configuration options can be read from a configuration file. mpd tries to read ${XDG_CONFIG_HOME}/mpd-notification.conf, then ~/.config/mpd-notification.conf, which is expected to look like this:

host = localhost
port = 6600
music-dir = /srv/media/music/
scale = 200
text-topic = MPD Notification
text-play = Playing <b>%t</b>\nby <i>%a</i>\nfrom <i>%A</i>
text-pause = Paused <b>%t</b>\nby <i>%a</i>\nfrom <i>%A</i>
text-stop = Stopped playback
timeout = 20

Unused options can be commented or removed completely.

The options text-play and text-pause support custom formatting with these specifiers:

  • %t: title
  • %a: artist
  • %A: album
  • %d: duration

Artwork

mpd does not provide any information where it finds its music files. To make mpd-notification display album artwork you need to tell it where to look for artwork. You can do that by exporting XDG_MUSIC_DIR to your environment, by specifying -m or --music-dir on the command line or by setting music-dir in configuration file. mpd-notification reads album artwork from mp3 files, otherwise an image file containing the artwork needs to be placed in the same directory as the media file and named cover.jpg, cover.png, folder.jpg or folder.png.

License and warranty

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Upstream

URL: GitHub.com

Mirror: eworm.de GitLab.com

mpd-notification's People

Contributors

eworm-de avatar fwsmit avatar maxice8 avatar rpthms avatar sammko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mpd-notification's Issues

Show mode change notifications

Is there a way to show mode change notifications? I'm using NCMPCPP and would like a notification of when I change shuffle and repeate modes. Is this something mpd-notification can show?

Read MPD environment variables

Namely, MPD_HOST and MPD_PORT are used by other mpd clients, and contain connection data. Beware that MPD_PORT might be set to -1 to signify that MPD_HOST is a path to a unix socket.

GLib critical message on g_markup_escape_text: assertion

Dunno if this a real problem, but if Critical is displayed I want to be sure. Though, I didn't notice a problem. Just a message on stdout.

Listening to a radio stream and the following error is produced:

(process:32163): GLib-CRITICAL **: g_markup_escape_text: assertion 'text != NULL' failed

and the notify looks like that
1436403240

starting playback

5.3.13-arch1-1 #1 SMP PREEMPT Sun, 24 Nov 2019 10:15:50 +0000 x86_64 GNU/Linux
Music Player Daemon 0.21.16 (0.21.16)

systemctl --user status mpd-notification
● mpd-notification.service - MPD Notification
   Loaded: loaded (/usr/lib/systemd/user/mpd-notification.service; enabled; ven>
   Active: active (running) since Fri 2019-11-29 19:20:28 +03; 1s ago
 Main PID: 22054 (mpd-notificatio)
   Status: "Waiting for mpd event..."
   CGroup: /user.slice/user-1000.slice/[email protected]/mpd-notification.servi>
           └─22054 /usr/bin/mpd-notification

mpd

albumart doesnt show

My music is in /home/music, and not in /home/$USER/music

I configured XDG_MUSIC_DIR in ~/.config/user-dirs.dirs

XDG_MUSIC_DIR="/home/music"

Also configure systemd user service just to be sure

ExecStart=/usr/bin/mpd-notification -t 5 -m /home/music

I tried to rename my albumart.jpg and png to folder.jpg or folder.png.
It shows a little lamp where the cover needs to be print. (which not appear without setting music folder).

I can't start mpd-notification alone, it freeze.
It only work with systemd service. So i edited it to add -v option
It print me some errors ->

sept. 19 22:56:31 osz mpd-notification[14318]: /usr/bin/mpd-notification: Error "GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name :1.66 was not provided by  .service files" while trying to show notification. Trying to reconnect.
sept. 19 23:03:51 osz mpd-notification[14318]: /usr/bin/mpd-notification: Error "GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name :1.99 was not provided by  .service files" while trying to show notification. Trying to reconnect.

sept. 19 23:05:20 osz mpd-notification[14318]: (process:14318): GLib-GObject-WARNING **: gsignal.c:2635: instance '0x5597ee645900' has no handler with id '7'

scale configuration has no impact

In mpd-notification.conf, I configured both music-dir and scale. I can see album pictures in notifications now, but they are very small. I tried to increase the scale to 600 (the size of the image in the music file metadata) but this has no impact (I restarted the systemd service in between).

change default cover name

Hi,
I renamed every cover files as folder.(jpg|png). It works well.
But the problem is that i use O!MPD mpd client, which print big covers, so i need them to be in a good resolution. O!MPD search for files named as folder.png, as mpd-notification.
The problem is that my notification daemon (dunst) prints cover as it finds it, if the cover is 800x800, it prints me a ~ 800x850 notification.
I want to generate cover_thumbs.(jpg|png), 200x200 with imagemagick and then tell to mpd-notification to looks at these files.

Have a nice day.

Problem with make and iniparser

I tried to install mpd-notification with the following error:

$ make
gcc -std=c11 -O2 -fPIC -Wall -Werror -liniparser -lmpdclient -pthread -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -lnotify -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -Wl,-z,now -Wl,-z,relro -pie -o mpd-notification mpd-notification.c
In file included from mpd-notification.c:8:0:
mpd-notification.h:26:10: fatal error: iniparser.h: Aucun fichier ou dossier de ce type
 #include <iniparser.h>
          ^~~~~~~~~~~~~
compilation terminated.
Makefile:33 : la recette pour la cible « mpd-notification » a échouée
make: *** [mpd-notification] Erreur 1

I tried to install iniparser (from https://github.com/ndevilla/iniparser). I did a "make" in iniparser folder and copied libiniparser.a to /usr/bin. With no effect.

How can I fix this issue?

system : debian sid

Can this work on a tty with gnome open (or not) on another tty?

A bit of context: I'm interested in controlling mpd with media keys on a tty, and tried out mpris2 https://github.com/eonpatapon/mpDris2

There i was informed that what i wanted isn't possible for them, since they depend on the gnome-settings-daemon daemon being running to get the keys.

I was also further reminded that there is a rule somewhere about 'only one notification daemon can be registered on dbus at a time', which definitely sinks any further attempts when both gnome and ncmpcpp are running on different ttys but the same user i believe. I'm uncertain if systemd units can coordinate a eventual 'TTY media keys daemon' so it's not running at the same time as gnome, or if there is a much better way listening to edev directly.

This issue is just a query 'is this going to stay impossible on the foreseeable future'?

Eh. A modern shell tty running alacritty and 3d acceleration and a notification daemon would be quite interesting. I hope to see something like that eventually.

Awesome

I just started using mpd-notification. I like it very much. Thank you

Change notification's text?

Hey! First of all, thanks for this great piece of software :)

Is there someway to tweak the text of the notification?
I ask this because the most prominent element of the notification is "MPD Notification", and the actual useful (for me) informations, like track and artist are smaller and less evident. It'd be great to be able to hide "MPD Notification", or at least make it smaller, giving more space to the rest and making it a bit cleaner.

Error with iniparser libraries

~/mpd/mpd-notification/ make
echo "#ifndef VERSION" > version.h
echo "#define VERSION "0.8.0-0-g9a13c62"" >> version.h
echo "#endif" >> version.h
gcc -std=c11 -O2 -fPIC -Wall -Werror -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -lmpdclient -pthread -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -lnotify -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -Wl,-z,now -Wl,-z,relro -pie -L. -liniparser -o mpd-notification mpd-notification.c
/tmp/ccsWabl1.o : Dans la fonction « main » :
mpd-notification.c:(.text.startup+0x2ae) : référence indéfinie vers « iniparser_freedict »
mpd-notification.c:(.text.startup+0x6c2) : référence indéfinie vers « iniparser_load »
mpd-notification.c:(.text.startup+0x6e4) : référence indéfinie vers « iniparser_getboolean »
mpd-notification.c:(.text.startup+0x6fc) : référence indéfinie vers « iniparser_getstring »
mpd-notification.c:(.text.startup+0x714) : référence indéfinie vers « iniparser_getint »
mpd-notification.c:(.text.startup+0x72c) : référence indéfinie vers « iniparser_getstring »
mpd-notification.c:(.text.startup+0x745) : référence indéfinie vers « iniparser_getint »
mpd-notification.c:(.text.startup+0x764) : référence indéfinie vers « iniparser_getboolean »
mpd-notification.c:(.text.startup+0x779) : référence indéfinie vers « iniparser_getint »
collect2: error: ld returned 1 exit status
Makefile:33 : la recette pour la cible « mpd-notification » a échouée
make: *** [mpd-notification] Erreur 1

I compile them with make but no make install where could I copy libiniparser.so.1 libiniparser.a ?

Feature: Limit size of album art

Some of my album art files are quiet big (nice in some other programs). But that way the notifications get very big as well (at least in awesome WM, have not tried gnome or others).

Is it possible to scale the images before using them in the notification?

Maybe a new command line option can be added for this, in order not to change the current default behavior. The command line option could take an argument to give the maximum number of pixles (any bigger images will then be scaled down on the fly).

Can't get cover art

I have MPD running on another server, with the audio directory mounted to my local machine via NFS. Notifications are working fine but it can't seem to get cover art. I have "music-dir" set to the NFS-mounted audio file in my config. Not sure how to get it to tell me where it's looking or how it's failing.

Fail to start after mpd on boot

Hi, I'm using Archlinux and have installed mpd and mpd-notification-git.
Then I want them both to run automatically on boot.

systemctl --user enable mpd
systemctl --user enable mpd-notification

But these command doesn't work. Here is the log of mpd-notification:

20:37:48 systemd[424]: Started MPD Notification.
20:37:48 mpd-notification[433]: /usr/bin/mpd-notification: Connection refused
20:37:48 systemd[424]: mpd-notification.service: Main process exited, code=exited, status=1/FAILURE
20:37:48 systemd[424]: mpd-notification.service: Unit entered failed state.
20:37:48 systemd[424]: mpd-notification.service: Failed with result 'exit-code'.

And the log of mpd:

20:37:48 systemd[424]: Started Music Player Daemon.
20:37:49 mpd[432]: May 12 20:37 : server_socket: bind to '0.0.0.0:6600' failed: Address already in use (continuing anyway, because binding to '[::]:6600' succeeded)

Then referring to Archlinux Wiki, I add both Requires=mpd.service and After=mpd.service to the [Unit] section of mpd-notification.service. But mpd-notification still start before mpd opening its port.
Maybe we need a script to delay a few seconds.

Notification history problem in KDE

Due to a change in KDE, it seems that the notification sent by mpd-notification can't be preserved in the notification history.

Is that possible to deal with this problem? I find a related workaround here.

Can't change image size.

I have 600x600 px cover images, but it only seems to display them at 200x200 px. I've tried setting the scale in the config and via the -s flag, but the size remains the same.

TIMEOUT only works from command line

I tried setting the TIMEOUT to various values in my config, but it doesn't change. Setting it via -t works, however. I know it's reading my config because it's connecting to the correct server, etc.

Crash when no notification server is up twice (should autostart)

I have configured my notification daemon to autostart upon sending a notification, but this seems to not always work with mpd-notificatition (note that it always works with notify-send).

To reproduce:

  1. start mpd-notification
  2. kill the notification daemon
  3. toggle music playback
  4. kill the notification deamon again
  5. toggle music playback again

mpd-notification will then crash with the message:

mpd-notification: Error showing notification: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name :1.398 was not provided by any .service files

I reproduced it using mpd-notification v0.8.6 and the latest master.

Consider adding a --version command line option.

I just wanted to see which version I have installed (and not start a new instance). But --help only shows the version if I also put -v on the cammand line. I consider this not obvious (and only found out about it after reading the source).

The problem is that the normal greeting might have to be moved to another location in main() for this to be pratical (otherwise --version --verbose might print the same info twice which is not really verbose but redundant).

Config File

I want to change the message format to better fit my desktop theme. Where is the config file located?

Quits after radio stream changes in active Queue

I noticed the following behaviour:
I have one set a Queue just with radio streams. And if I switch between the streams mpd-notification quits every time.
With local files everything is normal aka it will be running until I clear the Queue.
Can this behaviour be changed or is it due to the streams?

Setup:
*mpd (not started on boot; manually via systemctl --user)
*mpd-notification (manually from a shell after mpd is running. I did try the systemd user service, but it wasn't working the way I hoped)

implicit declaration of function av_register_all on make

I am trying to update the app from 0.8.6-1 -> 0.8.6-2 but I get the following error on build (tried both paru and make on arch linux):

gcc mpd-notification.c  -std=c11 -O2 -fPIC -Wall -Werror -liniparser -DHAVE_SYSTEMD -lsystemd  -lmpdclient  -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -pthread -lnotify -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0  -DHAVE_LIBAV -lavformat -lavutil  -lmagic -Wl,-z,now -Wl,-z,relro -pie -o mpd-notification
mpd-notification.c: In function ‘main’:
mpd-notification.c:357:9: error: implicit declaration of function ‘av_register_all’ [-Werror=implicit-function-declaration]
  357 |         av_register_all();
      |         ^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:36: mpd-notification] Error 1

After a quick search I have noticed that av_register_all is deprecated in ffmpeg 4+

Is this something that needs to be updated in this repo to resolve this or did I misunderstand the build failure?

Integrate album art into notifications

Thank you for sharing; love this script ever since I discovered it. =)

I'd like to suggest a small addition though. magpie240's mpdcover script scans the current song's directory for album art and copies them to tmp (for easy output to conky, or something else).

Perhaps this could be incorporated into mpd-notification so it displays albumart (in place of the default eighth-note) if available?

Incorrect artwork shown when pausing

When pausing mpd, mpd-notification shows the album art of a previously-played album rather than the current one. As far as I can tell, it shows the first album played in this instance of mpd-notification. On play or resume, the current album's artwork is shown.

Running on Arch Linux using the latest git checkout.

Cover art not working

music-dir has been set correctly and mpd-notification can correctly find my music files:

~ $ mpd-notification -v                                        
mpd-notification: mpd-notification v0.8.7 +systemd +libav (compiled: May 19 2024, 18:36:54)
mpd-notification: MIME type for /home/faaris/Music//Sullivan King/Someone Else/01 Someone Else.m4a is: audio/x-m4a
mpd-notification: Playing <b>Someone Else</b> by <i>Sullivan King</i> from <i>Someone Else</i>

Is this due to my music being in the m4a format? I am using dunst, and I have also attempted to use the notification-file to no avail, it just shows a generic music file icon.

Please specify license clearer

I would like to package this software for personal use downstream in Gentoo, but the current licensing terms are unclear. The mpd-notification.c file says:

/*
 * (C) 2011-2018 by Christian Hesse <[email protected]>
 *
 * This software may be used and distributed according to the terms
 * of the GNU General Public License, incorporated herein by reference.
 */

without specifying exactly which version of the GPL that is mentioned. Is it GPL-2.0 only, or GPL-2.0 or any later version, or GPL-3.0?

Furthermore, according to [1] (under "The licenses notices") the source file should have a license notice which should not be on the above form but instead something like:

/*
 * Copyright (C) 2011-2018 Christian Hesse <[email protected]>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

Also, again according to [1] (under "The license files"), there should be a COPYING (or LICENSE) file with the (full) text version of the GPL.

Thanks in advance.

[1] https://www.gnu.org/licenses/gpl-howto.en.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.