Candyrice/sh/values/vol/volume_mono.sh

30 lines
655 B
Bash
Raw Permalink Normal View History

#!/bin/bash
vol=$(amixer get Master | grep "Mono: Playback" | sed -n 's/.*Mono: Playback [0-9]* \[\([0-9]*\)%\].*\[\(.*\)\]/\1 \2/p')
2025-01-08 18:53:29 +00:00
v=${vol%% *} # Volume percentage
s=${vol#* } # Volume status (on/off)
if [[ $v == '0' ]]; then
s="empty";
ico="";
elif [[ "$s" == "on" ]]; then
s="low";
ico="";
if [[ $v -gt 35 ]]; then
s="med";
ico=""; fi
if [[ $v -gt 50 ]]; then
s="high";
ico=""; fi
if [[ $v -gt 80 ]]; then
s="vhigh";
ico=""; fi
if [[ $v -eq 100 ]]; then
s="full";
ico=""; fi
else
ico="";
fi
echo "{\"level\":\"$v\",\"status\":\"$s\",\"icon\":\"$ico\"}"