module/mpd: add volume tag

This commit is contained in:
optimus-prime 2020-12-02 13:13:15 +05:30
parent 9718c6f31e
commit 96d2d057e0
3 changed files with 8 additions and 0 deletions

View file

@ -14,6 +14,8 @@
(https://codeberg.org/dnkl/yambar/issues/9).
* script: new module, adds support for custom user scripts
(https://codeberg.org/dnkl/yambar/issues/11).
* mpd: `volume` tag. This is a range tag that represents MPD's current volume
in percentage (0-100)
### Deprecated

View file

@ -452,6 +452,9 @@ artist/album/song.
| consume
: bool
: True if the *consume* flag is set
| volume
: range
: Volume of MPD in percentage
| album
: string
: Currently playing album (also valid in *paused* state)

View file

@ -38,6 +38,7 @@ struct private {
bool repeat;
bool random;
bool consume;
int volume;
char *album;
char *artist;
char *title;
@ -162,6 +163,7 @@ content(struct module *mod)
tag_new_bool(mod, "repeat", m->repeat),
tag_new_bool(mod, "random", m->random),
tag_new_bool(mod, "consume", m->consume),
tag_new_int_range(mod, "volume", m->volume, 0, 100),
tag_new_string(mod, "album", m->album),
tag_new_string(mod, "artist", m->artist),
tag_new_string(mod, "title", m->title),
@ -320,6 +322,7 @@ update_status(struct module *mod)
m->repeat = mpd_status_get_repeat(status);
m->random = mpd_status_get_random(status);
m->consume = mpd_status_get_consume(status);
m->volume = mpd_status_get_volume(status);
m->duration = mpd_status_get_total_time(status) * 1000;
m->elapsed.value = mpd_status_get_elapsed_ms(status);
m->elapsed.when = now;