alfred-pass
alfred-pass copied to clipboard
alfred-pass not working in macOS Monterey 12.3 onwards
As of macOS Monterey 12.3, python2 (i.e. the binary /usr/bin/python
) has been removed from new macOS installations causing the Alfred integration not to work anymore.
Any idea how best to proceed to circumvent that? Migrate the code to python3?
Hi,
Make sure that you have python3 installed as MacOS 12.3 removed python. (I've installed python3 with brew)
Then replace pass-filter.py
script with:
#!/usr/bin/env python3
import fnmatch
import os
import sys
import re
# import string
QUERY = sys.argv[1]
HOME = os.environ['HOME']
PASS_DIR = os.environ.get('PASSWORD_STORE_DIR', os.path.join(HOME, '.password-store/'))
# TODO: list_passwords creates cache of passwords for first time
def list_passwords():
ret = []
for root, _, filenames in os.walk(PASS_DIR):
for filename in fnmatch.filter(filenames, '*.gpg'):
ret.append(os.path.join(root, filename.replace('.gpg','')).replace(PASS_DIR, ''))
return sorted(ret, key=lambda s: s.lower())
def search_passwords(query):
ret = []
passwords = list_passwords()
regex = ".*{}.*".format(query)
for password in passwords:
if re.match(regex, password):
ret.append(password)
return ret
def xmlize_items(items, query):
items_a = []
for item in items:
list = item.split("/", 1)
name = list[-1]
path = item if len(list) == 2 else ""
complete = item
if item.lower().startswith(query.lower()):
i = item.find("/", len(query))
if i != -1:
complete = item[:(i+1)]
items_a.append("""
<item uid="%(item)s" arg="%(item)s" autocomplete="%(complete)s">
<title>%(name)s</title>
<subtitle>%(path)s</subtitle>
</item>
""" % {'item': item, 'name': name, 'path': path, 'complete': complete})
return """
<?xml version="1.0"?>
<items>
%s
</items>
""" % '\n'.join(items_a)
items = search_passwords(QUERY)
print (xmlize_items(items, QUERY))
(my path for filter script is /Users/XXXXXX/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.08300DF9-3BE9-497B-80AB-D35A7C5E03CC
And in workflow edit pass script filter
and change
python pass-filter.py "{query}"
to
/usr/local/bin/python3 pass-filter.py "{query}"
Hope this helps
@btaczala thanks a lot. Maybe you can make a PR with that?
PR here: https://github.com/CGenie/alfred-pass/pull/30
As a heads up, I just updated to Mac OS 12.4 from 11.6 and the above worked, but. my Python was found in /usr/bin/python3
, so I needed to edit pass script filter
with that location instead of /usr/local/bin/python3
.
@chipsenkbeil Added a change to https://github.com/CGenie/alfred-pass/pull/30 to accommodate for that.
Applied the change in bfdfaf4942ab66f137bcdf6f38ccabe5cfdfbb01
After upgrading to mac os 14.0 sonoma my pass workflow stopped working.
with python3 installed via brew the binary was found in /opt/homebrew/bin/python3
I replaced the binary location within the alfred script node and then all was good.
Hello, thanks for contributing to fixing this. Would someone want to take over the project? I currently don't own a Mac and don't plan to, but it seems this plugin is useful for people.
Hello, thanks for contributing to fixing this. Would someone want to take over the project? I currently don't own a Mac and don't plan to, but it seems this plugin is useful for people.
Sure, I can take it on. I use it across a series of M1 Macs at this point, both personal and work.
@chipsenkbeil @CGenie Same here, I use pass across my setup, I will be happy to help.
@chipsenkbeil @emicha I invited you as collaborators, is this enough?
@chipsenkbeil @emicha I invited you as collaborators, is this enough?
I accepted it. I can check this weekend to see if some fixes or PRs can be merged in with this access. Maybe @emicha can get to it before I can.