-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpass.py
51 lines (40 loc) · 1.35 KB
/
pass.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
__kupfer_name__ = _("Pass Manager")
__kupfer_sources__ = ("PassSource", )
__description__ = _("Passwords to clipboard")
__version__ = ""
__author__ = "Christopher Freeman <christopher.p.freeman@gmail.com"
from kupfer.objects import Action, Source, Leaf
from kupfer import utils
import os
class Password (Leaf):
rank_adjust = 5
def __init__(self, password):
self.password = password
Leaf.__init__(self, password, password)
def get_actions(self):
yield OpenPass()
def get_icon_name(self):
return "dialog-password"
class OpenPass (Action):
rank_adjust = 5
def __init__(self, name=None):
super(OpenPass, self).__init__(name or _("Open Password"))
def activate(self, leaf):
utils.spawn_async(["pass", "-c", leaf.password])
return
class PassSource (Source):
def __init__(self):
Source.__init__(self, name=_("Passwords"))
def get_rank(self):
return 5
def is_dynamic(self):
return True
def get_items(self):
root = os.environ['HOME'] + "/.password-store/"
for path, subdirs, files in os.walk(root):
for name in files:
yield Password(os.path.splitext(os.path.relpath(os.path.join(path, name), root))[0])
def get_icon_name(self):
return "dialog-password"
def provides(self):
yield Password