I am having trouble comparing two strings. Even though they are identical when printed, my if statement returns false.
#!/bin/bash
string1="HDMI"
string2="PC Speaker"
hash=$(pacmd list-sinks | grep active)
echo $hash
trigger="active port: <analog-output-speaker>"
echo $trigger
if [ "$hash" == "$trigger" ]; then
pacmd set-card-profile 0 output:hdmi-stereo+input:analog-stereo
echo $string1
else
pacmd set-card-profile 0 output:analog-stereo+input:analog-stereo
echo $string2
fi
It produces the following output:
active port: <analog-output-speaker>
active port: <analog-output-speaker>
Welcome to PulseAudio! Use "help" for usage information.
>>> >>> PC Speaker