Created
March 20, 2026 21:35
-
-
Save metrafonic/1cee3978f5cc949e1766e32def5eaef9 to your computer and use it in GitHub Desktop.
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
| #!/usr/bin/env python3 | |
| import sys | |
| import os | |
| import RNS | |
| import LXMF | |
| from datetime import datetime | |
| MSG_FILE = sys.argv[1] | |
| PRINTER = "/dev/usb/lp0" # adjust as needed | |
| message = LXMF.LXMessage.unpack_from_file(open(MSG_FILE, "rb")) | |
| content = message.content_as_string() | |
| sender = RNS.prettyhexrep(message.source_hash) | |
| time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") | |
| with open(PRINTER, "wb") as p: | |
| p.write(f""" | |
| ============================== | |
| LXMF MESSAGE | |
| ------------------------------ | |
| {time} | |
| From: {sender} | |
| {content} | |
| ============================== | |
| \n\n""".encode()) | |
| p.write(b'\x1d\x56\x00') # full cut | |
| os.remove(MSG_FILE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment