Skip to content

Commit

Permalink
Ensure Sonos app is running before trying to use it
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonrudolph committed Jul 15, 2017
1 parent a79b2c2 commit ee0001c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sonos-mute-unmute.lbaction/Contents/Scripts/default.scpt
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
if application "Sonos" is not running then
tell application "Sonos" to activate

tell application "System Events"
repeat until visible of process "Sonos" is true
delay 0.1
end repeat
delay 1 -- After app becomes visible, wait for it to render its buttons
end tell
end if

tell application "System Events"
tell process "Sonos"
click button 1 of window 1
Expand Down
11 changes: 11 additions & 0 deletions sonos-play-pause.lbaction/Contents/Scripts/default.scpt
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
if application "Sonos" is not running then
tell application "Sonos" to activate

tell application "System Events"
repeat until visible of process "Sonos" is true
delay 0.1
end repeat
delay 1 -- After app becomes visible, wait for it to render its buttons
end tell
end if

tell application "System Events"
tell process "Sonos"
click button 3 of window 1
Expand Down
11 changes: 11 additions & 0 deletions sonos-volume-down.lbaction/Contents/Scripts/default.scpt
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
if application "Sonos" is not running then
tell application "Sonos" to activate

tell application "System Events"
repeat until visible of process "Sonos" is true
delay 0.1
end repeat
delay 1 -- After app becomes visible, wait for it to render its buttons
end tell
end if

tell application "System Events"
tell process "Sonos"
set value of slider 1 of window 1 to get (value of slider 1 of window 1) - 2
Expand Down
11 changes: 11 additions & 0 deletions sonos-volume-up.lbaction/Contents/Scripts/default.scpt
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
if application "Sonos" is not running then
tell application "Sonos" to activate

tell application "System Events"
repeat until visible of process "Sonos" is true
delay 0.1
end repeat
delay 1 -- After app becomes visible, wait for it to render its buttons
end tell
end if

tell application "System Events"
tell process "Sonos"
set value of slider 1 of window 1 to get (value of slider 1 of window 1) + 2
Expand Down

0 comments on commit ee0001c

Please sign in to comment.