alfred-workflows icon indicating copy to clipboard operation
alfred-workflows copied to clipboard

[Bug]: switch-audio does not on macOS 13 Ventura

Open dyckia opened this issue 2 years ago • 18 comments

Describe the bug

switch-audio workflow is no longer working on macOS 13 Ventura.

Behavior: The sound and voice commands do not return the devices list.

MacOS Version

macOS 13 Ventura

Alfred Version

Alfred 5.0.5

Workflow Name

Switch Audio

dyckia avatar Nov 04 '22 00:11 dyckia

  1. I haven't upgraded my new system at the moment, so I can't test verify the issue.
  2. The workflow relies on the UI, so the cause of the problem should be here.

alanhe421 avatar Nov 04 '22 15:11 alanhe421

I have adapted it locally to work with Mac OS Ventura. I am using switchaudio-osx and jq in order to select and switch the devices without relying on AppleScript and the System Settings.

Therefore, my solution is not an easy drop-in, but in case you are interested, my main.sh looks like:

#!/bin/zsh
type=$1
current=$(SwitchAudioSource -c -t $type -f json)
current_id=$(echo $current | jq -r '.id')
current_extended=$(echo $current | jq -rc --arg TYPE "$type" '{title: .name, uid: .name, autocomplete: .name, arg: .id, icon: {path: ("./icons/"+ $TYPE + "_selected.png")}}')
all_without_current=$(SwitchAudioSource -a -t $type -f json | jq -rc --arg CURRENT "$current_id" 'select(.id != $CURRENT) | {title: .name, uid: .name, autocomplete: .name, arg: .id}')
echo "$all_without_current\n$current_extended" | jq -r --slurp 'sort_by(.title) | {items: .}'

can be called via ZSH ./main.sh output (or input)

Preconditions can be installed via

brew install switchaudio-osx jq

The actual command for switching then is a ZSH script as well

SwitchAudioSource -i $1 > /dev/null

SwitchAudioSource -c

If that is a path you consider going with the plugin, I am happy to provide a PR.

TobiasMende avatar Dec 15 '22 12:12 TobiasMende

Seeing the same issue on my end. (I didn't attempt Tobias' fix)

MacOS Ventura 13.0.1 - Alfred version 5.0.6

Here is the error:

[10:39:59.050] Switch Audio[Script Filter] Queuing argument '(null)' [10:39:59.193] Switch Audio[Script Filter] Script with argv '(null)' finished [10:39:59.193] ERROR: Switch Audio[Script Filter] Code 1: /Users/chris/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/A80F00C9-3FBC-481F-B5CB-A94ED3E5EB49:55:102: execution error: System Settings got an error: AppleEvent handler failed. (-10000)

am-chris avatar Dec 17 '22 18:12 am-chris

+1 @am-chris

Ventura 13.1, Alfred 5.0.6

my "log" :

[21:19:28.232] Logging Started...
[21:19:30.727] Switch Audio[Script Filter] Queuing argument '(null)'
[21:19:30.913] Switch Audio[Script Filter] Script with argv '(null)' finished
[21:19:30.918] ERROR: Switch Audio[Script Filter] Code 1: /Users/alexbnd/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/FBE66A11-B1A0-40C9-8F30-87C699126DF7:55:102: execution error: System Settings got an error: AppleEvent handler failed. (-10000)

abondarev84 avatar Dec 27 '22 19:12 abondarev84

@TobiasMende You are nice.

switchaudio-osx does not support airplay devices. so I think AppleScript it's better.

alanhe421 avatar Dec 28 '22 02:12 alanhe421

You are right. Did not use AirPlay, so I was not aware of this limitation.

Found this issue, where you already commented: https://github.com/deweller/switchaudio-osx/issues/9

Unfortunately, there also seems to be no working AppleScript solution for Ventura yet. Do you know one?

TobiasMende avatar Dec 28 '22 14:12 TobiasMende

@TobiasMende

I will update my home mac to Ventura and have a try.

alanhe421 avatar Dec 28 '22 14:12 alanhe421

@alanhg

Hope to help fix the bug: https://forum.keyboardmaestro.com/t/macro-set-sound-output-v4-0/23959

I like Alfred rather than Keyboard Maestro.

feeltens avatar Dec 31 '22 07:12 feeltens

@alanhg looking forward to use your workflow at ventura!

fuhrthom avatar Jan 13 '23 01:01 fuhrthom

AppleScript documentation was so poor that I had to consider learning Swift to solve it.

alanhe421 avatar Jan 15 '23 10:01 alanhe421

any updates? this was one of my most used workflows up until Ventura.

abondarev84 avatar Mar 15 '23 09:03 abondarev84

I found some sources online and got this AppleScript to work in Ventura: https://github.com/deweller/switchaudio-osx/issues/9#issuecomment-1496674289

(Caveat: doesn't seem to work when System Settings is launched hidden or in the background, so if someone knows how to fix that, it would be most welcome.)

JayBrown avatar Apr 05 '23 13:04 JayBrown

any updates? this was one of my most used workflows up until Ventura.

In development.

I gave up on using AppleScript and decided to do secondary development based on switchaudio-osx.

list airplay device is ok. but switch to airplay not work. I need to find method to do it.

image

alanhe421 avatar Apr 15 '23 15:04 alanhe421

hey, don't shoot me pls :) just wandering if this something that you still think about. thank you!

WladyX avatar Oct 17 '23 08:10 WladyX

+1

abondarev84 avatar Oct 17 '23 13:10 abondarev84

+1

feeltens avatar Oct 27 '23 02:10 feeltens

@alanhg Hope to help fix the bug: https://github.com/lapfelix/BluetoothConnector 1、install bluetoothconnector by homebrew: brew install bluetoothconnector

2、bluetoothconnector with the MAC address of specific device eg: myAirPods MAC address: 30-82-16-f2-a4-e1

3、make Application by Automator image

the shell script: #!/bin/sh /usr/local/bin/BluetoothConnector --connect 30-82-16-f2-a4-e1 --notify << EOF 123 EOF

4、allow your application to use bluetooth image

5、open your application with alfred or spotlight just enjoy it!

feeltens avatar Nov 01 '23 12:11 feeltens

I found DNSService can list airplay device. but I have not found any method to set airplay device as sound-output image

alanhe421 avatar Jan 28 '24 12:01 alanhe421