Skip to content

Allow separation of MPD's %elapsed% and %total% #1968

@jallbrit

Description

@jallbrit

The Problem

I use 3 mpd modules to create a layout like this:

modules-center = mpd-elapsedtime mpd-bar mpd-totaltime

...

[module/mpd-bar]
inherit = module/mpd

format-online = [<bar-progress>]

[module/mpd-elapsedtime]
inherit = module/mpd

label-time = %elapsed%

format-online = <label-time>

[module/mpd-totaltime]
inherit = module/mpd

label-time =%total%

format-online = <label-time>

polybar supports retrieving both the elapsed time and total time for the current mpd song. Why is it that I have to use two modules to get all this information, simply because I want to separate the information with a progress bar?

Describe the solution you'd like

I want to be able to combine these 3 modules I've created into only 1 module. This should be possible, considering they are all mpd modules and are located right next to each other.

There are two solutions that come to my mind:

Solution 1: Create label-time-1 and label-time-2

Currently, label-time is the only label within format-online that allows the use of %total%/%elapsed% etc. If there were more than one label that allowed those variables, the following would be possible:

[module/mpd-everything]
inherit = module/mpd

label-time-1 = %elapsed%
label-time-2 = %total%

format-online = <label-time-1> [<bar-progress>] <label-time-2>

Solution 2: Allow custom label names

If I could just create my own label names and refer to them in format-online, this whole problem goes away and allows for a ton of customization:

[module/mpd-everything]
inherit = module/mpd

label-whatever-I-want = %elapsed%
label-time17 = %total%

format-online = <label-whatever-I-want> [<bar-progress>] <label-time17>

Describe alternatives you've considered

I realize it is possible to get all 3 pieces of data inside 1 module like this:

modules-center = mpd-everything

[module/mpd-everything]
inherit = module/mpd

label-time = %elapsed% / %total%

format-online = <label-time> <bar-progress>

However, this layout is not what I want. The previous code gives:

1:32 / 2:41 [---------|-----]

While I want:

1:32 [---------|-----] 2:41

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions