Candyrice/sh/values/vol/volume.sh

31 lines
565 B
Bash
Raw Normal View History

2024-08-01 17:28:37 +00:00
#!/bin/bash
vol=$(amixer get Master | grep "Front\ Left:\ Playback.*%")
v=${vol#*\[}
s=${v#*\[}
v=${v%%\%*}
s=${s%%\]*}
if [[ $v == '0' ]]; then
s="empty";
2024-12-13 19:04:18 +00:00
ico="";
2024-08-01 17:28:37 +00:00
elif [[ "$s" == "on" ]]; then
s="low";
2024-12-13 19:04:18 +00:00
ico="";
2024-08-01 17:28:37 +00:00
if [[ $v -gt 35 ]]; then
s="med";
2024-12-13 19:04:18 +00:00
ico=""; fi
2024-08-01 17:28:37 +00:00
if [[ $v -gt 50 ]]; then
s="high";
2024-12-13 19:04:18 +00:00
ico=""; fi
2024-08-01 17:28:37 +00:00
if [[ $v -gt 80 ]]; then
s="vhigh";
2024-12-13 19:04:18 +00:00
ico=""; fi
2024-08-01 17:28:37 +00:00
if [[ $v -eq 100 ]]; then
s="full";
2024-12-13 19:04:18 +00:00
ico=""; fi
2024-08-01 17:28:37 +00:00
else
2024-12-13 19:04:18 +00:00
ico="";
2024-08-01 17:28:37 +00:00
fi
echo "{\"level\":\"$v\",\"status\":\"$s\",\"icon\":\"$ico\"}"