regolith-linux / regolith-i3xrocks-config

Regolith customization of i3xrocks.
Other
29 stars 49 forks source link

i3xrocks-volume - volume below 10% not shown #135

Closed sdrwtf closed 2 years ago

sdrwtf commented 2 years ago

Hey,

I'm currently testing regolith with an virtual minimal Ubuntu installation (like it's described here https://regolith-desktop.com/docs/howtos/minimal-ubuntu-install/) and figured out that if I change the volume below 10% the volume is not displayed anymore:

image

If the volume is >= 10% everything is fine:

image

The same behavior applies for the microphone volume.

The reason seems to be the sed regex which is used within the mixer_value function: https://github.com/regolith-linux/regolith-i3xrocks-config/blob/7bb3464cc56ec3e42830e9126a246769a86d3bba/scripts/volume#L66

I think it would be better to only filter on a single number and add a 0 prefix in case the value is less than 10, for example:

mixer_value() {
    VAL=$(mixer_info | sed -n -E "s/.*\[(-?[0-9]+)$UNIT\].*/\1/p" | head -n 1)
    if [ -z "$VAL" ]; then
        # return empty string of same width to prevent bar shift.
        echo "   "
    elif [ "$VAL" -lt "10" ]; then
        echo "0$VAL$UNIT"
    else
        echo "$VAL$UNIT"
    fi
}

So volume below 10% is also displayed as expected:

image

kgilmer commented 2 years ago

Hi @sdrwtf ! Thanks for the detailed bug report and fix proposal. I don't see any problems with your update. Would you like to setup a Pull Request?

sdrwtf commented 2 years ago

Hi @kgilmer,

yep of course, I'll create the PR tomorrow and will also include the microphone script.