Jump to content

PB-Panda

Member
  • Posts

    3
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

PB-Panda's Achievements

Helping Hand

Helping Hand (3/5)

0

Reputation

  1. That was it @vitor—not sure how I missed that detail before. Thanks! I've been dipping my toes in to regex lately, and it looks interesting. I'm trying to keep things in Python (or another programming language) for portability outside of Alfred in case something catastrophic happened to the company, but I appreciate the suggestion!
  2. Hi @giovanni, Thank you for the example! The issue turned out to be with my Python installation, and I will leave a breadcrumb trail here in case it helps anyone else. 1. After realizing giovanni's Python script did not work but the rest of them in their workflow (zsh scripts) did, I chose to research why Alfred may not be able to run Python in general. I also created a Python script that created a file on the desktop so I could be sure it wasn't a data extraction to Alfred problem. (Also, my Python scripts run fine from the command line or an IDE) 2. Based on this forum post and memory that I may have installed Python on my system with an alternative path variable (before I really knew what I was doing probably), I decided a reinstall of Python might be in order. 3. Followed the steps laid out by this forum post to reinstall Python3. (I already had HomeBrew installed). 4. Alfred now runs Python scripts that are created within the workflow itself. I still cannot run an external script (it appears to not do anything), but at least I have one way to make what I want work. Thanks again! My final Python script: import sys # Constants TEXT_HEADING = "\\text{" TEXT_TRAILING = "}" output = TEXT_HEADING + sys.argv[1] + TEXT_TRAILING sys.stdout.write(output)
  3. Hi Everyone, I am trying to make an Alfred workflow that does the following 1. Is triggered via a keyboard shortcut 2. Takes the currently selected text as input 3. Feeds that text into a Python script to do some basic processing (removing spaces, changing capitalization, etc) 4. Pastes that modified text in place of the selected text Based on the above requirements, I do not think the script filter tool will work well because that requires calling up Alfred's dialog box, but I am having trouble outputting the result of the Python script into something Alfred can work with. I have tried different Python outputs, including the `sys.stdout.write` recommended on other forums. The current Python script (no processing, just testing) in which I tried to use a JSON object is below. I believe JSON objects are only for script filters though, and the return line also appears to do nothing helpful. import sys import json items = { "type": "text", "title": "Result", "arg": "Test_Text" } sys.stdout.write(json.dumps(items)) return json.dumps(items) Is there an easy way to get Alfred to read the Python output, or a different way to achieve what I want. I would prefer Python to do the heavy lifting even though the script is simple because it's just more portable, but a working script is better than nothing obviously. Thanks for your help. Workflow and clipboard modules attached.
×
×
  • Create New...