Comments (4)
When run on Monterey.
1206:1281: execution error: System Events got an error: Can’t get menu bar item 1 of menu bar 1 of process "SystemUIServer" whose description contains "Displays". Invalid index. (-1719)
from aircontrol.
I also get this with Monterey:
1161:1236: execution error: System Events got an error: Can’t get menu bar 1 of process "SystemUIServer". Invalid index. (-1719)
from aircontrol.
@kevindiffily If you still care about this, I ultimately changed everything in /aircontrol for Monterey, so hopefully this helps:
#!/usr/bin/env bash
tvname="Samsung 8 series"
read -d '' APPLESCRIPT <<EOF
tell application "System Preferences"
if not running then run
activate
reveal anchor "displaysArrangementTab" of pane id "com.apple.preference.displays"
end tell
tell application "System Events"
tell process "System Preferences"
click window "Displays"
tell pop up button "Add Display" of window "Displays"
click
click menu item \"$tvname\" of menu 1
end tell
end tell
end tell
EOF
osascript -e "$APPLESCRIPT" > /dev/null
(I'll have to open a PR later to make it better)
from aircontrol.
It does not work on Ventura. I used Automator to generate AppleScript that works most of the time:
-- Click the “Screen Mirroring” menu bar item.
-- delay 2.130212
set timeoutSeconds to 2.0
set uiScript to "click menu bar item 7 of menu bar 1 of application process \"Control Center\""
my doWithTimeout(uiScript, timeoutSeconds)
-- Click the “<fill in title>” checkbox.
-- delay 0.988109
set timeoutSeconds to 2.0
set uiScript to "click checkbox 1 of scroll area 1 of group 1 of window \"Control Center\" of application process \"Control Center\""
my doWithTimeout(uiScript, timeoutSeconds)
-- Type '�'
-- delay 1.04737
set timeoutSeconds to 2.0
set uiScript to "keystroke \"�\""
my doWithTimeout(uiScript, timeoutSeconds)
on doWithTimeout(uiScript, timeoutSeconds)
set endDate to (current date) + timeoutSeconds
repeat
try
run script "tell application \"System Events\"
" & uiScript & "
end tell"
exit repeat
on error errorMessage
if ((current date) > endDate) then
error "Can not " & uiScript
end if
end try
end repeat
end doWithTimeout
However, I can't find a way to hard-code the menu time in Control Center, so we can consistently select the correct Airplay receiver using the CLI argument. It appears GUI scripting got more difficult with Ventura:
https://stackoverflow.com/questions/71691357/open-screen-mirroring-in-control-center-for-sidecar
from aircontrol.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aircontrol.