From 75c6e2e7d53b5d2a7efbae38b6cf1225d446aee4 Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Tue, 15 Oct 2019 09:24:04 -0700 Subject: [PATCH] mpd: add paused format string --- include/modules/mpd.hpp | 1 + man/waybar-mpd.5.scd | 6 +++++- src/modules/mpd.cpp | 6 +++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/modules/mpd.hpp b/include/modules/mpd.hpp index d69618a9..d08b28b2 100644 --- a/include/modules/mpd.hpp +++ b/include/modules/mpd.hpp @@ -36,6 +36,7 @@ class MPD : public ALabel { bool stopped(); bool playing(); + bool paused(); const std::string module_name_; diff --git a/man/waybar-mpd.5.scd b/man/waybar-mpd.5.scd index 598cbc63..fc3b1b36 100644 --- a/man/waybar-mpd.5.scd +++ b/man/waybar-mpd.5.scd @@ -38,13 +38,17 @@ Addressed by *mpd* *format*: ++ typeof: string ++ default: "{album} - {artist} - {title}" ++ - Information displayed when a song is playing or paused + Information displayed when a song is playing. *format-stopped*: ++ typeof: string ++ default: "stopped" ++ Information displayed when the player is stopped. +*format-paused*: ++ + typeof: string ++ + This format is used when a song is paused. + *format-disconnected*: ++ typeof: string ++ default: "disconnected" ++ diff --git a/src/modules/mpd.cpp b/src/modules/mpd.cpp index 7bad855b..13ab9f0d 100644 --- a/src/modules/mpd.cpp +++ b/src/modules/mpd.cpp @@ -140,7 +140,9 @@ void waybar::modules::MPD::setLabel() { if (playing()) { label_.get_style_context()->add_class("playing"); label_.get_style_context()->remove_class("paused"); - } else { + } else if (paused()) { + format = + config_["format-paused"].isString() ? config_["format-paused"].asString() : config_["format"].asString(); label_.get_style_context()->add_class("paused"); label_.get_style_context()->remove_class("playing"); } @@ -346,3 +348,5 @@ bool waybar::modules::MPD::stopped() { } bool waybar::modules::MPD::playing() { return connection_ != nullptr && state_ == MPD_STATE_PLAY; } + +bool waybar::modules::MPD::paused() { return connection_ != nullptr && state_ == MPD_STATE_PAUSE; }