Skip to content

Commit

Permalink
Prefix all env vars with A_
Browse files Browse the repository at this point in the history
  • Loading branch information
deafmute1 committed Jan 16, 2025
1 parent d9b90a1 commit 7361b1b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
10 changes: 5 additions & 5 deletions workflow/alfred-linkwarden.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}

def lw_url() -> str:
return os.environ['LW_URL'].rstrip('/')
return os.environ['A_LW_URL'].rstrip('/')

def get_links(query: str|None, collection_id: str|None = None):
params = {
Expand All @@ -26,20 +26,20 @@ def get_links(query: str|None, collection_id: str|None = None):
if collection_id is not None: params['collectionId'] = collection_id
return requests.get(
url=f"{lw_url()}/api/v1/links",
headers={"Authorization": f"Bearer {os.environ['LW_API_KEY']}"},
headers={"Authorization": f"Bearer {os.environ['A_LW_API_KEY']}"},
params=params
)

def delete_link(link_id: str):
return requests.delete(
url=f"{lw_url()}/api/v1/links/{link_id}",
headers={"Authorization": f"Bearer {os.environ['LW_API_KEY']}"},
headers={"Authorization": f"Bearer {os.environ['A_LW_API_KEY']}"},
)

def get_all_collections():
return requests.get(
url=f"{lw_url()}/api/v1/collections",
headers={"Authorization": f"Bearer {os.environ["LW_API_KEY"]}"},
headers={"Authorization": f"Bearer {os.environ["A_LW_API_KEY"]}"},
)

def query_json_to_workflow_item(response: requests.Response):
Expand Down Expand Up @@ -123,7 +123,7 @@ def in_venv():
return (hasattr(sys, 'real_prefix') or
(hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix))
if not in_venv():
env_loc = os.environ.get("ENV_LOC", "./env")
env_loc = os.environ.get("A_ENV_LOC", "./env")
if os.path.isdir(env_loc):
shutil.rmtree(env_loc)
subprocess.run(["bash", "./helper.sh"])
Expand Down
10 changes: 5 additions & 5 deletions workflow/helper.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash
set -a # export all vars following, including activation script
ENV_LOC="./env"
if [ ! -d "$ENV_LOC" ]; then
/usr/bin/env python3 -m venv "$ENV_LOC"
source "${ENV_LOC}/bin/activate"
A_ENV_LOC="./env"
if [ ! -d "$A_ENV_LOC" ]; then
/usr/bin/env python3 -m venv "$A_ENV_LOC"
source "${A_ENV_LOC}/bin/activate"
pip3 install -r ./requirements.txt
fi
. "${ENV_LOC}/bin/activate"
. "${A_ENV_LOC}/bin/activate"
set +a
python ./alfred-linkwarden.py "$@"
22 changes: 10 additions & 12 deletions workflow/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ You can search/display a collection via a custom keyword.
<key>0764D263-0FD7-4BA1-B04C-99673D62C89D</key>
<dict>
<key>xpos</key>
<real>515</real>
<real>500</real>
<key>ypos</key>
<real>430</real>
</dict>
Expand All @@ -588,7 +588,7 @@ You can search/display a collection via a custom keyword.
<key>126EF3B6-E7CB-4C32-BB88-B7CAF26DAFA5</key>
<dict>
<key>xpos</key>
<real>555</real>
<real>575</real>
<key>ypos</key>
<real>245</real>
</dict>
Expand Down Expand Up @@ -627,25 +627,25 @@ You can search/display a collection via a custom keyword.
<key>note</key>
<string>Search a specific collection with a keyword</string>
<key>xpos</key>
<real>280</real>
<real>260</real>
<key>ypos</key>
<real>225</real>
<real>240</real>
</dict>
<key>C3938C43-F374-46D7-9C55-3200430ED8C3</key>
<dict>
<key>xpos</key>
<real>280</real>
<real>240</real>
<key>ypos</key>
<real>110</real>
<real>105</real>
</dict>
<key>CCFFCA17-1963-4E36-9935-1E463BA63F05</key>
<dict>
<key>note</key>
<string>delete link</string>
<key>xpos</key>
<real>545</real>
<real>565</real>
<key>ypos</key>
<real>75</real>
<real>90</real>
</dict>
<key>F1F713A4-7DB9-4D20-87CB-D3AD60341D02</key>
<dict>
Expand Down Expand Up @@ -676,7 +676,7 @@ You can search/display a collection via a custom keyword.
<key>type</key>
<string>textfield</string>
<key>variable</key>
<string>LW_API_KEY</string>
<string>A_LW_API_KEY</string>
</dict>
<dict>
<key>config</key>
Expand All @@ -697,11 +697,9 @@ You can search/display a collection via a custom keyword.
<key>type</key>
<string>textfield</string>
<key>variable</key>
<string>LW_URL</string>
<string>A_LW_URL</string>
</dict>
</array>
<key>variablesdontexport</key>
<array/>
<key>version</key>
<string>1.4</string>
<key>webaddress</key>
Expand Down

0 comments on commit 7361b1b

Please sign in to comment.