Jump to content

Rigonatti

Member
  • Posts

    11
  • Joined

  • Last visited

Posts posted by Rigonatti

  1. I'm probably wrong, but couldn't see that working. 

    since each note has a 'template', the URL would be something like 

     

    open "bear://xcallback-url/add-text?title={arg from filterlist}&tag={the tag relative to arg from filter list}&text={query} on: ${dateap} @ ${timeap}

     

    ie: 

    If I choose "books" from List Filter, I should have an URL with  title=Books and tag=books. 

    But Filter List only allow me to pass 1 parameter per option, right? 

     

    I think I'm going to end up in a need of a script. 

    and back do scratch to learn how to do it. .. 

  2. ops! sorry! 

    I've posted the wrong code version. 

    Re-postiing to make it clear

     

    # Import Sys to sus.stdout
    import sys
    import json
    import requests
    
    # Importing Variables from os
    # import os
    
    
    
    # Connecting to the Short IO API Links:
    
    url = "https://api.short.io/api/links?domain_id=182191&limit=5&dateSortOrder=desc"
    headers = {
        "accept": "application/json",
        "Authorization": "SHORT_API_KEY"
    }
    
    response = requests.get(url, headers=headers)
    
    alfred_items = []
    
    for item in response:
        result = {
            "uid": item["id"],
            "title": item["title"],
            "subtitle": item["originalURL"],
            "arg": item["id"],
        }
    
        alfred_items.append(result)
    
    response = json.dumps({
        "items": alfred_results
    })
    
    
    sys.stdout.write(response)

     

    The debugger: 

     

    [08:16:52.188] Short URL[Script Filter] Queuing argument ''
    [08:16:53.817] Short URL[Script Filter] Script with argv '' finished
    [08:16:53.822] ERROR: Short URL[Script Filter] Code 1: Traceback (most recent call last):
      File "PATH/user.workflow.7D5AFBA8-06E5-449C-8F09-087F9369FB5C/search.py", line 25, in <module>
        "uid": item["id"],
               ~~~~^^^^^^
    TypeError: byte indices must be integers or slices, not str

     

  3.  

     

    So, I ended up getting back to python3, per @vitor recommendation.

    The code now is: 

    import requests
    import json
    
    # Importing Variables from os
    # import os
    
    # Import Sys to sus.stdout
    import sys
    
    # Connecting to the Short IO API Links:
    
    url = "https://api.short.io/api/links?domain_id=182191&limit=5&dateSortOrder=desc"
    headers = {
        "accept": "application/json",
        "Authorization": "SHORT_API_KEY"
    }
    
    response = requests.get(url, headers=headers)
    
    alfred_items = []
    
    for item in response:
        result = {
            "uid": item["id"],
            "title": item["title"],
            "subtitle": item["originalURL"],
            "arg": item["id"],
        }
    
        alfred_items.append(result)
    
    response = json.dumps({
        "items": alfred_results
    })
    
    sys.stdout.write(response)
     
     
     
     
    But, the Debugger keeps getting this message back: 
     
    [17:49:45.183] ERROR: Short URL[Script Filter] Code 1: Traceback (most recent call last):
      File "/Users/thiagorigonatti/Dropbox/Alfred Settings/Alfred.alfredpreferences/workflows/user.workflow.7D5AFBA8-06E5-449C-8F09-087F9369FB5C/search.py", line 24, in <module>
        "links": item["links"],
                 ~~~~^^^^^^^^^
    TypeError: byte indices must be integers or slices, not str
     
    I've tried a few ways to solve it, but couldn't be successful. 
     
    In time. The JSON API response bellow: 
     
    601237775_CleanShot2022-11-24at18_20_20@2x.thumb.png.730639186c54b58f552ec34cc7539c5f.png
     
     
  4. I'm pretty new (and curious) about Python and recent rediscover Alfred.

    I've installed the Alfred Librarys from @deanishe

     

    What I am trying to achieve is to get a list of last links created, when user type shsearch, and when select an specific result, pass the id to the next workflow.  

     

     

    My code is now like this: 

    And i've been trying a lot of ways to parse the results to Script Filter Json format, but couldn't move on.

    So, any tips that can help me will be highly appreciated.

    I'm also attaching my workflow, just in case. 

    Short URL v1.1

     

    import requests
    import sys
    import os
    from workflow import Workflow, ICON_WEB, web
    
    url = "https://api.short.io/api/links?domain_id=182191&limit=5&dateSortOrder=desc"
    
    headers = {
        "accept": "application/json",
        "Authorization": os.getenv('SHORT_API_KEY')
    }
    
    response = requests.get(url, headers=headers)
    response_info =  response.json()
    
    
    def main(wf):
         url = 'https://api.short.io/api/links?domain_id=182191&limit=5&dateSortOrder=desc'
         params = dict(Authorization=os.getenv('SHORT_API_KEY'), format='application/json')
         r = web.get(url, headers=params)
    
         # throw an error if request failed
         # Workflow will catch this and show it to the user
         r.raise_for_status()
    
         # Parse the JSON returned by pinboard and extract the posts
         result = r.json()
         link_list = result['link_list']
    
         # Loop through the returned posts and add an item for each to
         # the list of results for Alfred
         for link in link_list:
             wf.add_item(title=link['title'],
                         subtitle=link['shortURL'],
                         arg=link['id']
                         icon=ICON_WEB)
    
         # Send the results to Alfred as XML
         wf.send_feedback()
    
    if __name__ == u"__main__":
         wf = Workflow()
         sys.exit(wf.run(main))
    

     

  5. I'm creating an Alfred Workflow to allow me to add a line to a note. As an example:
    A note with the tag #books-to-read
    - Getting search results with the #books-to-read
    - Append {query} to the note selected.
     
    I have managed to create an append by running a bash script with the title of a specific note. However, my goal is to filter and show specific tags and notes under it, then append the text based on the user's selection. Consider this example:
     
    - User starts workflow;
    - User see a list of an tag (lets says "#running-notes")
    -User select the "Books" Note
    - User types {query} to be append to the note "Books" under "#running-notes".
     
    Here is the code I'm using to append, right now:
    open "bear://x-callback-url/add-text?title=Books&selected=no&mode=append&new_line=yes&open_note=no&exclude_trashed=yes&new_window=no&show_window=no&edit=yes&timestamp=no&clipboard=no&text=%0A%0A%3E%20($(query}%3A%20 ${title} %20%0A%3E%20Added on: ${dateap} @ ${timeap}"
     
    Does anyone have a clue on how that can be done?
     
    Cheers
     
  6.  Momentum-Workspace-Laucher

     

     A Alfred Workflow to kill any apps that won't be used and open just the only ones you need.  
     Saving CPU/Memory but also helping you to keep focus. 🧘‍♂️

     

    I'm really focused on doing things one at at time and giving full attention  on whatever needs my attention. 
    Living with ADHD for decades, I've learned how to setup my workflow to avoid any disruption on my attention spam. 

     

    That means, closing any app that will not help me to achieve my goals in that moment.

     know that are a few apps that can launch a group of apps (or kill it) based on an interface selections.
    The Question, for me was: how to implement a simple workflow on Alfred (that I use for almost everything during my day) that will kill any apps (saving power and CPU/Memory) and then open only the Apps used for the purpose. 

     

    You can download it here:  Momentum Workspace Launcher

    But here is a spoiler on how it works! 

     

    (Thanks to @Vero who gave me valuable tips to get in to it.)

     

    sm_2022-11-17 19-52-25.png

  7. 8 hours ago, Vero said:

    @Rigonatti This is quite an old thread and Alfred has evolved a lot since then :)

     

    You should be able to do exactly what you want without a single line of code using Alfred's Automation Tasks:

    https://www.alfredapp.com/help/workflows/automations/automation-task/

     

    You can start your workflow with a keyword for work and connect it to the "Launch Apps / Files" object to launch the apps you need for work (and ahem, quit any distracting personal ones if needed ;) )

     

    Do much the same when setting up your personal environment, but use Automation Task (Under Core Automation Tasks > macOS, choose either the Quit Apps or Quit All Apps, with Exceptions) to quit any apps you no longer want active.

    image.png

    Start creating your workflow and, if you need any help, share your workflow-in-progress and we'll be happy to help :)

     

    Hi @Vero 

    Thank you so much for the tips. 

    I've created and workflow using (only) Alfred's Automation Tasks. 

     

     

    I'm glad that you answered so I also included a small thank-you note on the credits mentioning you.

    (Please, let me know if the links are correct).

     

    I'm gonna try to figure out the best language to create a script to build a setup menu that can't customize the 'Workspaces Names'  and also show a list of apps  installed that can't be added to the workspace trough Alfred spotlight. 


    If you have any other suggestion to improve or correct anything. Just let me know. 

     

    Here is the WorkFlow Momentum Workspace Launcher

     

    Txs again, 

     

  8. Hello There,

     

    I'm new on Workflows and know nothing about Ruby.
    So I was wondering if is possible to setup a keyword that can kill  a group of pre-selected apps.
    For example:

     I use a keyword to launch my Work Environment:
       - launch Excel 
       - launch WinWord
       - launch my company web site. 

    When I'm launching my Personal Environment, I want the script or the keyword to: 
      - kill Excel
      - kill Winword
       - Launch my Notes App
     - launch my personal website

    Its that possible? I'm using Alfred5 currently.

    I found Kill Process Workflow great to use, but I can't set to kill multiple process with a single keyword

     

     


      

  9. Greetings everyone! 

     

    For over 8 years, DayOne has added significant value to me by integrating social media, locations, and event tracking features. 

    Also, the interface is kind of bulky, and sometimes I prefer something cleaner like Bear Notes, Stoic Journal , or even a regular TXT file. 

     

    As a result, I created my first workflow to quickly import any text entry into the DayOne App and avoid losing focus.  

    DayOne App doesn't even need to be open as the workflow runs in the background. 

     

    You can download de package here

     

    And, of course,  contact me through GitHub if you have any suggestions or improvements. 

     

    I hope you enjoy it!

     

    See in Action:

     

    dayone-instant-import.gif?raw=true

     

     

×
×
  • Create New...