Skip to content

Commit 6d7d278

Browse files
Initial commit
0 parents  commit 6d7d278

File tree

9 files changed

+280
-0
lines changed

9 files changed

+280
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.1 / 2018-12-03
2+
3+
* initial version

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Martin Hoefling
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
release:
2+
zip -r ../gopass.alfredworkflow *

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Gopass-Alfred
2+
3+
Workflow to interact with gopass from Alfred 3.
4+
Currently querying entries and copying username or password to clipboard is supported.
5+
## Screenshot
6+
7+
![gopass alfred screenshot](./screenshot.png)
8+
9+
## Installation
10+
11+
Download the latest package from github or build zip file via `make release` in checked out repository.
12+
13+

get_password.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python
2+
3+
import subprocess
4+
import sys
5+
import json
6+
import os
7+
import struct
8+
9+
query = {
10+
"type": "getLogin",
11+
"entry": sys.argv[1]
12+
}
13+
14+
querystr = json.dumps(query)
15+
16+
my_env = os.environ.copy()
17+
my_env['PATH'] = '/usr/local/bin:{}'.format(my_env['PATH'])
18+
19+
process = subprocess.Popen(['/usr/local/bin/gopass', 'jsonapi', 'listen'], stdout=subprocess.PIPE, env=my_env, stdin=subprocess.PIPE)
20+
stdout, stderr = process.communicate(input=struct.pack('I', len(querystr))+querystr)
21+
print(json.loads(stdout[4:].strip())[sys.argv[2]])

gopass_filter.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python
2+
3+
import os
4+
import sys
5+
import logging
6+
import subprocess
7+
import json
8+
import re
9+
10+
logging.basicConfig(filename='/tmp/gopassalfred.log', level=logging.DEBUG)
11+
logging.debug('Debug log started, called with {}'.format(sys.argv))
12+
13+
my_env = os.environ.copy()
14+
my_env['PATH'] = '/usr/local/bin:{}'.format(my_env['PATH'])
15+
16+
process = subprocess.Popen(['/usr/local/bin/gopass', 'list', '-f'], stdout=subprocess.PIPE, env=my_env)
17+
stdout, stderr = process.communicate()
18+
19+
outlist = [
20+
{
21+
"uid": result,
22+
"title": result.split('/')[-1],
23+
"subtitle": '/'.join(result.split('/')[:-1]),
24+
"arg": result,
25+
"match": " ".join(set(re.split('[. /\-]', result))) + ' ' + result,
26+
"autocomplete": result
27+
} for result in stdout.decode('ascii').splitlines()
28+
]
29+
30+
print(json.dumps({'items': outlist}))

icon.png

46.5 KB
Loading

info.plist

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>bundleid</key>
6+
<string>pw.gopass.alfred</string>
7+
<key>category</key>
8+
<string>Productivity</string>
9+
<key>connections</key>
10+
<dict>
11+
<key>0D5132AE-3620-4D5F-BA72-EFD481455463</key>
12+
<array>
13+
<dict>
14+
<key>destinationuid</key>
15+
<string>DB6BF0F4-4C45-43AF-9889-5E5E6CD8048F</string>
16+
<key>modifiers</key>
17+
<integer>0</integer>
18+
<key>modifiersubtext</key>
19+
<string></string>
20+
<key>vitoclose</key>
21+
<false/>
22+
</dict>
23+
<dict>
24+
<key>destinationuid</key>
25+
<string>B1FF35DC-433E-4CCC-9CB3-7C8E1BC532F7</string>
26+
<key>modifiers</key>
27+
<integer>131072</integer>
28+
<key>modifiersubtext</key>
29+
<string>copy username</string>
30+
<key>vitoclose</key>
31+
<false/>
32+
</dict>
33+
</array>
34+
<key>B1FF35DC-433E-4CCC-9CB3-7C8E1BC532F7</key>
35+
<array/>
36+
</dict>
37+
<key>createdby</key>
38+
<string>Martin Hoefling</string>
39+
<key>description</key>
40+
<string>Gopass password access</string>
41+
<key>disabled</key>
42+
<false/>
43+
<key>name</key>
44+
<string>gopass</string>
45+
<key>objects</key>
46+
<array>
47+
<dict>
48+
<key>config</key>
49+
<dict>
50+
<key>concurrently</key>
51+
<false/>
52+
<key>escaping</key>
53+
<integer>68</integer>
54+
<key>script</key>
55+
<string>export PATH=/usr/local/bin:$PATH
56+
57+
if [ -f ~/.gpg-agent-info ] &amp;&amp; [ -n "$(pgrep gpg-agent)" ]; then
58+
source ~/.gpg-agent-info
59+
export GPG_AGENT_INFO
60+
else
61+
eval $(gpg-agent --daemon)
62+
fi
63+
64+
export GPG_TTY="$(tty)"
65+
66+
/usr/local/bin/gopass -c "{query}"
67+
68+
RESULT=$?
69+
70+
osascript -e 'display notification "Copied password for {query} to clipboard" with title "Gopass"'
71+
72+
exit $RESULT</string>
73+
<key>scriptargtype</key>
74+
<integer>0</integer>
75+
<key>scriptfile</key>
76+
<string></string>
77+
<key>type</key>
78+
<integer>0</integer>
79+
</dict>
80+
<key>type</key>
81+
<string>alfred.workflow.action.script</string>
82+
<key>uid</key>
83+
<string>DB6BF0F4-4C45-43AF-9889-5E5E6CD8048F</string>
84+
<key>version</key>
85+
<integer>2</integer>
86+
</dict>
87+
<dict>
88+
<key>config</key>
89+
<dict>
90+
<key>alfredfiltersresults</key>
91+
<true/>
92+
<key>alfredfiltersresultsmatchmode</key>
93+
<integer>2</integer>
94+
<key>argumenttrimmode</key>
95+
<integer>0</integer>
96+
<key>argumenttype</key>
97+
<integer>0</integer>
98+
<key>escaping</key>
99+
<integer>70</integer>
100+
<key>keyword</key>
101+
<string>gp</string>
102+
<key>queuedelaycustom</key>
103+
<integer>3</integer>
104+
<key>queuedelayimmediatelyinitially</key>
105+
<true/>
106+
<key>queuedelaymode</key>
107+
<integer>0</integer>
108+
<key>queuemode</key>
109+
<integer>1</integer>
110+
<key>runningsubtext</key>
111+
<string>loading gopass secrets</string>
112+
<key>script</key>
113+
<string>/usr/local/bin/gopass list -f &gt; /tmp/all
114+
</string>
115+
<key>scriptargtype</key>
116+
<integer>1</integer>
117+
<key>scriptfile</key>
118+
<string>gopass_filter.py</string>
119+
<key>subtext</key>
120+
<string>secret</string>
121+
<key>title</key>
122+
<string>Passwords from gopass</string>
123+
<key>type</key>
124+
<integer>8</integer>
125+
<key>withspace</key>
126+
<true/>
127+
</dict>
128+
<key>type</key>
129+
<string>alfred.workflow.input.scriptfilter</string>
130+
<key>uid</key>
131+
<string>0D5132AE-3620-4D5F-BA72-EFD481455463</string>
132+
<key>version</key>
133+
<integer>2</integer>
134+
</dict>
135+
<dict>
136+
<key>config</key>
137+
<dict>
138+
<key>concurrently</key>
139+
<false/>
140+
<key>escaping</key>
141+
<integer>68</integer>
142+
<key>script</key>
143+
<string>USER=$(./get_password.py {query} username)
144+
osascript -e 'display notification "Copied username '$USER'" with title "Gopass"'
145+
echo $USER | pbcopy</string>
146+
<key>scriptargtype</key>
147+
<integer>0</integer>
148+
<key>scriptfile</key>
149+
<string></string>
150+
<key>type</key>
151+
<integer>0</integer>
152+
</dict>
153+
<key>type</key>
154+
<string>alfred.workflow.action.script</string>
155+
<key>uid</key>
156+
<string>B1FF35DC-433E-4CCC-9CB3-7C8E1BC532F7</string>
157+
<key>version</key>
158+
<integer>2</integer>
159+
</dict>
160+
</array>
161+
<key>readme</key>
162+
<string></string>
163+
<key>uidata</key>
164+
<dict>
165+
<key>0D5132AE-3620-4D5F-BA72-EFD481455463</key>
166+
<dict>
167+
<key>xpos</key>
168+
<integer>80</integer>
169+
<key>ypos</key>
170+
<integer>20</integer>
171+
</dict>
172+
<key>B1FF35DC-433E-4CCC-9CB3-7C8E1BC532F7</key>
173+
<dict>
174+
<key>xpos</key>
175+
<integer>250</integer>
176+
<key>ypos</key>
177+
<integer>160</integer>
178+
</dict>
179+
<key>DB6BF0F4-4C45-43AF-9889-5E5E6CD8048F</key>
180+
<dict>
181+
<key>xpos</key>
182+
<integer>250</integer>
183+
<key>ypos</key>
184+
<integer>20</integer>
185+
</dict>
186+
</dict>
187+
<key>webaddress</key>
188+
<string>https://www.gopass.pw</string>
189+
</dict>
190+
</plist>

screenshot.png

34.3 KB
Loading

0 commit comments

Comments
 (0)