-
Notifications
You must be signed in to change notification settings - Fork 6
/
list_apps.py
46 lines (34 loc) · 1.22 KB
/
list_apps.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
import sys
from workflow import Workflow
from toolchain import run_script
from commands import CMD_LIST_APPS
import os
func = os.getenv("func")
def main(wf):
arg = wf.args[0].strip()
apps = run_script(CMD_LIST_APPS)
apps = apps.rstrip().split('\n')
log.debug(arg)
for app in apps:
if arg is '' or any(x.isupper() for x in arg) and arg in app or arg.islower() and arg in app.lower():
it = wf.add_item(title=app,
uid=app,
arg=app,
copytext=app,
valid=True)
if func == '':
m = it.add_modifier('cmd', "Launch")
m.setvar("func", "start_app")
m = it.add_modifier('alt', "Uninstall")
m.setvar("func", "uninstall_app")
m = it.add_modifier('ctrl', "Force stop")
m.setvar("func", "force_stop")
m = it.add_modifier('fn', "Clear data")
m.setvar("func", "clear_app_data")
m = it.add_modifier('shift', "Show app info")
m.setvar("func", "app_info")
wf.send_feedback()
if __name__ == '__main__':
wf = Workflow()
log = wf.logger
sys.exit(wf.run(main))