diff --git a/.gitignore b/.gitignore index f3097ab..a82618d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ password +dist +password_darwin_amd64 +PasswordGenerator.alfredworkflow diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..82a6236 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "alfred-workflow/lib"] + path = alfred-workflow/lib + url = https://github.com/deanishe/alfred-workflow.git diff --git a/Makefile b/Makefile index 774928e..98810da 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,13 @@ publish: bash golang.sh workflow: - cp password_darwin_amd64 password - zip -9 -j PasswordGenerator.alfredworkflow alfred-workflow/* password + mkdir -p dist + cp -r password_darwin_amd64 \ + alfred-workflow/exec.py \ + alfred-workflow/icon.png \ + alfred-workflow/info.plist \ + alfred-workflow/lib/workflow \ + dist + echo -n $(shell git describe --tags --exact-match) > dist/version + cd dist && zip -r -9 ../PasswordGenerator.alfredworkflow * github-release upload --user luzifer --repo password --tag $(shell git describe --tags --exact-match) --name PasswordGenerator.alfredworkflow --file PasswordGenerator.alfredworkflow diff --git a/alfred-workflow/F8CBCF9B-3B33-400E-B6AD-6B8500938BA4.png b/alfred-workflow/F8CBCF9B-3B33-400E-B6AD-6B8500938BA4.png deleted file mode 100644 index 32c10c2..0000000 Binary files a/alfred-workflow/F8CBCF9B-3B33-400E-B6AD-6B8500938BA4.png and /dev/null differ diff --git a/alfred-workflow/History.md b/alfred-workflow/History.md deleted file mode 100644 index 14e1522..0000000 --- a/alfred-workflow/History.md +++ /dev/null @@ -1,9 +0,0 @@ -# 1.2.0 / 2017-09-22 - - * Update password utility from github - * Stripping newlines from the password - * Updated password to v.1.2.2 - * Updated password tool - * Prevent generation of passwords with long duration - * Migrated to Luzifer/password backed password generation - * Added README diff --git a/alfred-workflow/Makefile b/alfred-workflow/Makefile deleted file mode 100644 index ef6e419..0000000 --- a/alfred-workflow/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -compress: - curl -sSLfo ./password https://github.com/Luzifer/password/releases/download/v1.4.0/password_darwin_amd64 - chmod +x ./password - rm -rf *.pyc PasswordGenerator.alfredworkflow /tmp/password_master_darwin-amd64.zip /tmp/password - zip -9 PasswordGenerator.alfredworkflow * -x PasswordGenerator.alfredworkflow Makefile diff --git a/alfred-workflow/README.markdown b/alfred-workflow/README.markdown deleted file mode 100644 index a710cff..0000000 --- a/alfred-workflow/README.markdown +++ /dev/null @@ -1,11 +0,0 @@ -# Alfred2 Password Generator - -## Installation - -* Ensure your Alfred 2 have the Powerpack enabled -* Download [PasswordGenerator.alfredworkflow](https://github.com/Luzifer/alfred-pwdgen/blob/master/PasswordGenerator.alfredworkflow?raw=true) -* Open downloaded file - the workflow will install itself - -## Patches - -Please don't republish this workflow but fork it and send me a pull request for your changes. I'll republish the workflow at it's current locations. diff --git a/alfred-workflow/exec.py b/alfred-workflow/exec.py new file mode 100644 index 0000000..5ea062e --- /dev/null +++ b/alfred-workflow/exec.py @@ -0,0 +1,45 @@ +# encoding: utf-8 + +import subprocess +import sys +from workflow import Workflow, ICON_WEB, web + + +def main(wf): + password_length = 20 + use_special = False + + if len(wf.args): + for arg in wf.args[0].split(): + if arg.isdigit(): + password_length = int(arg) + elif arg == 's': + use_special = True + + if password_length < 5 or password_length > 256: + wf.add_item(title="Password length out of bounds", + subtitle="Please use a reasonable password length between 5 and 256") + wf.send_feedback() + return 1 + + command = ["./password_darwin_amd64", "get", "-l", str(password_length)] + if use_special: + command.append("-s") + result = subprocess.check_output(command).strip() + + wf.add_item(title=result, arg=result) + wf.send_feedback() + + return 0 + + +if __name__ == "__main__": + wf = Workflow(update_settings={ + 'github_slug': 'Luzifer/password', + }) + + if wf.update_available: + # Download new version and tell Alfred to install it + wf.start_update() + + sys.exit(wf.run(main)) diff --git a/alfred-workflow/feedback.py b/alfred-workflow/feedback.py deleted file mode 100755 index 8a7876f..0000000 --- a/alfred-workflow/feedback.py +++ /dev/null @@ -1,47 +0,0 @@ -#author: Peter Okma -import xml.etree.ElementTree as et - - -class Feedback(): - """Feeback used by Alfred Script Filter - - Usage: - fb = Feedback() - fb.add_item('Hello', 'World') - fb.add_item('Foo', 'Bar') - print fb - - """ - - def __init__(self): - self.feedback = et.Element('items') - - def __repr__(self): - """XML representation used by Alfred - - Returns: - XML string - """ - return et.tostring(self.feedback) - - def add_item(self, title, subtitle="", arg="", valid="yes", autocomplete="", icon="icon.png"): - """ - Add item to alfred Feedback - - Args: - title(str): the title displayed by Alfred - Keyword Args: - subtitle(str): the subtitle displayed by Alfred - arg(str): the value returned by alfred when item is selected - valid(str): whether or not the entry can be selected in Alfred to trigger an action - autcomplete(str): the text to be inserted if an invalid item is selected. This is only used if 'valid' is 'no' - icon(str): filename of icon that Alfred will display - """ - item = et.SubElement(self.feedback, 'item', uid=str(len(self.feedback)), - arg=arg, valid=valid, autocomplete=autocomplete) - _title = et.SubElement(item, 'title') - _title.text = title - _sub = et.SubElement(item, 'subtitle') - _sub.text = subtitle - _icon = et.SubElement(item, 'icon') - _icon.text = icon diff --git a/alfred-workflow/info.plist b/alfred-workflow/info.plist index edeaeb8..896ac2f 100644 --- a/alfred-workflow/info.plist +++ b/alfred-workflow/info.plist @@ -3,7 +3,7 @@ bundleid - me.knut.pwd + io.luzifer.pwd category Tools connections @@ -17,6 +17,8 @@ 0 modifiersubtext + vitoclose + @@ -37,17 +39,23 @@ clipboardtext {query} + transient + type alfred.workflow.output.clipboard uid F417810A-4CC7-4844-9B6E-DA2D6B40543C version - 0 + 2 config + alfredfiltersresults + + argumenttrimmode + 0 argumenttype 1 escaping @@ -65,38 +73,17 @@ runningsubtext Generating password... script - import subprocess, sys -from feedback import Feedback - -password_length = 20 -use_special = False - -for arg in '{query}'.split(): - if arg.isdigit(): - password_length = int(arg) - elif arg == 's': - use_special = True - -if password_length < 5 or password_length > 128: - fb = Feedback() - fb.add_item(title="Password length out of bounds", subtitle="Please use a reasonable password length between 5 and 128") - print fb - sys.exit(1) - -command = ["./password", "get", "-l", str(password_length)] -if use_special: - command.append("-s") -result = subprocess.check_output(command).strip() - -fb = Feedback() -fb.add_item(title=result, arg=result) -print fb + python exec.py "$1" + scriptargtype + 1 + scriptfile + subtext Generates a secure password with <n> length title Password Generator type - 3 + 0 withspace @@ -105,7 +92,7 @@ print fb uid F8CBCF9B-3B33-400E-B6AD-6B8500938BA4 version - 0 + 2 readme @@ -114,11 +101,15 @@ print fb F417810A-4CC7-4844-9B6E-DA2D6B40543C + xpos + 700 ypos 170 F8CBCF9B-3B33-400E-B6AD-6B8500938BA4 + xpos + 300 ypos 170 diff --git a/alfred-workflow/lib b/alfred-workflow/lib new file mode 160000 index 0000000..39241c1 --- /dev/null +++ b/alfred-workflow/lib @@ -0,0 +1 @@ +Subproject commit 39241c12cff55dd94cd001c32de2e319a71a6e66