forked from albertlauncher/python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trash.py
28 lines (21 loc) · 875 Bytes
/
trash.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
# -*- coding: utf-8 -*-
"""Open virtual trash location.
This extension provides a single item which opens the systems virtual trash \
location in your default file manager.
Synopsis: <trigger>"""
import re
from albertv0 import Item, UrlAction, iconLookup
__iid__ = "PythonInterface/v0.1"
__prettyname__ = "Trash"
__version__ = "1.0"
__author__ = "Manuel Schneider"
iconPath = iconLookup("user-trash-full")
def handleQuery(query):
if query.string.strip() and "trash".startswith(query.string.lower()):
pattern = re.compile(query.string, re.IGNORECASE)
return Item(id="trash-open",
icon=iconPath,
text=pattern.sub(lambda m: "<u>%s</u>" % m.group(0), "Trash"),
subtext="Show trash folder",
completion="trash",
actions=[UrlAction("Show", "trash:///")])