initial add of to-print app

This commit is contained in:
AJ Siegel
2025-12-13 13:09:40 -05:00
commit 519a9c1161
4 changed files with 486 additions and 0 deletions

159
README.md Normal file
View File

@@ -0,0 +1,159 @@
# Print Queue Manager
A simple command-line tool to store things you want to print when you're away from your home network, then print them all at once when you're back.
## Features
- Store file paths and URLs in a print queue
- **Watch folder**: Drop files into `~/to-print` and they'll be printed automatically
- Print all pending items with a single command
- Track what's been printed and what's still pending
- Works with your default macOS printer
## Requirements
- Python 3.6+
- macOS (uses `lp` command for printing)
- `curl` (for downloading URLs)
## Usage
### Two ways to queue items
**Method 1: Manually add items to the queue**
Add a local file:
```bash
./print_queue.py add /path/to/document.pdf
./print_queue.py add ~/Downloads/invoice.pdf --name "Monthly Invoice"
```
Add a URL:
```bash
./print_queue.py add https://example.com/article.html
./print_queue.py add https://example.com/page.html --name "Important Article"
```
**Method 2: Use the watch folder (simpler!)**
Just drop files into `~/to-print`:
```bash
cp ~/Downloads/document.pdf ~/to-print/
mv ~/Desktop/receipt.pdf ~/to-print/
```
The watch folder accepts: PDF, TXT, JPG, PNG, GIF, DOC, DOCX, HTML, and PS files.
### List items in the queue
Show pending items:
```bash
./print_queue.py list
```
Show all items (including already printed):
```bash
./print_queue.py list --all
```
### Print all pending items
Print everything in the queue:
```bash
./print_queue.py print
```
Preview what would be printed (dry run):
```bash
./print_queue.py print --dry-run
```
### Remove items from queue
Remove a specific item by ID:
```bash
./print_queue.py remove 3
```
Clear all printed items from the queue:
```bash
./print_queue.py clear
```
## How it works
**Manual queue:**
1. When you're away from your home network, use `add` to store items in the queue
2. The queue is stored in `queue.json` in this directory
3. When you're back on your home network, run `print` to print everything
4. Items are marked as printed but stay in the queue
5. Use `clear` to remove printed items when you're done
**Watch folder:**
1. Drop any files into `~/to-print` whenever you want
2. When you run `print`, all files in the folder are printed
3. After printing, files are moved to `~/to-print/printed/` to avoid reprinting
4. You can delete or keep the printed files - they won't be reprinted
## Examples
**Using the watch folder (easiest):**
```bash
# Away from home - just drop files in the folder
cp ~/Downloads/receipt.pdf ~/to-print/
cp ~/Desktop/ticket.pdf ~/to-print/
# Back home - check what's ready
./print_queue.py list
# Print everything
./print_queue.py print
```
**Using manual queue (for URLs or tracking):**
```bash
# Away from home - add items to queue
./print_queue.py add ~/Downloads/receipt.pdf
./print_queue.py add https://github.com/user/repo/blob/main/README.md --name "GitHub README"
# Back home - check what's queued
./print_queue.py list
# Print everything
./print_queue.py print
# Later, clean up printed items
./print_queue.py clear
```
**Mix both methods:**
```bash
# Add URLs to queue
./print_queue.py add https://example.com/article.html
# Drop files in folder
cp ~/Downloads/*.pdf ~/to-print/
# Print everything at once (queue + folder)
./print_queue.py print
```
## Tips
- **Watch folder is the easiest**: Just drop files into `~/to-print` - no commands needed until you're ready to print
- File paths are converted to absolute paths, so they'll work even if you change directories
- URLs are downloaded and sent directly to the printer
- For better web page printing, consider saving the page as PDF first, then dropping it in the watch folder
- Use `--name` to give items friendly names instead of long file paths or URLs
- Printed files from the folder are moved to `~/to-print/printed/` - check there if you need to reprint something
## Troubleshooting
**"File not found" error**: Make sure the file path is correct and the file exists
**Printing fails**:
- Check that your printer is set up and `lpstat -p -d` shows your default printer
- Make sure you're connected to the network where your printer is available
- For URLs, ensure you have internet connectivity
**Permission denied**: Make sure the script is executable with `chmod +x print_queue.py`