elkowar / eww

ElKowars wacky widgets
https://elkowar.github.io/eww
MIT License
9.21k stars 380 forks source link

awk travesty #856

Closed jnordwick closed 1 year ago

jnordwick commented 1 year ago

elkowar/eww/blob/master/examples/eww-bar/scripts/getvol

amixer -D pulse sget Master | grep 'Left:' | awk -F'[][]' '{ print $2 }' | tr -d '%' | head -1

to

amixer -D pulse sget Master | awk -F '[^0-9]+' '/Left:/{print $3}'

kids these days

buffet commented 1 year ago

fr what even is that, eww (get it)

elkowar commented 1 year ago

fixed, thanks!

a-priestley commented 1 year ago

This assumes stereo output. You still need to ensure a single value in the case of multiple left speakers:

amixer -D pulse sget Master | awk -F '[^0-9]+' '/Left:/{print $3}' | head -n 1
Mango0x45 commented 11 months ago

This assumes stereo output. You still need to ensure a single value in the case of multiple left speakers:

amixer -D pulse sget Master | awk -F '[^0-9]+' '/Left:/{print $3}' | head -n 1

Yet another incorrect use of awk. It can also take the place of head:

amixer -D pulse sget Master | awk -F '[^0-9]+' '/Left:/ { print $3; quit }'