Jun-09-2020, 10:13 AM
This may be more of a linux question, but I'm working through the Multi-Clipboard project in Automate the Boring Stuff. The code runs perfectly when executed directly from the shell. The keywords/content are stored in the shelf file and can be recalled with the list key word.
-----
#!/usr/bin/env bash
echo "Enter a keyword for the text to be stored"
read ANYTHING
python3.7 /users/patrick/code/python/projects/automation/mcb.pyw $ANYTHING
-----
When I run the list keyword in shell it only returns the original keywords I had previously stored.
Again...might be something for a linux forum, but thought I'd try here first.
Cheers!
#! python3 # mcb.pyw - Saves and loads pieces of text to the clipboard. # Usage: py.exe mcb.pyw save <keyword> - Saves clipbard to keyword. # py.exe mcb.pyw <keyword> - Loads keyword to clipboard. # py.exe mcb.pyw list - Loads all keywords to clipboard. import shelve, pyperclip, sys mcbShelf = shelve.open('mcb') # Save clipboard content. if len(sys.argv) == 3 and sys.argv[1].lower() == 'save': mcbShelf[sys.argv[2]] = pyperclip.paste() elif len(sys.argv) == 2: # List keywords and load content. if sys.argv[1].lower() == 'list': pyperclip.copy(str(list(mcbShelf.keys()))) elif sys.argv[1] in mcbShelf: pyperclip.copy(mcbShelf[sys.argv[1]]) mcbShelf.close()The issue I'm having is executing this with a .command file. When executed from spotlight it should prompt the user for a keyword and append it to the list of keywords in the shelf file. What I've tried are different variations of:
-----
#!/usr/bin/env bash
echo "Enter a keyword for the text to be stored"
read ANYTHING
python3.7 /users/patrick/code/python/projects/automation/mcb.pyw $ANYTHING
-----
When I run the list keyword in shell it only returns the original keywords I had previously stored.
Again...might be something for a linux forum, but thought I'd try here first.
Cheers!