Skip to content

Added MacOs support#47

Open
arnoutzw wants to merge 12 commits intovivier:masterfrom
arnoutzw:master
Open

Added MacOs support#47
arnoutzw wants to merge 12 commits intovivier:masterfrom
arnoutzw:master

Conversation

@arnoutzw
Copy link
Copy Markdown

@arnoutzw arnoutzw commented Feb 1, 2026

Thanks for your work, Added MacOS support together with Claude. Works great for USB & Bluetooth now. Have not been able to regression test linux.

claude and others added 12 commits January 31, 2026 15:06
- Document all CLI tools (phomemo-filter.py, format-checker.py)
- Document CUPS backend and filters architecture
- Add protocol reference for M02/T02 and M110/M220 printers
- Provide detailed macOS Apple Silicon CUPS compatibility analysis
- Include step-by-step macOS installation guide for USB printing
- Document required code changes for full macOS support

https://claude.ai/code/session_01WBHE6TN5hyNn6pNDFTRMis
docs: add comprehensive tool documentation and macOS CUPS guide
This commit implements complete macOS support for phomemo-tools,
including Bluetooth connectivity via IOBluetooth framework.

## Architecture Changes

- Introduced platform abstraction layer for cross-platform support
- Created modular bluetooth/ and usb/ packages with platform-specific
  implementations for Linux (BlueZ/D-Bus) and macOS (IOBluetooth/PyObjC)
- Refactored phomemo.py backend to use the new abstraction layer

## New Files

Backend modules:
- cups/backend/platform.py - Platform detection utilities
- cups/backend/bluetooth/{__init__,base,linux,darwin}.py
- cups/backend/usb/{__init__,base,linux,darwin}.py

Installation:
- scripts/install-macos.sh - Automated macOS installer
- requirements.txt, requirements-{macos,linux}.txt

## macOS Features

- Full Bluetooth discovery via IOBluetoothDevice.pairedDevices()
- RFCOMM connections via IOBluetoothRFCOMMChannel
- USB device detection via PyUSB with /dev/cu.usbmodem* paths
- CUPS integration using /usr/local/lib/cups/ (SIP-friendly)
- Automatic platform detection and backend selection

## Compatibility

- Maintains full backwards compatibility with Linux
- Supports Apple Silicon (arm64) and Intel Macs
- Requires macOS 11.0+ and Python 3.9+

https://claude.ai/code/session_01WBHE6TN5hyNn6pNDFTRMis
Add test build for macOS USB printing support:
- USB-only backend (phomemo-usb.py) without dbus dependency
- macOS install script with proper CUPS paths
- Makefile with check, install, uninstall, and test targets
- Comprehensive README with setup and troubleshooting

This is an experimental build for testing USB connectivity.
Bluetooth is not supported on macOS due to different stack.

https://claude.ai/code/session_01TxFkTuQwkdnPzGU5g57h3C
feat: add full macOS Apple Silicon support with Bluetooth and USB
feat(macos): add experimental USB support for macOS
macOS CUPS sandbox blocks Python filters due to xcode-select checks.
This adds a native C filter that works around the restriction.

Changes:
- Add cups/filter/rastertopm110.c - native C CUPS filter for M110/M220
- Update Makefile to compile C filter on macOS
- Fix bug in Python filters (stdout.write -> file.write)
- Add macos/print-usb.py for direct USB printing
- Add uncompressed PPD files

The C filter links with libcups and libcupsimage, bypassing the
Python sandbox issues on macOS.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add print-bluetooth.py for direct Bluetooth printing on macOS using
IOBluetooth framework via PyObjC.

Features:
- Auto-detect paired Phomemo printers (by name or serial pattern)
- RFCOMM connection with proper chunked data transfer
- Same image processing as USB printing

Usage: python3 print-bluetooth.py <image>

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
macOS TCC privacy restrictions prevent CUPS (running as root) from
accessing Bluetooth directly. This implements a helper daemon approach:

- phomemo-bt-helper.py: Runs as user LaunchAgent with Bluetooth access
- phomemo-bt-socket: CUPS backend that connects to helper via Unix socket
- install-bt-helper.sh: Installation script for the helper daemon

The helper daemon listens on /tmp/phomemo-bt.sock and forwards print
data to Bluetooth printers using IOBluetooth/PyObjC.

Also includes phomemo-bt.m as reference implementation showing direct
IOBluetooth usage (works standalone, blocked by TCC under CUPS).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The CUPS sandbox blocks both system Python (xcode-select issues) and
Homebrew Python (framework library blocked). Switch to pure bash+nc
approach for socket communication with the helper daemon.

Changes:
- Use netcat (nc) for Unix socket communication
- Implement binary protocol header in bash (uint32_be function)
- Handle SIGPIPE (exit 141) as success since data was sent
- Remove Python discovery (can't run in sandbox)

The helper daemon still uses Python with PyObjC for Bluetooth, but runs
outside the CUPS sandbox as a user LaunchAgent.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update all documentation to reflect current feature set:

- docs/README.MD: Complete rewrite with updated macOS section,
  simplified structure, and accurate feature descriptions
- macos/README.md: Full rewrite showing USB, Bluetooth, and CUPS
  support with helper daemon architecture
- cups/README.md: Add proper documentation for filters and backends

Key changes documented:
- Native C filter for macOS (bypasses sandbox)
- Bluetooth helper daemon for CUPS printing
- Direct printing scripts (print-usb.py, print-bluetooth.py)
- Troubleshooting guides for common issues

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Rewrite root README.md to be concise and reference detailed
documentation in subdirectories:
- docs/README.MD for complete documentation
- macos/README.md for macOS-specific guide
- cups/README.md for CUPS driver details

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vivier
Copy link
Copy Markdown
Owner

vivier commented Feb 1, 2026

Hi @arnoutzw,
Thank you for your work.
Is there any way to avoid to introduce C language in this project?
Could you send the PR without merge commits inside?
Could you merge the fix directly in the buggy commit? Same comment for the rewrite of the documentation.
Could you add your Signed-off-by and set you as Author, not Claude.

@arnoutzw
Copy link
Copy Markdown
Author

@vivier Hi Vivier, sorry no the c implementation was necessary to avoid permission problems on MacOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants