Alfred-WorkFlows
Alfred-WorkFlows copied to clipboard
The workflow require type two times to show the available devices
step 1: The first time it will reach the web search step of the alfred, step 2: and the second time will show a list, step 3: after the devices is switched it will go to step one again
I had this on my M1 after upgrading to Montery.
If you open the 'output' script filter in alfred, you can add the following
repeat until exists tab group 1 of window "Sound"
end repeat
under
tell application "System Events" to tell process "System Preferences"
Here's the entire output scriptfilter code incase usefull:
tell application "System Preferences"
reveal anchor "output" of pane id "com.apple.preference.sound"
end tell
set deviceselectedXML to ""
tell application "System Events" to tell process "System Preferences"
repeat until exists tab group 1 of window "Sound"
end repeat
repeat with i from 1 to the count of rows of table 1 of scroll area 1 of tab group 1 of window 1
if exists (text field 1 of row i of table 1 of scroll area 1 of tab group 1 of window 1) then
set deviceselected to the value of text field 1 of row i of table 1 of scroll area 1 of tab group 1 of window 1
set deviceselectedXML to deviceselectedXML & "<item uid='" & deviceselected & "' arg='" & deviceselected & "' valid='YES' autocomplete='" & deviceselected & "'><title>" & deviceselected & "</title>"
if (selected of row i of table 1 of scroll area 1 of tab group 1 of window 1) then
set deviceselectedXML to deviceselectedXML & "<subtitle> Currently selected </subtitle>"
end if
set deviceselectedXML to deviceselectedXML & "<icon>output.png</icon> </item>"
end if
end repeat
end tell
set deviceselectedXML to "cat << EOB
<?xml version='1.0'?> <items> " & deviceselectedXML & "</items>
EOB"
do shell script deviceselectedXML