Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alfred-pass not working in macOS Monterey 12.3 onwards #29

Open
burneyy opened this issue Mar 25, 2022 · 12 comments
Open

alfred-pass not working in macOS Monterey 12.3 onwards #29

burneyy opened this issue Mar 25, 2022 · 12 comments

Comments

@burneyy
Copy link

burneyy commented Mar 25, 2022

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?

@btaczala
Copy link

btaczala commented Mar 30, 2022

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

@gi4c0
Copy link

gi4c0 commented Apr 7, 2022

@btaczala thanks a lot. Maybe you can make a PR with that?

@btaczala
Copy link

PR here: #30

@chipsenkbeil
Copy link
Collaborator

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.

@emicha
Copy link
Collaborator

emicha commented Aug 7, 2022

@chipsenkbeil Added a change to #30 to accommodate for that.

@btaczala
Copy link

btaczala commented Aug 9, 2022

Applied the change in bfdfaf4

@blakecarrasco
Copy link

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.

@CGenie
Copy link
Owner

CGenie commented Oct 24, 2023

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.

@chipsenkbeil
Copy link
Collaborator

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.

@emicha
Copy link
Collaborator

emicha commented Oct 28, 2023

@chipsenkbeil @CGenie Same here, I use pass across my setup, I will be happy to help.

@CGenie
Copy link
Owner

CGenie commented Oct 30, 2023

@chipsenkbeil @emicha I invited you as collaborators, is this enough?

@chipsenkbeil
Copy link
Collaborator

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants