Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
martinhoefling committed Dec 2, 2018
0 parents commit 6d7d278
Show file tree
Hide file tree
Showing 9 changed files with 280 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.1 / 2018-12-03

* initial version
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Martin Hoefling

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
release:
zip -r ../gopass.alfredworkflow *
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Gopass-Alfred

Workflow to interact with gopass from Alfred 3.
Currently querying entries and copying username or password to clipboard is supported.
## Screenshot

![gopass alfred screenshot](./screenshot.png)

## Installation

Download the latest package from github or build zip file via `make release` in checked out repository.


21 changes: 21 additions & 0 deletions get_password.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python

import subprocess
import sys
import json
import os
import struct

query = {
"type": "getLogin",
"entry": sys.argv[1]
}

querystr = json.dumps(query)

my_env = os.environ.copy()
my_env['PATH'] = '/usr/local/bin:{}'.format(my_env['PATH'])

process = subprocess.Popen(['/usr/local/bin/gopass', 'jsonapi', 'listen'], stdout=subprocess.PIPE, env=my_env, stdin=subprocess.PIPE)
stdout, stderr = process.communicate(input=struct.pack('I', len(querystr))+querystr)
print(json.loads(stdout[4:].strip())[sys.argv[2]])
30 changes: 30 additions & 0 deletions gopass_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python

import os
import sys
import logging
import subprocess
import json
import re

logging.basicConfig(filename='/tmp/gopassalfred.log', level=logging.DEBUG)
logging.debug('Debug log started, called with {}'.format(sys.argv))

my_env = os.environ.copy()
my_env['PATH'] = '/usr/local/bin:{}'.format(my_env['PATH'])

process = subprocess.Popen(['/usr/local/bin/gopass', 'list', '-f'], stdout=subprocess.PIPE, env=my_env)
stdout, stderr = process.communicate()

outlist = [
{
"uid": result,
"title": result.split('/')[-1],
"subtitle": '/'.join(result.split('/')[:-1]),
"arg": result,
"match": " ".join(set(re.split('[. /\-]', result))) + ' ' + result,
"autocomplete": result
} for result in stdout.decode('ascii').splitlines()
]

print(json.dumps({'items': outlist}))
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
190 changes: 190 additions & 0 deletions info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>bundleid</key>
<string>pw.gopass.alfred</string>
<key>category</key>
<string>Productivity</string>
<key>connections</key>
<dict>
<key>0D5132AE-3620-4D5F-BA72-EFD481455463</key>
<array>
<dict>
<key>destinationuid</key>
<string>DB6BF0F4-4C45-43AF-9889-5E5E6CD8048F</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
<dict>
<key>destinationuid</key>
<string>B1FF35DC-433E-4CCC-9CB3-7C8E1BC532F7</string>
<key>modifiers</key>
<integer>131072</integer>
<key>modifiersubtext</key>
<string>copy username</string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>B1FF35DC-433E-4CCC-9CB3-7C8E1BC532F7</key>
<array/>
</dict>
<key>createdby</key>
<string>Martin Hoefling</string>
<key>description</key>
<string>Gopass password access</string>
<key>disabled</key>
<false/>
<key>name</key>
<string>gopass</string>
<key>objects</key>
<array>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>68</integer>
<key>script</key>
<string>export PATH=/usr/local/bin:$PATH
if [ -f ~/.gpg-agent-info ] &amp;&amp; [ -n "$(pgrep gpg-agent)" ]; then
source ~/.gpg-agent-info
export GPG_AGENT_INFO
else
eval $(gpg-agent --daemon)
fi
export GPG_TTY="$(tty)"
/usr/local/bin/gopass -c "{query}"
RESULT=$?
osascript -e 'display notification "Copied password for {query} to clipboard" with title "Gopass"'
exit $RESULT</string>
<key>scriptargtype</key>
<integer>0</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>0</integer>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>DB6BF0F4-4C45-43AF-9889-5E5E6CD8048F</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>alfredfiltersresults</key>
<true/>
<key>alfredfiltersresultsmatchmode</key>
<integer>2</integer>
<key>argumenttrimmode</key>
<integer>0</integer>
<key>argumenttype</key>
<integer>0</integer>
<key>escaping</key>
<integer>70</integer>
<key>keyword</key>
<string>gp</string>
<key>queuedelaycustom</key>
<integer>3</integer>
<key>queuedelayimmediatelyinitially</key>
<true/>
<key>queuedelaymode</key>
<integer>0</integer>
<key>queuemode</key>
<integer>1</integer>
<key>runningsubtext</key>
<string>loading gopass secrets</string>
<key>script</key>
<string>/usr/local/bin/gopass list -f &gt; /tmp/all
</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string>gopass_filter.py</string>
<key>subtext</key>
<string>secret</string>
<key>title</key>
<string>Passwords from gopass</string>
<key>type</key>
<integer>8</integer>
<key>withspace</key>
<true/>
</dict>
<key>type</key>
<string>alfred.workflow.input.scriptfilter</string>
<key>uid</key>
<string>0D5132AE-3620-4D5F-BA72-EFD481455463</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>68</integer>
<key>script</key>
<string>USER=$(./get_password.py {query} username)
osascript -e 'display notification "Copied username '$USER'" with title "Gopass"'
echo $USER | pbcopy</string>
<key>scriptargtype</key>
<integer>0</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>0</integer>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>B1FF35DC-433E-4CCC-9CB3-7C8E1BC532F7</string>
<key>version</key>
<integer>2</integer>
</dict>
</array>
<key>readme</key>
<string></string>
<key>uidata</key>
<dict>
<key>0D5132AE-3620-4D5F-BA72-EFD481455463</key>
<dict>
<key>xpos</key>
<integer>80</integer>
<key>ypos</key>
<integer>20</integer>
</dict>
<key>B1FF35DC-433E-4CCC-9CB3-7C8E1BC532F7</key>
<dict>
<key>xpos</key>
<integer>250</integer>
<key>ypos</key>
<integer>160</integer>
</dict>
<key>DB6BF0F4-4C45-43AF-9889-5E5E6CD8048F</key>
<dict>
<key>xpos</key>
<integer>250</integer>
<key>ypos</key>
<integer>20</integer>
</dict>
</dict>
<key>webaddress</key>
<string>https://www.gopass.pw</string>
</dict>
</plist>
Binary file added screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6d7d278

Please sign in to comment.