Jump to content

greghoch

Member
  • Posts

    94
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by greghoch

  1. See our similar discussion here. This should give you a good idea of what some of the options are for achieving this. http://www.alfredforum.com/topic/1164-multiple-steps-with-feedback-in-a-workflow/

     

    Thanks! Great suggestions. I am still not sure how to solve my problem though because of some additional features. I will try to explain my desired setup. This is all based on a database with items and the items have zero, one or multiple attachments. The first script filter shows the items in the database, the second the attachments for the selected item OR directly opens the attachment with there is only one OR reveal the item in the database if there are no attachments. The solutions described in David's link rely on 'valid' = 'no' and use the autocomplete setting. But the problem is that I either want to use a second script filter that shows the attachments (for which I would use valid = no and autocomplete) or want to run an action (if are no or only one attachments or when the user holds down cmd). I don't know how to combine these two because setting valid = no (for the second autocomplete) prevents me from running an action under certain conditions when I want to skip the second filter. Does that make any sense? (below is also a shorter description).

     

    Suggestion: These kind of problems could be solved if it would be possible to connect two script filters and allow a script filter to take input from the last one. It would basically be a script filter at the 'action' stage of the flow diagram taking the arg parameter from the last script filter (or other stuff) as input. That would be a really nice and much lass hacky solution for multi stage script filter.

     

     

     

    Script Filter

    Filter items in database based on query

    When item is selected, do either of the following three actions

         (a) if there are multiple attachments

         ( B) if only one attachment

         © if there are zero attachments

    When item is selected with cmd key pressed, run action ©

     

    Actions

    (a) show list of attachments ('second' script filter)

              run action ( B) if selected, or © if selected with cmd

    ( B) open file attachment (open file action)

    © reveal item in database

     

     

    Edit: my ( b ) and ( c ) were converted but you the smily still works as a reference.

  2. great, I didn't know that!

     

    About the build in function: Does that mean Alfred applies a fuzzy search to the results I feedback and combines the information from the fuzzy search with the ranking based on the learning algorithm to rank my results (decided position 1, 2...)? Does the fuzzy search only looks at the title or also the subtitle? 

  3. Thanks for the great library! It's very helpful for writing workflow.

     

    I also like the simplification but it would be great to still have a `PyAl.Item().fromDictionary()` function in `alp`. I think it's a pretty useful function. Alternatively, it would be nice to have a dictionary as an optional argument for `alp.item(**kwargs)` so that the arguments get set right at the beginning. 

     

    The other common task for workflows is some kind of fuzzy search algorithm, which takes a list and returns the matches or something.

  4. Hi,

     

    this is probably simple but I don't understand how I get the currently selected file(s)? How can I call a script with the {query} set to the path of the currently selected file(s)?

     

    Thanks!

     

    EDIT: It would also be good to pass the path to the current file to a script filter.

  5. 1. Alfred doesn't kill the previous process, it still runs to completion.

    2. Keep the variables in memory? No. You could always write them to a local file though.

    3. Same applies. Whatever is set in the "arg" for the script filter output is passed to the script and is available as {query} but anything else would have to be written to a local file or something and then read in the next piece.

     

    Thanks! I think I will just set the "arg" for the script filter to a json string. That solves the problem and seems like a pretty flexible way to pass an object with multiple elements to the next step...

  6. I will try that and see how it works performance wise. But I guess there is another reason for cacheing: I might want to follow the first script filter with a second script filter showing the attachments of a particular item in the zotero library. That would I mean I have to reopen the database in the second filer, no?

     

    I guess there are a couple of related general question, which I am unsure about:

    - Does Alfred kill the current process/script when a new one starts because the user changes the argument?

    - Is there a way to keep variables in the memory when the user changes the argument and the script is called again?

    - Or between two script filters or a script filter and a script that gets an argument from a script filter? (like a callback function in the script filter that is called when the user selected an item)

  7. I'm not too familiar with Zotero so I could totally off key here but first off we'd have to know where and how Zotero stores its data.

    Is it open? Do they have some form of API?

    With this info it could be feasible.

     

    There are basically two ways to access Zotero's data:

     

    (A) A server API, which is well documented: http://www.zotero.org/support/dev/server_api/v2/start

    Here is also a python library: https://github.com/urschrei/pyzotero

    Maybe there are also libraries for other languages

     

    (b ) Access the local zotero database (read only). It's a SQLite database. The documentation isn't very good but it's easy to open and take a look at. 

    http://www.zotero.org/support/dev/client_coding/direct_sqlite_database_access

    Here is a python project that reads the local database: https://github.com/smathot/qnotero

  8. What type of database is it? I would think it opening the database every time wouldn't really matter. I do it for some of my workflows. It happens so fast you don't really even notice it. I use local SQLite databases for some of my workflows..

     

    It's Zotero's database and I think it's to large to open it every time. My own is over 20 MB right now. The workflow only needs a small subset of that information so that I thought about either creating a cache with separate files for each relevant entry or a database (maybe SQLite) only with the necessary information. In both cases, the cache has to be updated when the Zotero database changed and that is part I am not sure about...

  9. Hi,

     

    I am working on a workflow that uses a large local database and I am not sure about the best way to handle the situation. My script gets called every time the user changes the argument, right? (or I guess there is a small delay to avoid handle changes)

    It doesn't make sense to open the database every time the script is called so my plan was to cache the relevant data using the folder suggested in the "best practice" post (Non-Volatile:~/Library/Application Support/Alfred 2/Workflow Data/[bundle id]). But I still have to update the cache and I am not sure about the best way to handle that. I am working with Python so does it make sense to start a separate thread to handle the cacheing? But this thread ends up getting started multiple times when the user changes the argument. 

     

    Any suggestions about handling this situation would be great.

     

    Thanks!

     

  10. This is great!!

     

    I the search algorithm is not very good though (not sure whether that is Alfred or the workflow). Below are a couple of screenshots.

     

    1) Alfred "ch new" finds the new york times page  http://postimage.org/image/475xpczff/

    2) Alfred "ch new " does not find the new york times page  http://postimage.org/image/3s37c238z/

    3) Alfred "ch newt" does not find the new york times page http://postimage.org/image/whi74jw4n/

    4) Alfred "ch nyt" does not find the page either http://postimage.org/image/cn8n0bhg1/bfc6a68a/

     

    I think they should all find the page...

  11. I'm not sure what exactly it is that you are asking for. Essentially, if you create a workflow that has a Script Filter item, then in the script area, if you make it return/echo back an XML string that matches the format of the first post then that will generate results in the Alfred interface. Similar to searching in Alfred and getting results in the list.. you can make results appear in the list with this XML format.

     

    Thanks, that is already helpful. I though the returned values comes from the different scripting languages.

  12. This is a great workflow! Thanks!

     

    Would it be possible to a) show all unread emails right after entering a keyword and B) reply to email meaning that I select an email and Mail.app open a window where I can write my reply to an email. Together, these two features would be pretty awesome!

  13. Hi,

     

    it would be great if Alfred would work together with Zotero so that Zotero references can be searched from Alfred. How could that be implemented?  The 'search Mail.app' workflow shows the results from a mail search. I am thinking about something similar. What does Alfred need to do that? What scripting would be necessary?

     

    Thanks! 

×
×
  • Create New...