Created
April 30, 2025 23:40
-
-
Save marcus-crane/ed60b42e4e4d41d42b83f3d72c71b433 to your computer and use it in GitHub Desktop.
A Popclip script for sending selected text to a Memos (https://github.com/usememos/memos) server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# #popclip | |
# { name: Memos, icon: iconify:si:memory-fill, after: show-result, interpreter: python3 } | |
import json | |
import os | |
import urllib.request | |
print(os.environ) | |
payload = { | |
"state": "NORMAL", | |
"creator": "<you>", | |
"content": os.environ['POPCLIP_TEXT'], | |
"visibility": "PRIVATE" | |
} | |
headers = { | |
"Authorization": f"Bearer <token>", | |
"Content-Type": "application/json" | |
} | |
body = json.dumps(payload).encode('utf8') | |
req = urllib.request.Request("https://example.com/api/v1/memos", headers=headers, data=body) | |
res = urllib.request.urlopen(req) | |
print(f'Received {res.getcode()} from Memos', end='') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment