11
11
import time
12
12
import subprocess
13
13
14
- from albert import Item , info , ProcAction
14
+ from albert import QueryHandler , Item , info , Action , runDetachedProcess
15
15
16
16
from brotab .search .query import query as brotab_query
17
17
18
18
__title__ = "BroTab Search"
19
- __version__ = "0.1.0 "
19
+ __version__ = "0.1"
20
20
__triggers__ = "s "
21
21
__authors__ = ["Yuri Bochkarev" ]
22
22
__dependencies__ = []
23
23
__exec_deps__ = ["bt" ]
24
24
25
+ md_iid = "0.5"
26
+ md_version = "0.1"
27
+ md_id = "brotab"
28
+ md_name = "BroTab Search"
29
+ md_description = "Search your indexed browser tabs' contents."
30
+ md_license = "BSD-2"
31
+ md_url = "https://github.com/balta2ar/brotab"
32
+ md_maintainers = "@balta2ar"
33
+
25
34
SQL_DB_FILENAME = '/tmp/tabs.sqlite'
26
35
SQL_DB_TTL_SECONDS = 5 * 60
27
36
QUERY_DELAY = 0.3
@@ -42,8 +51,8 @@ def need_refresh_index():
42
51
43
52
def handleQuery (query ):
44
53
# it's not our query
45
- if not query .isTriggered :
46
- return None
54
+ # if not query.isTriggered:
55
+ # return None
47
56
48
57
# query is empty
49
58
user_query = query .string .strip ()
@@ -67,7 +76,11 @@ def handleQuery(query):
67
76
text = 'Reindex browser tabs' ,
68
77
subtext = '> bt index' ,
69
78
actions = [
70
- ProcAction ('Activate' , ['bt' , 'index' ])
79
+ Action (
80
+ id = 'reindex' ,
81
+ text = 'Reindex browser tabs' ,
82
+ callable = lambda : runDetachedProcess (cmdln = ['bt' , 'index' ], workdir = '~' ),
83
+ )
71
84
]
72
85
))
73
86
@@ -81,8 +94,24 @@ def handleQuery(query):
81
94
text = query_result .snippet ,
82
95
subtext = query_result .title ,
83
96
actions = [
84
- ProcAction ('Activate' , ['bt' , 'activate' , query_result .tab_id ])
97
+ Action (
98
+ id = 'activate' ,
99
+ text = 'Activate' ,
100
+ callable = lambda : runDetachedProcess (cmdln = ['bt' , 'activate' , query_result .tab_id ], workdir = '~' ),
101
+ )
85
102
]
86
103
))
87
104
88
- return items
105
+ #return items
106
+ query .add (items )
107
+
108
+ class Plugin (QueryHandler ):
109
+ def id (self ): return md_id
110
+ def name (self ): return md_name
111
+ def description (self ): return md_description
112
+ def initialize (self ): info ('brotab initialize' )
113
+ def finalize (self ): info ('brotab finalize' )
114
+ def defaultTrigger (self ): return __triggers__
115
+ def handleQuery (self , query ):
116
+ info ('brotab handleQuery' )
117
+ return handleQuery (query )
0 commit comments