#!/bin/env sh

SPEAKER_ICON="󰓃 "
HEADPHONE_ICON=" "

declare -A ICON_DEVICES
ICON_DEVICES[alsa_output.usb-Razer_Razer_Nari-00.pro-output-1]=$HEADPHONE_ICON
ICON_DEVICES[alsa_output.pci-0000_08_00.0.iec958-stereo]=$SPEAKER_ICON

ICON_VOLMUES=" , "
ICON_VOLUME_MUTED=" "

NICKNAME_SOURCE="device.nick"

FORMAT_DEFAULT='$VOL_ICON ${VOL_LEVEL}%  $ICON_NODE $NODE_NICKNAME'
FORMAT_ICONS='$VOL_ICON  $ICON_NODE $NODE_NICKNAME'

icon_devices_parameters=""
for device in "${!ICON_DEVICES[@]}"; do
  icon_devices_parameters="${icon_devices_parameters} --node-nickname "${device}:${ICON_DEVICES[$device]}""
done

format=$FORMAT_DEFAULT
if [[ $1 == 'icons' ]]; then
  format=$FORMAT_ICONS
fi

pulseaudio-control ${icon_devices_parameters} --icons-volume "${ICON_VOLMUES}" --icon-muted "${ICON_VOLUME_MUTED}" --node-nicknames-from "${NICKNAME_SOURCE}" --format "${format}" --color-muted "" listen
