#!/bin/bash
# Get all sink inputs as JSON array for eww
pactl list sink-inputs | awk '
/^Sink Input/ { id=substr($3,2,length($3)-1) }
/application.name/ { gsub(/"/,"",$3); name=$3 }
/Volume:.*%/ {
  match($0, /[0-9]+%/)
  vol=substr($0,RSTART,RLENGTH-1)
  printf "{\"id\":\"%s\",\"name\":\"%s\",\"volume\":\"%s\"}\n", id, name, vol
  name=""; vol=""
}' | jq -s '.'