#! /bin/bash

internal() {
  SPEAKER=$(pactl list sinks | grep "Name" | grep "alsa" | awk -F ': ' '{ print $2  }')
  if [ "$SPEAKER" != "" ]; then
    pactl set-default-sink "$SPEAKER"
    pactl set-sink-mute "$SPEAKER" false
    notify-send "changed audio to internal speakers "
  else
    notify-send "failed, not available!"
  fi
}

bluetooth() {
  SPEAKER=$(pactl list sinks | grep "Name" | grep "blue" | awk -F ': ' '{ print $2  }')
  if [ "$SPEAKER" != "" ]; then
    pactl set-default-sink "$SPEAKER"
    pactl set-sink-mute "$SPEAKER" false
    notify-send "changed audio to Bluetooth"
  else
    notify-send "failed, not available!"
  fi
}


if [ "$1" == "internal" ]; then
  internal
elif [ "$1" == "bluetooth" ]; then
  bluetooth
else
  SPEAKER=$(pactl info | grep "Default Sink" | awk -F ': ' ' { print $2 } ')
  pactl set-sink-mute "$SPEAKER" false
fi


