Skip to content

Instantly share code, notes, and snippets.

@VimalMollyn
Created February 21, 2024 07:46
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 VimalMollyn/6ea17a5257cca11a7731ae17cd38c42b to your computer and use it in GitHub Desktop.
Save VimalMollyn/6ea17a5257cca11a7731ae17cd38c42b to your computer and use it in GitHub Desktop.
Auto Pause and Resume Dropbox sync on MacOS with python
import subprocess
def run_apple_script(apple_script):
result = subprocess.run(['osascript', '-e', apple_script], capture_output=True, text=True)
if result.returncode == 0:
return result.stdout
else:
raise Exception(result.stderr)
# Example usage
script = '''tell application "System Events"
-- Pause syncing
click menu bar item 1 of menu bar 2 of application process "Dropbox"
click menu item "Pause Syncing" of menu 1 of menu bar item 1 of menu bar 2 of application process "Dropbox"
delay 2
-- Now re-enable syncing
click menu bar item 1 of menu bar 2 of application process "Dropbox"
click menu item "Resume Syncing" of menu 1 of menu bar item 1 of menu bar 2 of application process "Dropbox"
end tell
'''
output = run_apple_script(script)
print(output)
@VimalMollyn
Copy link
Author

Big thanks to @varenc for the original implementation. I just modified it to run in python :D. tjluoma/dropbox-pause-unpause#2 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment