Jump to content

fwdalpha

Member
  • Posts

    16
  • Joined

  • Last visited

Everything posted by fwdalpha

  1. Yes! thanks for clarifying that, I do not know shell very well, but I will try to implement this in python. I was able to find a 100% working alternative with external triggers, but your method is definitely more correct.
  2. Thanks. That definitely works and I have tried this, but I found in my personal testing that it's difficult to get used to pressing a character to select an option than hitting return like I am used to on Alfred. My goal is to programmatically be able to read that the return key was selected and then immediately return a new json object on that condition. I found this Toggl workflow that has something like this. Setting an external trigger on the input and output with conditionals seems to work for this.
  3. Is there a better way to give a second dropdown menu based on the actioned element than to chain script filters together? Seems very repetitive to have to keep chaining them together for nested selections.
  4. import sys import json import os arg= sys.argv[1] PATH = '*************' def create_json_to_send(title, uid, autocomplete, arg, subtitle, path,type_of_icon='fileicon'): one_item = {"title":title, "uid":uid, "autocomplete":autocomplete, "arg":arg, "subtitle":subtitle, "icon": {"type":type_of_icon, "path":path}} my_json = {"items": [one_item]} final = json.dumps(my_json, indent=2) return final def send_res_back(arg): path = PATH list_of_files = os.listdir(PATH) for each in list_of_files: listed = each.split('.') to_match_name = listed[0] if to_match_name == arg: return path + '/' + each return 'NO Match yet' if __name__ == '__main__': path = send_res_back(arg) returned_json = create_json_to_send('copy', 'copy', 'copy', 'copy', 'copy image to board', path) sys.stdout.write(returned_json) I am currently learning script filters. I understand the power behind it, and am currently trying to make a workflow that takes in an argument that the python script searches a certain directory of images for the name. If it finds the name, it returns the entire path to the file, which I could then use to copy the image to clipboard, or any other action with the full path. One of the things I would like to also do is, that once the image is found, and its according path, the icon shows up as the image itself (which you can see in my code above as the path argument). I've spent a while trying to get this to work, and feel like I am not understanding something fundamental about how script filters work (which is why this is not working). When calling the script, Alfred shows a match in the log, but then nothing else.
  5. Thanks. I am happy to see that is an option!
  6. That new Get Number of Arguments functionality will be useful. I have a solution I can use python to solve for this, but was trying to figure out if Alfred had a way to do it. My script appends X number of argument strings to json file into a certain array. The easy way is to just send the entire argument as one string with each argument delimited by a comma and then split it using python based on that, and append accordingly. The whole idea is that I have to write "$var:1" "$var:2" etc for each possible argument I might give to the python file. So if I had 8 arguments, there would need to be 8 of those already written to store the arguments I gave Alfred. That's way to repetitive. Anyways, the simple fix is to just send it all as one argument (delimited for python to parse) unless you see something I don't.
  7. I am using Alfred to run a bash script after taking X amount of arguments from Alfred (using the split args to vars utility). I am using sys in my Python program which I have added conditionals to deal with any amount of arguments. My question is if anyone knows the best way to use conditionals (or some better method) in Alfred to detect how many arguments were given, and then to be able to use that amount of arguments to execute the python file right now I have to deal with each amount of potential inputs like /pathtofile/myfile.py "$split1" "$split2" /pathtofile/myfile.py "$split1" "$split2" "$split3" /pathtofile/myfile.py "$split1" "$split2" "$split3" "$split4"
  8. Thanks. I am going to check out Keyboard Maestro for that. I am being picky about it just being Int/Int or Double/Double because I want to integrate it as smoothly as possible into my daily use cases without any specific trigger so it would be faster than opening up Alfred and making the quick calculation and copying to clipboard. I'm sure others may be wondering the practical of this, but if you imagine popping open iMessage to send a text and in the middle of a sentence just writing 8.4*6.7 and it immediately puts the answer, sure I could easily have done that in Alfred's calculator, but it does subtract a second or two, which adds up over time. Appreciate the help --- on to Maestro!
  9. Thanks. How would you go about setting that workflow up with a Snippet Trigger? My thought process would be to have it trigger on "/" divide symbol and then look to the left of it and to the right of it to collect the integers to perform the math but I do not know how to get Alfred to do that. Next thought would be to have workflow run a bash or JXA script when it sees "/" and then the script performs the aforementioned operation, but I am not sure how I would go about that. Worst case scenario I use a crude GUI script to press the keys manually, but I would like to avoid that at all costs since its likely to be more computationally laborious.
  10. I have very basic automation that I would like to use a Snipper trigger for with Alfred. I would like to create an automation such that whenever I type any integer followed by a "/" followed by another integer, it triggers a workflow which I would then use to perform said calculation and then paste it back into the space that I previously had been typing into. This seems like what snippets were designed for, but seems I need to use regex for it which it doesn't look like Alfred has functionality for. Anyone have any ideas? I do not want to have to type any other triggers & would like it to be a smooth automation. Thx so much
  11. Your solution worked for what I was trying to do, but I have extended it here (see attached image for more) and I can't come up with a solution. To explain I have a series of downloaded images that I use often and many are connected by a certain topic. So in this case with keyword input "bravo1", the workflow begins by running the JXA script which copies the first item I have hardcoded to my clipboard. Then I am going to use the copied item, so when I paste it, I would not only like a second group of actions to occur but actually for the next item to be copied to the clipboard (by running the given script).... and then this to be able to repeat for each time the current item is pasted. Maybe there is a workaround for this.... there's nothing special about the script other than it allows me to copy an image to clipboard (rather than text) since Alfred's built in features did not allow me to use images with clipboard actions. Any advice? Thanks.
  12. Thanks that helped get me on the right track. As an aside, for anyone else looking to do something similar pay close attention to the quote requirements. In order for the variables to be read properly in this case you must use double quotes to encircle the entire value and then single quotes around the variable (if there's no spaces you can leave it at that {"name": "'$split1'"} , but if there are spaces you need to add another set of double quotes inside the single quotes like this: split1 = "John posted a tweet" {"name": "'"$split1"'"}
  13. Hey, I am also trying to do something similar. I am sending some 2 pieces of data to a webhook. I am delimiting my keyword arguments by comma and have appropriately adjusted that in the split args and vars utility. When I go to the curl input in the bash script, and put in {var:split1} {var:split2} {var:splitn}.... it is not registering the variable and only see's it as a string "{var:split1}" etc. See attached files for explanation.
  14. I would like to create a workflow where I have some first group of actions occur. Then, at some point, I will be pasting the contents of current clipboard item into whatever application I am in. I would then like to have some mechanism to sense that I have pasted from the clipboard (doesn't matter which item.. just that something from the clipboard has been pasted). And then at that point, I would like to simply continue the workflow. So it is simply to wait until an item has been pasted and then to let the rest of the workflow continue. Any ideas?
×
×
  • Create New...