feat(mpd): Add support for icon-consume ()

This commit is contained in:
Jens Henniges 2017-12-04 20:38:17 +01:00 committed by NBonaparte
parent 17f1f19012
commit d3abcc97f6
4 changed files with 32 additions and 2 deletions
src/modules

View file

@ -25,7 +25,7 @@ namespace modules {
m_formatter->add(format, format_online,
{TAG_BAR_PROGRESS, TAG_TOGGLE, TAG_TOGGLE_STOP, 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_SEEKB, TAG_ICON_SEEKF});
TAG_ICON_NEXT, TAG_ICON_SEEKB, TAG_ICON_SEEKF, TAG_ICON_CONSUME});
auto mod_format = m_formatter->get(format);
mod_format->fg = m_conf.get(name(), FORMAT_ONLINE + "-foreground"s, mod_format->fg);
mod_format->bg = m_conf.get(name(), FORMAT_ONLINE + "-background"s, mod_format->bg);
@ -74,6 +74,9 @@ namespace modules {
if (m_formatter->has(TAG_ICON_REPEAT_ONE)) {
m_icons->add("repeat_one", load_icon(m_conf, name(), TAG_ICON_REPEAT_ONE));
}
if (m_formatter->has(TAG_ICON_CONSUME)) {
m_icons->add("consume", load_icon(m_conf, name(), TAG_ICON_CONSUME));
}
if (m_formatter->has(TAG_LABEL_SONG)) {
m_label_song = load_optional_label(m_conf, name(), TAG_LABEL_SONG, "%artist% - %title%");
@ -82,7 +85,7 @@ namespace modules {
m_label_time = load_optional_label(m_conf, name(), TAG_LABEL_TIME, "%elapsed% / %total%");
}
if (m_formatter->has(TAG_ICON_RANDOM) || m_formatter->has(TAG_ICON_REPEAT) ||
m_formatter->has(TAG_ICON_REPEAT_ONE)) {
m_formatter->has(TAG_ICON_REPEAT_ONE) || m_formatter->has(TAG_ICON_CONSUME)) {
m_toggle_on_color = m_conf.get(name(), "toggle-on-foreground", ""s);
m_toggle_off_color = m_conf.get(name(), "toggle-off-foreground", ""s);
}
@ -252,6 +255,9 @@ namespace modules {
m_icons->get("repeat_one")->m_foreground =
m_status && m_status->single() ? m_toggle_on_color : m_toggle_off_color;
}
if (m_icons->has("consume")) {
m_icons->get("consume")->m_foreground = m_status && m_status->consume() ? m_toggle_on_color : m_toggle_off_color;
}
return true;
}
@ -296,6 +302,8 @@ namespace modules {
builder->cmd(mousebtn::LEFT, EVENT_REPEAT, m_icons->get("repeat"));
} else if (tag == TAG_ICON_REPEAT_ONE) {
builder->cmd(mousebtn::LEFT, EVENT_REPEAT_ONE, m_icons->get("repeat_one"));
} else if (tag == TAG_ICON_CONSUME) {
builder->cmd(mousebtn::LEFT, EVENT_CONSUME, m_icons->get("consume"));
} else if (tag == TAG_ICON_PREV) {
builder->cmd(mousebtn::LEFT, EVENT_PREV, m_icons->get("prev"));
} else if ((tag == TAG_ICON_STOP || tag == TAG_TOGGLE_STOP) && (is_playing || is_paused)) {
@ -348,6 +356,8 @@ namespace modules {
mpd->set_repeat(!status->repeat());
} else if (cmd == EVENT_RANDOM) {
mpd->set_random(!status->random());
} else if (cmd == EVENT_CONSUME) {
mpd->set_consume(!status->consume());
} else if (cmd.compare(0, strlen(EVENT_SEEK), EVENT_SEEK) == 0) {
auto s = cmd.substr(strlen(EVENT_SEEK));
int percentage = 0;