#!/bin/bash MASTER_STATE=$(amixer sget Master | grep -Po "(?<=\[)(on)|(off)(?=\])" | head -n1) if [ $MASTER_STATE = "off" ] then echo 0 else echo $(amixer sget Master | grep -Po "(?<=\[)[[:digit:]]+(?=(%\]))" | head -n1) fi