-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmenubar.py
executable file
·57 lines (50 loc) · 1.69 KB
/
menubar.py
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
#!/usr/bin/env python3
"""
This module defines class for menu bar item and the options
user can click on.
Includes features like:
Setup
Password (create/change)
onoff- Launching daemon
stop - stop the daemon from running
"""
import rumps
import subprocess
import os
class MacFace(rumps.App):
new_process = None
@rumps.clicked("SetUp")
def setup(self, _):
"""
Method to access setup options to create or change training data
"""
subprocess.Popen([os.path.expanduser('~/MacFaceID/training_data.py')])
@rumps.clicked("Password")
def password(self, _):
"""
Method to create or change password. Calls the script which
saves the password in keychain.
"""
subprocess.Popen([os.path.expanduser("~/MacFaceID/credentials.py")])
@rumps.clicked("Launch MacFace")
def onoff(self, sender):
"""
Method to launch MacFace daemon, saves process in class attribute new_process
"""
self.new_process = subprocess.Popen([os.path.expanduser('~/MacFaceID/sleepwatcher'), '-w', os.path.expanduser('~/MacFaceID/unlock_it.wakeup')])
@rumps.clicked("Stop")
def stop_macface(self, _):
"""
Method to stop the app from running. Uses kill to kill the
process launched in Launch Macface button
"""
kill_it = "kill -9 {}".format(self.new_process.pid)
os.system(kill_it)
@rumps.clicked('Quit')
def clean_up_before_quit(self,_):
kill_it = "kill -9 {}".format(self.new_process.pid)
os.system(kill_it)
rumps.quit_application()
if __name__ == "__main__":
app = MacFace('MF', quit_button=None)
app.run()