Skip to content

Instantly share code, notes, and snippets.

@manzyuk
Created December 23, 2010 20:12
Show Gist options
  • Save manzyuk/753481 to your computer and use it in GitHub Desktop.
Save manzyuk/753481 to your computer and use it in GitHub Desktop.
format volume info for xmobar
#!/usr/bin/env bash
OUTPUT=`amixer sget Master | tail -1`
VOLUME=`echo $OUTPUT | sed -r 's/.*\[([0-9]*)%\].*/\1/' | awk '{printf "%3s",$1}'`
STATUS=`echo $OUTPUT | sed -r 's/.*\[(on|off)\].*/\1/'`
if [[ "$STATUS" == "off" ]]
then
echo "<fc=#8888FF>VOL:</fc> $VOLUME% <fc=red>Off</fc>"
else
echo "<fc=#8888FF>VOL:</fc> $VOLUME% <fc=green> On</fc>"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment