Why doesn't this work?
$ SwitchAudioSource -c
William’s AirPods
$ if [[ $(SwitchAudioSource -c) == "William's Airpods" ]]; then echo hello; fi
$
CodePudding user response:
Look at them side by side:
William’s AirPods
William's Airpods
^ ^
| --- capital (P) vs. lowercase (p)
--- smart quote (’) vs plain apostrophe (')
CodePudding user response:
The only way I can figure this is if the output you show from SwitchAudioSource
is on STDERR, not STDOUT.
(I'm on a Mac, but don't have SwitchAudioSource
.)
But if that's the case, this should work:
if [[ $(SwitchAudioSource -c 2>&1) == "William’s AirPods" ]]; then echo hello; fi