marioortizmanero / polybar-pulseaudio-control

A feature-full Polybar module to control PulseAudio
MIT License
466 stars 49 forks source link

Allow variable substitution in --color-muted #80

Open rtreccani opened 1 year ago

rtreccani commented 1 year ago

I use wal to theme my system, and for most modules I could use something like format-muted = ${colors.disabled} to make the module highlight red when muted, or use --color-muted ${colors.disabled} in my call to the pulseaudio-control bash script, but I get /bin/bash line 1: bad substitution when I do that. Is there an undocumented way to change the color of the module when muted, or some way to correctly escape the color such that it can be read?

marioortizmanero commented 1 year ago

I think ${colors.disabled} isn't a valid variable in bash. I also use wal, and in .cache/wal/colors.sh, they're declared as color0 and such. Is that what you actually want to use?

rtreccani commented 1 year ago

I'm not sure if that's the 'canonical' way that polybar does it, but yeah in my polybar config, i have a block such as

[colors]
urgent = ${xrdb:color4}
disabled = ${xrdb:color5}
primary = ${xrdb:color6}
foreground = ${xrdb:color7}

which just renames the xrdb variables to something more palatable, and then when i want to use it, for example

[module/xworkspaces]
label-active-background = ${colors.background}
label-active-underline= ${colors.disabled}

this works for the polybar modules i'm using so far, so maybe the best option would be format-muted = ${colors.disabled}being supported, as it doesn't rely on bash expanding the variable.

Thanks for the quick response and the amazing module btw :)

marioortizmanero commented 1 year ago

That won't work because polybar variables can't be set as part of another string. If you use a variable, the entire value has to be the variable, not command ${variable}, for example. I also ran into this issue, and not sure if I ended up resolving it, because AFAIK in script modules you can't really have these format-muted-like custom fields. Maybe you could create a wrapper that reads from the cache pywal script and executes this with the proper variable expanded.

rtreccani commented 1 year ago

I'm just trying to achieve something similiar to, for example, the default PulseAudio module, see https://github.com/rtreccani/dotfiles/blob/newlap/polybar/config#L168. Forget using Pywal, is it possible to statically set the colour of unmuted vs muted?