Bleh!
Bleh! is a command-line utility to print images on the MXW01 Bluetooth thermal printer. It supports 1-bit (1bpp) and 4-bit (4bpp) printing, various dithering algorithms, PNG preview output, and direct communication with the printer via BLE.
Features
- Print PNG/JPG images (from file or stdin) in 1bpp or 4bpp mode
- Multiple dithering algorithms (Floyd-Steinberg, Bayer, Atkinson, etc.)
- Query printer status, battery, version, and more
- Output a PNG preview instead of printing (for integration or testing)
- Command-line interface with fine-grained options
- Works on Linux using BlueZ (via go-ble/ble)
Compiling
On a Linux system:
make build
(or go build ./... if you prefer)
Running (recommended: root daemon + unprivileged CLI)
Start the daemon as root:
sudo ./bin/blehd --socket /run/bleh/blehd.sock --group bleh
Then run the CLI as your normal user:
./bin/bleh -s
./bin/bleh -i 100 ./image.png
The daemon restricts socket access via the --group flag. Add your user to that group:
sudo groupadd -r bleh
sudo usermod -aG bleh $USER
# log out and back in
For a permanent setup, install the systemd service (see dist/INSTALL.md).
Usage
bleh [options] <image_path or ->
Options
| Option | Description |
|---|---|
-i, --intensity |
Print intensity (0-100) (default: 80) |
-m, --mode |
Print mode: 1bpp or 4bpp (default: "1bpp") |
-d, --dither |
Dither method: none, floyd, bayer2x2, bayer4x4, bayer8x8, bayer16x16, atkinson, jjn |
-s, --status |
Query printer status |
-b, --battery |
Query battery level |
-v, --version |
Query printer version |
-p, --printtype |
Query print type |
-q, --querycount |
Query internal counter |
-E, --eject |
Eject paper by N lines |
-R, --retract |
Retract paper by N lines |
-o, --output |
Output PNG preview instead of printing. If value is "-", writes PNG to stdout. |
<image_path or -> |
Path to PNG/JPG image to print, or "-" for stdin |
Example
bleh -m 4bpp -d floyd ./myimage.png
Requirements
- Go 1.18+
- BlueZ on Linux (for BLE support)
- Dependencies listed in
go.mod(see source)
License
This project is licensed under the terms of the GNU General Public License v3.0 or later.
Parts of the code were ported from CatPrinterBLE and are licensed under the MIT License.
See the LICENSE file for details.
Disclaimer: While a license was only added after the project’s initial commits, the current license applies retroactively to all previous commits of this repository.
