From d8a3d7d5f6296ce7d8126da5eb39c57c548e68a8 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Tue, 21 Jun 2016 05:10:18 +0200 Subject: [PATCH] feat(mpd): Format tags for back-/forward seek --- README.md | 6 +++++- include/modules/mpd.hpp | 2 ++ src/modules/mpd.cpp | 11 ++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2281d2d0..3b7f188e 100644 --- a/README.md +++ b/README.md @@ -685,7 +685,9 @@ See [the bspwm module](#user-content-dependencies) for details on `label-dimmed` ; ; ; - format-online = + ; + ; + format-online = ; Available tags: ; @@ -713,6 +715,8 @@ See [the bspwm module](#user-content-dependencies) for details on `label-dimmed` icon-stop = ⏹ icon-prev = ⏮ icon-next = ⏭ + icon-seekb = ⏪ + icon-seekf = ⏩ icon-random = 🔀 icon-repeat = 🔁 ;icon-repeatone = 🔂 diff --git a/include/modules/mpd.hpp b/include/modules/mpd.hpp index f3f99540..bc3ce644 100644 --- a/include/modules/mpd.hpp +++ b/include/modules/mpd.hpp @@ -30,6 +30,8 @@ namespace modules static constexpr auto TAG_ICON_PLAY = ""; static constexpr auto TAG_ICON_PAUSE = ""; static constexpr auto TAG_ICON_NEXT = ""; + static constexpr auto TAG_ICON_SEEKB = ""; + static constexpr auto TAG_ICON_SEEKF = ""; static constexpr auto FORMAT_OFFLINE = "format-offline"; static constexpr auto TAG_LABEL_OFFLINE = ""; diff --git a/src/modules/mpd.cpp b/src/modules/mpd.cpp index edda7fad..50721aef 100644 --- a/src/modules/mpd.cpp +++ b/src/modules/mpd.cpp @@ -23,7 +23,8 @@ MpdModule::MpdModule(std::string name_) this->formatter->add(FORMAT_ONLINE, TAG_LABEL_SONG, { TAG_BAR_PROGRESS, TAG_TOGGLE, TAG_LABEL_SONG, TAG_LABEL_TIME, TAG_ICON_RANDOM, TAG_ICON_REPEAT, TAG_ICON_REPEAT_ONE, TAG_ICON_PREV, - TAG_ICON_STOP, TAG_ICON_PLAY, TAG_ICON_PAUSE, TAG_ICON_NEXT }); + TAG_ICON_STOP, TAG_ICON_PLAY, TAG_ICON_PAUSE, TAG_ICON_NEXT, + TAG_ICON_SEEKB, TAG_ICON_SEEKF }); this->formatter->add(FORMAT_OFFLINE, "", { TAG_LABEL_OFFLINE }); if (this->formatter->has(TAG_ICON_PLAY) || this->formatter->has(TAG_TOGGLE)) @@ -36,6 +37,10 @@ MpdModule::MpdModule(std::string name_) this->icons->add("prev", drawtypes::get_config_icon(name(), get_tag_name(TAG_ICON_PREV))); if (this->formatter->has(TAG_ICON_NEXT)) this->icons->add("next", drawtypes::get_config_icon(name(), get_tag_name(TAG_ICON_NEXT))); + if (this->formatter->has(TAG_ICON_SEEKB)) + this->icons->add("seekb", drawtypes::get_config_icon(name(), get_tag_name(TAG_ICON_SEEKB))); + if (this->formatter->has(TAG_ICON_SEEKF)) + this->icons->add("seekf", drawtypes::get_config_icon(name(), get_tag_name(TAG_ICON_SEEKF))); if (this->formatter->has(TAG_ICON_RANDOM)) this->icons->add("random", drawtypes::get_config_icon(name(), get_tag_name(TAG_ICON_RANDOM))); if (this->formatter->has(TAG_ICON_REPEAT)) @@ -258,6 +263,10 @@ bool MpdModule::build(Builder *builder, std::string tag) icon_cmd(builder, EVENT_PLAY, this->icons->get("play")); else if (tag == TAG_ICON_NEXT) icon_cmd(builder, EVENT_NEXT, this->icons->get("next")); + else if (tag == TAG_ICON_SEEKB) + icon_cmd(builder, std::string(EVENT_SEEK).append("-5"), this->icons->get("seekb")); + else if (tag == TAG_ICON_SEEKF) + icon_cmd(builder, std::string(EVENT_SEEK).append("+5"), this->icons->get("seekf")); else return false;