summaryrefslogtreecommitdiffstats
path: root/polybar/OpenBSD-vol.sh
blob: 8cc7925b42a0c0094df4f64428547fbaeaebfba9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env bash

function sndio_val() {
  sndioctl "$1" 2> /dev/null | awk -F'=' '{print $2}'
}

while true; do
  LEVEL=$(sndio_val output.level | bc)
  MUTE=$(sndio_val output.mute)
  if [[ $MUTE -eq 1 ]]; then
    echo 'muted'
  else
    LEVEL=${LEVEL/./}
    echo "$(( LEVEL/10 ))%"
  fi
  sleep 1
done