Skip to content

Commit ec47a5e

Browse files
committed
albert: committing changes from the shelf, looks like there have been updates to albert interfaces
1 parent 6f2ab29 commit ec47a5e

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

brotab/albert/brotab_search.py

+36-7
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,26 @@
1111
import time
1212
import subprocess
1313

14-
from albert import Item, info, ProcAction
14+
from albert import QueryHandler, Item, info, Action, runDetachedProcess
1515

1616
from brotab.search.query import query as brotab_query
1717

1818
__title__ = "BroTab Search"
19-
__version__ = "0.1.0"
19+
__version__ = "0.1"
2020
__triggers__ = "s "
2121
__authors__ = ["Yuri Bochkarev"]
2222
__dependencies__ = []
2323
__exec_deps__ = ["bt"]
2424

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+
2534
SQL_DB_FILENAME = '/tmp/tabs.sqlite'
2635
SQL_DB_TTL_SECONDS = 5 * 60
2736
QUERY_DELAY = 0.3
@@ -42,8 +51,8 @@ def need_refresh_index():
4251

4352
def handleQuery(query):
4453
# it's not our query
45-
if not query.isTriggered:
46-
return None
54+
# if not query.isTriggered:
55+
# return None
4756

4857
# query is empty
4958
user_query = query.string.strip()
@@ -67,7 +76,11 @@ def handleQuery(query):
6776
text='Reindex browser tabs',
6877
subtext='> bt index',
6978
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+
)
7184
]
7285
))
7386

@@ -81,8 +94,24 @@ def handleQuery(query):
8194
text=query_result.snippet,
8295
subtext=query_result.title,
8396
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+
)
85102
]
86103
))
87104

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

Comments
 (0)