alanhe421 / alfred-workflows

Save time, Improve life.🚀 ☕️ 💻
https://medium.com/@alanhe421/list/alfred-a65a11fa7a0f
MIT License
645 stars 61 forks source link

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

Closed dyckia closed 7 months ago

dyckia commented 1 year ago

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

alanhe421 commented 1 year ago
  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.
TobiasMende commented 1 year ago

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.

am-chris commented 1 year ago

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)

abondarev84 commented 1 year ago

+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)
alanhe421 commented 1 year ago

@TobiasMende You are nice.

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

TobiasMende commented 1 year ago

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?

alanhe421 commented 1 year ago

@TobiasMende

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

feeltens commented 1 year ago

@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.

fuhrthom commented 1 year ago

@alanhg looking forward to use your workflow at ventura!

alanhe421 commented 1 year ago

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

abondarev84 commented 1 year ago

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

JayBrown commented 1 year ago

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.)

alanhe421 commented 1 year ago

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

WladyX commented 11 months ago

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

abondarev84 commented 11 months ago

+1

feeltens commented 10 months ago

+1

feeltens commented 10 months ago

@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!

alanhe421 commented 7 months ago

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