forked from raycast/script-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeetingbar-join-meeting.applescript
executable file
·86 lines (69 loc) · 1.92 KB
/
meetingbar-join-meeting.applescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/osascript
# Dependencies:
# MeetingBar: https://github.com/leits/MeetingBar
# Recommended installation:
# brew install --cask meetingbar
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Join Meeting
# @raycast.mode silent
# Optional parameters:
# @raycast.icon images/meetingbar.png
# @raycast.packageName MeetingBar
# Documentation:
# @raycast.author Jakub Lanski
# @raycast.authorURL https://github.com/jaklan
# @raycast.description Join the ongoing or upcoming meeting.
on run
try
runMeetingBar()
joinMeeting()
return
on error errorMessage
closeMenu()
return errorMessage
end try
end run
### Functions ###
on joinMeeting()
openMenu()
tell application "System Events" to tell application process "MeetingBar"
tell menu 1 of menu bar item 1 of menu bar 2
if menu item "Join current event meeting" exists then
click menu item "Join current event meeting"
else if menu item "Join next event meeting" exists then
click menu item "Join next event meeting"
else
error "No meetings found"
end if
end tell
end tell
end joinMeeting
on MeetingBarIsRunning()
return application "MeetingBar" is running
end MeetingBarIsRunning
on runMeetingBar()
if not MeetingBarIsRunning() then do shell script "open -a 'MeetingBar'"
end runMeetingBar
on menuIsOpen()
tell application "System Events" to tell application process "MeetingBar"
return menu 1 of menu bar item 1 of menu bar 2 exists
end tell
end menuIsOpen
on openMenu()
set killDelay to 0
repeat
tell application "System Events" to tell application process "MeetingBar"
if my menuIsOpen() then return
ignoring application responses
click menu bar item 1 of menu bar 2
end ignoring
end tell
set killDelay to killDelay + 0.1
delay killDelay
do shell script "killall System\\ Events"
end repeat
end openMenu
on closeMenu()
if menuIsOpen() then tell application "System Events" to key code 53
end closeMenu