Skip to content

Instantly share code, notes, and snippets.

@marcus-crane
Created April 30, 2025 23:40
Show Gist options
  • Save marcus-crane/ed60b42e4e4d41d42b83f3d72c71b433 to your computer and use it in GitHub Desktop.
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
# #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