Skip to content

Commit

Permalink
Fix issue with notification + handle non existing display better
Browse files Browse the repository at this point in the history
  • Loading branch information
godbout committed Dec 13, 2017
1 parent 5256439 commit 0acf18a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions alfred-airplay-selector.sh → alfred-airplay-spreader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@

read -d '' APPLESCRIPT <<EOF
set found to false
tell application "System Events"
tell process "SystemUIServer"
click (menu bar item 1 of menu bar 1 whose description contains "Displays")
click menu item "$1" of menu 1 of result
set found to true
delay 4
try
click menu item "$1" of menu 1 of result
set found to true
delay 4
on error
key code 53
end try
end tell
end tell
return found
EOF

osascript -e "$APPLESCRIPT" > /dev/null
found=$(osascript -e "$APPLESCRIPT")

if [[ "$1" = "Turn AirPlay Off" ]]; then
echo "Display not shared anymore";
elif [ found = true ]; then
elif [ "$found" = true ]; then
echo "Display now shared with \"$1\"";
else
echo "Cannot find \"$1\" display";
Expand Down

0 comments on commit 0acf18a

Please sign in to comment.