diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c38fa4e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.idea
+*.iml
diff --git a/Makefile b/Makefile
index 47d205d..9e7b5a4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,2 +1,3 @@
release:
+ rm -f ../gopass.alfredworkflow
zip -r ../gopass.alfredworkflow *
diff --git a/gopass_autotype.py b/gopass_autotype.py
new file mode 100755
index 0000000..2ed6fc3
--- /dev/null
+++ b/gopass_autotype.py
@@ -0,0 +1,78 @@
+#!/usr/bin/env python3
+
+import os
+import subprocess
+import sys
+import json
+import time
+
+my_env = os.environ.copy()
+my_env['PATH'] = '/usr/local/bin:{}'.format(my_env['PATH'])
+
+special_autotype_handlers = {
+ ":tab": lambda: do_stroke(48),
+ ":space": lambda: do_stroke(49),
+ ":enter": lambda: do_stroke(36),
+ ":delay": lambda: time.sleep(1)
+}
+
+
+def do_type(to_type):
+ os.system(f"echo 'tell application \"System Events\" to keystroke \"{to_type}\"' | osascript")
+
+
+def do_stroke(stroke):
+ os.system(f"echo 'tell application \"System Events\" to key code \"{stroke}\"' | osascript")
+
+
+def get_gopass_data_for(query):
+ return subprocess.run(["gopass", "show", "-f", query], stdout=subprocess.PIPE, env=my_env).stdout.decode("utf-8")
+
+
+def parse_gopass_data(data):
+ lines = data.split("\n")
+ password = lines[0]
+ non_empty_lines = list(filter(lambda line: len(line) > 0, lines))
+ lines_splitted = map(lambda line: line.split(": "), non_empty_lines[2:])
+ items_dict = {item[0]: item[1] for item in lines_splitted}
+ items_dict["pass"] = password
+ return items_dict
+
+
+def autotype(items, field):
+ autotype = items.get(field)
+ if autotype is None:
+ return
+ to_type = autotype.split(" ")
+ for word in to_type:
+ handler = special_autotype_handlers.get(word)
+ if handler is None:
+ mapped = items.get(word)
+ do_type(word if mapped is None else mapped)
+ else:
+ handler()
+
+
+def autotype_list(path, parsed):
+ return [
+ {
+ "uid": result,
+ "title": result,
+ "subtitle": path,
+ "arg": f"{path} {result}",
+ "autocomplete": result
+ } for result in parsed.keys()
+ ]
+
+
+action = sys.argv[1]
+path = sys.argv[2].split(" ")
+
+data = get_gopass_data_for(path[0])
+parsed = parse_gopass_data(data)
+autotype_action = "autotype" if len(path) == 1 else path[1]
+
+if action == 'list':
+ print(json.dumps({'items': autotype_list(path[0], parsed)}))
+elif action == 'autotype':
+ autotype(parsed, autotype_action)
diff --git a/info.plist b/info.plist
index 16403ca..c62d69d 100644
--- a/info.plist
+++ b/info.plist
@@ -4,8 +4,6 @@
bundleid
pw.gopass.alfred
- category
- Productivity
connections
0D5132AE-3620-4D5F-BA72-EFD481455463
@@ -31,6 +29,45 @@
+ 1191CB7E-4E88-4BFB-BED0-579A0E6124C8
+
+
+ destinationuid
+ 7B342C01-E6A7-4B26-A83E-D593DA90F4E1
+ modifiers
+ 0
+ modifiersubtext
+
+ vitoclose
+
+
+
+ 2E65F512-65E5-47AD-83AD-EFBB0A988B69
+
+
+ destinationuid
+ 1191CB7E-4E88-4BFB-BED0-579A0E6124C8
+ modifiers
+ 0
+ modifiersubtext
+
+ vitoclose
+
+
+
+ 437FA632-22A0-4FA7-9B33-E0CFAFE9E61A
+
+
+ destinationuid
+ FB6C8961-5CC1-464F-AEF7-A9BCF53F228F
+ modifiers
+ 0
+ modifiersubtext
+
+ vitoclose
+
+
+
B1FF35DC-433E-4CCC-9CB3-7C8E1BC532F7
@@ -91,6 +128,8 @@ exit $RESULT
alfredfiltersresultsmatchmode
2
+ argumenttreatemptyqueryasnil
+
argumenttrimmode
0
argumenttype
@@ -130,7 +169,7 @@ exit $RESULT
uid
0D5132AE-3620-4D5F-BA72-EFD481455463
version
- 2
+ 3
config
@@ -157,6 +196,201 @@ echo $USER | pbcopy
version
2
+
+ config
+
+ alfredfiltersresults
+
+ alfredfiltersresultsmatchmode
+ 2
+ argumenttreatemptyqueryasnil
+
+ argumenttrimmode
+ 0
+ argumenttype
+ 0
+ escaping
+ 70
+ keyword
+ gpa
+ queuedelaycustom
+ 3
+ queuedelayimmediatelyinitially
+
+ queuedelaymode
+ 0
+ queuemode
+ 1
+ runningsubtext
+ loading gopass secrets
+ script
+ /usr/local/bin/gopass list -f > /tmp/all
+
+ scriptargtype
+ 1
+ scriptfile
+ gopass_filter.py
+ subtext
+ secret
+ title
+ Gopass autotype
+ type
+ 8
+ withspace
+
+
+ type
+ alfred.workflow.input.scriptfilter
+ uid
+ 437FA632-22A0-4FA7-9B33-E0CFAFE9E61A
+ version
+ 3
+
+
+ config
+
+ concurrently
+
+ escaping
+ 68
+ script
+ ./gopass_autotype.py autotype "{query}"
+ scriptargtype
+ 0
+ scriptfile
+
+ type
+ 0
+
+ type
+ alfred.workflow.action.script
+ uid
+ FB6C8961-5CC1-464F-AEF7-A9BCF53F228F
+ version
+ 2
+
+
+ config
+
+ alfredfiltersresults
+
+ alfredfiltersresultsmatchmode
+ 2
+ argumenttreatemptyqueryasnil
+
+ argumenttrimmode
+ 0
+ argumenttype
+ 0
+ escaping
+ 70
+ keyword
+ gpf
+ queuedelaycustom
+ 3
+ queuedelayimmediatelyinitially
+
+ queuedelaymode
+ 0
+ queuemode
+ 1
+ runningsubtext
+ loading gopass secrets
+ script
+ /usr/local/bin/gopass list -f > /tmp/all
+
+ scriptargtype
+ 1
+ scriptfile
+ gopass_filter.py
+ subtext
+ secret
+ title
+ gopass type field
+ type
+ 8
+ withspace
+
+
+ type
+ alfred.workflow.input.scriptfilter
+ uid
+ 2E65F512-65E5-47AD-83AD-EFBB0A988B69
+ version
+ 3
+
+
+ config
+
+ concurrently
+
+ escaping
+ 68
+ script
+ ./gopass_autotype.py autotype "{query}"
+ scriptargtype
+ 0
+ scriptfile
+
+ type
+ 0
+
+ type
+ alfred.workflow.action.script
+ uid
+ 7B342C01-E6A7-4B26-A83E-D593DA90F4E1
+ version
+ 2
+
+
+ config
+
+ alfredfiltersresults
+
+ alfredfiltersresultsmatchmode
+ 0
+ argumenttreatemptyqueryasnil
+
+ argumenttrimmode
+ 0
+ argumenttype
+ 0
+ escaping
+ 102
+ keyword
+ list for key
+ queuedelaycustom
+ 3
+ queuedelayimmediatelyinitially
+
+ queuedelaymode
+ 0
+ queuemode
+ 1
+ runningsubtext
+
+ script
+ ./gopass_autotype.py list "{query}"
+ scriptargtype
+ 0
+ scriptfile
+
+ subtext
+
+ title
+
+ type
+ 0
+ withspace
+
+
+ type
+ alfred.workflow.input.scriptfilter
+ uid
+ 1191CB7E-4E88-4BFB-BED0-579A0E6124C8
+ version
+ 3
+
readme
@@ -169,6 +403,34 @@ echo $USER | pbcopy
ypos
20
+ 1191CB7E-4E88-4BFB-BED0-579A0E6124C8
+
+ xpos
+ 255
+ ypos
+ 465
+
+ 2E65F512-65E5-47AD-83AD-EFBB0A988B69
+
+ xpos
+ 85
+ ypos
+ 465
+
+ 437FA632-22A0-4FA7-9B33-E0CFAFE9E61A
+
+ xpos
+ 90
+ ypos
+ 330
+
+ 7B342C01-E6A7-4B26-A83E-D593DA90F4E1
+
+ xpos
+ 430
+ ypos
+ 465
+
B1FF35DC-433E-4CCC-9CB3-7C8E1BC532F7
xpos
@@ -183,7 +445,18 @@ echo $USER | pbcopy
ypos
20
+ FB6C8961-5CC1-464F-AEF7-A9BCF53F228F
+
+ xpos
+ 250
+ ypos
+ 330
+
+ variablesdontexport
+
+ version
+
webaddress
https://www.gopass.pw