rice

personal dot files and scripts for linux and macOS
Log | Files | Refs | README | LICENSE

volume_change (509B)


      1 #!/bin/sh
      2 
      3 # Arbitrary but unique message id
      4 msgId="661051"
      5 
      6 # Get the current sink
      7 SINK=$(pactl list short sinks \
      8            | sed -e 's,^\([0-9][0-9]*\)[^0-9].*,\1,' \
      9            | head -n 1)
     10 
     11 # Update the volume
     12 pactl -- set-sink-volume "$SINK" "$1"
     13 
     14 # Get the current volume percentage
     15 NOW=$(pactl list sinks \
     16           | grep '^[[:space:]]Volume:' \
     17           | head -n $(( "$SINK" + 1 )) \
     18           | tail -n 1 \
     19           | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,')
     20 
     21 notify-send "<b>Volume</b> ${NOW}%"