summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config.def.h8
-rw-r--r--mpd-notification.c17
2 files changed, 10 insertions, 15 deletions
diff --git a/config.def.h b/config.def.h
index 000c74d..85ed744 100644
--- a/config.def.h
+++ b/config.def.h
@@ -17,10 +17,10 @@
/* strings used to display notification messages
* TEXT_PLAY_* need to include one string modifier '%s' each. */
#define TEXT_TOPIC "MPD Notification"
-#define TEXT_PLAY_TITLE "Playing <b>%s</b>"
-#define TEXT_PLAY_ARTIST "by <i>%s</i>"
-#define TEXT_PLAY_ALBUM "from <i>%s</i>"
-#define TEXT_PAUSE "Paused playback"
+#define TEXT_PLAY_PAUSE_STATE "%s "
+#define TEXT_PLAY_PAUSE_TITLE "<b>%s</b>"
+#define TEXT_PLAY_PAUSE_ARTIST "by <i>%s</i>"
+#define TEXT_PLAY_PAUSE_ALBUM "from <i>%s</i>"
#define TEXT_STOP "Stopped playback"
#define TEXT_NONE "No action received yet."
#define TEXT_UNKNOWN "(unknown)"
diff --git a/mpd-notification.c b/mpd-notification.c
index 46d471b..134907e 100644
--- a/mpd-notification.c
+++ b/mpd-notification.c
@@ -398,7 +398,7 @@ int main(int argc, char ** argv) {
mpd_command_list_end(conn);
state = mpd_status_get_state(mpd_recv_status(conn));
- if (state == MPD_STATE_PLAY) {
+ if (state == MPD_STATE_PLAY || state == MPD_STATE_PAUSE) {
/* There's a bug in libnotify where the server spec version is fetched
* too late, which results in issue with image date. Make sure to
* show a notification without image data (just generic icon) first. */
@@ -418,19 +418,19 @@ int main(int argc, char ** argv) {
goto nonotification;
#ifdef HAVE_SYSTEMD
- sd_notifyf(0, "READY=1\nSTATUS=Playing: %s", title);
+ sd_notifyf(0, "READY=1\nSTATUS=%s: %s", state == MPD_STATE_PLAY ? "Playing" : "Paused", title);
#endif
/* initial allocation and string termination */
notifystr = strdup("");
-
- notifystr = append_string(notifystr, TEXT_PLAY_TITLE, 0, title);
+ notifystr = append_string(notifystr, TEXT_PLAY_PAUSE_STATE, 0, state == MPD_STATE_PLAY ? "Playing": "Paused");
+ notifystr = append_string(notifystr, TEXT_PLAY_PAUSE_TITLE, 0, title);
if ((artist = mpd_song_get_tag(song, MPD_TAG_ARTIST, 0)) != NULL)
- notifystr = append_string(notifystr, TEXT_PLAY_ARTIST, oneline ? ' ' : '\n', artist);
+ notifystr = append_string(notifystr, TEXT_PLAY_PAUSE_ARTIST, oneline ? ' ' : '\n', artist);
if ((album = mpd_song_get_tag(song, MPD_TAG_ALBUM, 0)) != NULL)
- notifystr = append_string(notifystr, TEXT_PLAY_ALBUM, oneline ? ' ' : '\n', album);
+ notifystr = append_string(notifystr, TEXT_PLAY_PAUSE_ALBUM, oneline ? ' ' : '\n', album);
uri = mpd_song_get_uri(song);
@@ -458,11 +458,6 @@ int main(int argc, char ** argv) {
}
mpd_song_free(song);
- } else if (state == MPD_STATE_PAUSE) {
- notifystr = strdup(TEXT_PAUSE);
-#ifdef HAVE_SYSTEMD
- sd_notify(0, "READY=1\nSTATUS=" TEXT_PAUSE);
-#endif
} else if (state == MPD_STATE_STOP) {
notifystr = strdup(TEXT_STOP);
#ifdef HAVE_SYSTEMD