Jump to content

"Alfred filters results" gives empty list


Recommended Posts

I'm working on a script to play music using MPD. I want to list available albums and have Alfred filter them rather than doing the filtering myself in a script filter. But when I check the "Alfred filters results" check box, the result is an empty list regardless of what I type:

Screen Shot 2017-03-07 at 5.11.36 PM.png

 

If, on the other hand, I uncheck that box, I get a list of albums as expected, but I can't type to filter them:

Screen Shot 2017-03-07 at 5.12.14 PM.png

 

Here's my code, in Python. It's really not very complicated:

from __future__ import unicode_literals
from __future__ import print_function

import json
import os
import subprocess
import sys

MUSIC_DIR = '/Users/Shared/iTunes/iTunes Media/Music'
FIND_CMD = [
    '/usr/local/bin/mpc', 'list', 'album'
]


def make_item(album_name):
    return dict(
        title=album_name,
        uid=album_name,
        valid=True,
        arg=json.dumps({'album': album_name}),
        icon='icon.png',
        autocomplete=album_name,
    )


def main():
    print(json.dumps({
        'items': [
            make_item(item)
            for item in subprocess.check_output(FIND_CMD).decode('utf-8').split('\n')
            if item.strip()
        ]
    }))


if __name__ == '__main__':
    sys.exit(main())

 

Can anyone tell me what I might be doing wrong?

Edited by valrus
Moving images to better locations inline
Link to comment

I figured it out. The problem is that I was triggering the script filter with a hotkey, and I had incorrectly chosen "Pass through to workflow" rather than "Show Alfred" as the Action.

 

I'm not totally clear on why this matters; since my script filter doesn't actually use its arguments when "Alfred filters results" is checked, why should it matter if I pass something in from the hotkey? If someone can explain that, it might help my understanding. But my main problem is solved.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...