Skip to content

Commit

Permalink
Add HUD message to Sidecar script
Browse files Browse the repository at this point in the history
  • Loading branch information
dehesa authored May 10, 2021
1 parent 2cfa6d6 commit 0a70d46
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions commands/system/sidecar-toggle.template.applescript
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@

# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Toggle Sidecar
# @raycast.title Sidecar Switch
# @raycast.mode silent

# Optional parameters:
# @raycast.icon 🖥
# @raycast.packageName System

# Documentation:
# @raycast.description Toggles a Sidecar screen.
# @raycast.description Toggles on/off a Sidecar screen.
# @raycast.author Marcos Sánchez-Dehesa
# @raycast.authorURL https://www.github.com/dehesa

# You can see your device's name by going to: System Preferences > Sidecar > Connect to menu
property deviceName : "Your device's name"
# The button name changes depending on your locale.
# You can figure out your device's name on System Preferences > Sidecar > Connect to menu
property deviceName : "Device name"
# Change the "Disconnect" value if your OS is in a different language than English
property buttonName : "Disconnect"

property isConnected : false

tell application "System Preferences"
activate
reveal pane id "com.apple.preference.sidecar"
Expand All @@ -30,8 +32,14 @@ tell application "System Preferences"
tell application "System Events" to click first menu button of first window of application process "System Preferences" of application "System Events"
# If your sidecar screen device changes, youc can change the "click menu item deviceName" by "click first menu item"
tell application "System Events" to click menu item deviceName of first menu of first menu button of first window of application process "System Preferences" of application "System Events"
set isConnected to true
end try

quit

end tell
quit
end tell

if isConnected then
do shell script "echo Connection established to " & deviceName
else
do shell script "echo " & deviceName & " was disconnected"
end if

0 comments on commit 0a70d46

Please sign in to comment.