import "@johnlindquist/kit"
const SwitchAudioSourcePath = '/opt/homebrew/bin/SwitchAudioSource'
const sasExists = await pathExists(SwitchAudioSourcePath)
if (sasExists) {
const currentOutput = await $`${SwitchAudioSourcePath} -c`
const items = await $`${SwitchAudioSourcePath} -a -t output`
const choices = items.stdout.trim().split(/\r?\n/).filter(o => o !== currentOutput.stdout.trim())
let output = await arg(
{
placeholder: 'Pick ouput device'
},
choices
)
await $`${SwitchAudioSourcePath} -s ${output} -t output`
} else {
await div(md(`ERROR: Please install SwitchAudioSource`))
}