Skip to content

lape/todo_printer

Repository files navigation

todo_printer

A Ruby gem for printing TODO items to ESC/POS thermal printers. Print manual todos or sync with Apple Reminders to get physical copies of your tasks.

Features

  • πŸ–¨οΈ Direct thermal printer support - Works with ESC/POS compatible receipt printers
  • πŸ“ Manual todo creation - Create and print todos from the command line
  • 🍎 Apple Reminders integration - Automatically print todos due today from your Reminders app
  • πŸ” Auto-printer detection - Finds connected USB serial printers automatically
  • ⚑ Interactive mode - User-friendly prompts for creating todos
  • 🎯 macOS Quick Actions - Print todos directly from the Services menu
  • ⏰ Automation ready - Set up cron jobs for daily todo printing

Requirements

  • macOS (for Apple Reminders integration)
  • Ruby >= 2.7.0
  • ESC/POS compatible thermal printer (USB)
  • SQLite3 (for Reminders access)

Installation

Clone the repository and install from source:

git clone https://github.com/lape/todo_printer.git
cd todo_printer
bundle install
rake install

This will install the todo_printer command globally on your system.

Configuration

Todo printer supports configuration via ~/.config/todo_printer/config.yml:

# Default printer device
printer_device: /dev/cu.usbserial-12345

# Print settings
print_settings:
  wrap_width: 32
  auto_cut: true
  
# Reminders settings
reminders:
  include_notes: true
  priority_symbols:
    high: "πŸ”΄"
    medium: "🟑"
    low: "🟒"

Copy config.yml.example to get started:

mkdir -p ~/.config/todo_printer
cp config.yml.example ~/.config/todo_printer/config.yml

Usage

Basic Commands

# List available printers
todo_printer --list-printers

# Print a single todo
todo_printer -t "Buy milk" -d "2% organic" --priority "High"

# Interactive mode (prompts for details)
todo_printer

# Print all Apple Reminders due today
todo_printer --reminders

# Use a specific printer
todo_printer -p /dev/cu.usbserial-12345 -t "Todo item"

Examples

Simple todo with priority

todo_printer -t "Team meeting" -d "Discuss Q4 goals" --priority "High"

Output:

================================
        TODO ITEM
================================
Title: Team meeting
Priority: High
--------------------------------
Discuss Q4 goals
--------------------------------
Created: 2025-06-23 14:30
================================

Print today's reminders

todo_printer --reminders

macOS Integration

Quick Action Setup

  1. Open the shortcut.applescript file in Script Editor
  2. Export as an Application or Quick Action
  3. Add to System Preferences > Keyboard > Shortcuts > Services
  4. Now you can print todos from any app's Services menu

Automated Daily Printing

Using Standalone Script with Cron (Recommended)

Due to macOS security restrictions, the best approach for automation is to use a standalone script that can be directly added to Full Disk Access:

  1. Install the standalone script:

    sudo cp print_reminders_standalone.rb /usr/local/bin/print_reminders_todo
    sudo chmod +x /usr/local/bin/print_reminders_todo
  2. Grant Full Disk Access:

    • Open System Settings β†’ Privacy & Security β†’ Full Disk Access
    • Click the lock to make changes
    • Click the "+" button
    • Press Cmd+Shift+G and enter /usr/local/bin/print_reminders_todo
    • Click "Open" to add the script
    • Ensure the checkbox is enabled
  3. Set up cron job:

    # Edit your crontab
    crontab -e
    
    # Add this line to print todos every morning at 8 AM
    0 8 * * * /usr/local/bin/print_reminders_todo >> /tmp/todo_printer.log 2>&1
  4. Verify it's working:

    # Test manually
    /usr/local/bin/print_reminders_todo
    
    # Check logs after cron runs
    tail -f /tmp/todo_printer.log

The standalone script (print_reminders_standalone.rb) is a self-contained version that doesn't require Ruby gems or bundler, making it ideal for system-level automation.

Alternative: Using the Gem with Full Disk Access

If you prefer using the installed gem, you'll need to grant Full Disk Access to both /usr/sbin/cron and your Ruby installation. However, this is more complex and less reliable than the standalone script approach.

Supported Printers

Todo printer works with ESC/POS compatible thermal printers including:

  • Generic POS-80 series printers
  • Epson TM series (TM-T88, TM-T20, etc.)
  • Star Micronics printers with ESC/POS mode
  • Most 58mm and 80mm USB thermal receipt printers

The gem automatically detects printers at:

  • Named printer: POS80_Series_POS80_Printer_USB
  • USB serial devices: /dev/cu.usbserial* and /dev/tty.usbserial*

Development

Setup

# Clone the repository
git clone https://github.com/lape/todo_printer.git
cd todo_printer

# Install dependencies
bundle install

Running Tests

bundle exec rake test

Code Style

This project uses RuboCop for code linting:

# Check code style
bundle exec rubocop

# Auto-fix issues
bundle exec rubocop -a

Architecture

todo_printer/
β”œβ”€β”€ bin/                       # Executable files
β”‚   └── todo_printer          # Main CLI executable
β”œβ”€β”€ lib/                      # Library code
β”‚   β”œβ”€β”€ todo_printer.rb       # Main module file
β”‚   └── todo_printer/         # Module components
β”‚       β”œβ”€β”€ version.rb        # Version constant
β”‚       β”œβ”€β”€ printer.rb        # Core printer functionality
β”‚       β”œβ”€β”€ apple_reminders.rb # Reminders integration
β”‚       β”œβ”€β”€ config.rb         # Configuration management
β”‚       └── cli.rb            # Command-line interface
β”œβ”€β”€ spec/                     # Test files
β”œβ”€β”€ todo_printer.gemspec      # Gem specification
β”œβ”€β”€ Gemfile                   # Development dependencies
└── Rakefile                  # Build tasks

### Core Components

1. **TodoPrinter::Printer** - Core printer functionality:
   - ESC/POS command generation
   - Direct device communication
   - Auto-detection of USB printers
   - Text formatting and wrapping

2. **TodoPrinter::AppleReminders** - Apple Reminders integration:
   - Direct SQLite database access
   - Filters todos due today
   - Priority and list support

3. **TodoPrinter::CLI** - Command-line interface:
   - Argument parsing
   - Interactive mode
   - Configuration management

4. **TodoPrinter::Config** - Configuration handling:
   - YAML configuration files
   - User preferences
   - Default settings

## Contributing

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

### Development Guidelines

- Write tests for new features
- Follow Ruby style conventions (enforced by RuboCop)
- Update documentation as needed
- Add entries to CHANGELOG.md

## Troubleshooting

### Printer not found

If your printer isn't detected automatically:

1. List available printers:
   ```bash
   todo_printer --list-printers
  1. Check USB connections:

    ls /dev/cu.* | grep -E "(usbserial|POS)"
  2. Specify printer manually:

    todo_printer -p /dev/cu.usbserial-12345 -t "Test"

Permission errors with Apple Reminders

Grant Terminal/iTerm access to Reminders:

  1. System Preferences β†’ Security & Privacy β†’ Privacy
  2. Select "Reminders"
  3. Check your terminal application

Printing issues

  • Ensure printer supports ESC/POS commands
  • Check printer is powered on and connected
  • Try printing a test page first
  • Verify character encoding (UTF-8)

License

This project is available under the MIT License. See the LICENSE file for details.

Acknowledgments

  • ESC/POS command reference documentation
  • Apple Core Data timestamp handling techniques
  • Ruby ESC/POS printing community

Links

About

Printing TODO items on ESC/POS thermal printers with Apple Reminders integration

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published