Skip to content

Instantly share code, notes, and snippets.

@kalyan02
Created May 16, 2023 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kalyan02/634b84cca2fb1e78f60a9343ede8861d to your computer and use it in GitHub Desktop.
Save kalyan02/634b84cca2fb1e78f60a9343ede8861d to your computer and use it in GitHub Desktop.
Python script to show alert when a meeting is starting in 1 min
import subprocess
import datetime
import time
minutes=2
calendar_name = "Home"
def run_applescript(script):
osa_command = ['osascript', '-e', script]
return subprocess.run(osa_command, capture_output=True, text=True).stdout
def check_meetings(calendar_name, minutes):
script = f"""
tell application "Calendar"
tell (first calendar whose name is "%s")
get the summary of (every event whose start date is greater than (current date) and start date is less than (current date + %d * minutes))
end tell
end tell
""" % (calendar_name, minutes)
events = run_applescript(script).strip().split(", ")
print(events)
if events[0] != "":
alert_script = f"""
display dialog "Meeting is starting: {', '.join(events)}"
"""
run_applescript(alert_script)
while True:
check_meetings(calendar_name, minutes)
time.sleep(minutes*60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment