Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use AppKit to figure if we have accessbility perms and pyobjc to ask …
…for them
  • Loading branch information
xylix committed Mar 28, 2020
1 parent 25ae699 commit 82e90b2
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 1 deletion.
11 changes: 11 additions & 0 deletions aw_watcher_window/macos.py
@@ -1,9 +1,20 @@
from ApplicationServices import AXIsProcessTrusted
from AppKit import NSAlert
import subprocess
from subprocess import PIPE
import os


def getInfo() -> str:
accessibility_permissions = AXIsProcessTrusted()
#accessibility_permissions = False
if not accessibility_permissions:
title = "Missing accessibility permissions"
message = "To let ActivityWatch capture window titles grant it accessibility permissions"
ok = False
cancel = False
alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(title, ok, 'Cancel' if cancel else None, None, message)
alert.runModal()
cmd = ["osascript", os.path.join(os.path.dirname(os.path.realpath(__file__)), "printAppTitle.scpt")]
p = subprocess.run(cmd, stdout=PIPE)
return str(p.stdout, "utf8").strip()
Expand Down
90 changes: 89 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Expand Up @@ -14,6 +14,8 @@ aw-client = {git = "https://github.com/ActivityWatch/aw-client.git"}
python-xlib = {version = "^0.26", platform = "linux"}
pypiwin32 = {version = "223", platform = "win32"}
wmi = {version = "^1.4.9", platform = "win32"}
pyobjc-framework-ApplicationServices = "^6.2"
pyobjc-framework-CoreText = "^6.2"

[tool.poetry.dev-dependencies]
pytest = "^5.3.2"
Expand Down

0 comments on commit 82e90b2

Please sign in to comment.