diff options
Diffstat (limited to 'machammer/process.py')
-rwxr-xr-x | machammer/process.py | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/machammer/process.py b/machammer/process.py index d445e07..59160c6 100755 --- a/machammer/process.py +++ b/machammer/process.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from .functions import osascript, call +from .functions import call, tell_app def pidof(name): @@ -8,12 +8,30 @@ def pidof(name): def is_running(name): - pass + s = 'name of every application process contains "%s"' % name + a = tell_app('System Events', s) + return a == 'true' + + +def is_active(name): + """Return True if process with name is frontmost + """ + s = 'name of first application process whose frontmost is true' + a = tell_app('System Events', s) + return a == name + + +def activate(name): + tell_app(name, 'activate') def quit(name): pass -def kill(name): - pass +def kill(name, signal='TERM'): + call('/usr/bin/killall', '-' + signal, name) + + +def open(name): + call('/usr/bin/open', '-a', name) |