Add the packagecloud.io/fxkr/weblabel repository and install weblabel
via your package manager. Currently, Debian 8 (x86_64, armhf) and Fedora 25 (x86_64). Contact me if you need more.
Install a tool like ptouch-print that takes a text to print on the command line. At the moment, you'll likely need to compile this yourself. This won't be necessary in the future.
Copy /usr/share/weblabel/config.yml
to /etc/weblabel/config.yml
and edit appropriately. For ptouch-print
, it could look like this:
---
Address: "0.0.0.0:80"
PrintCommand: "/usr/bin/ptouch-print --image {}"
StaticPath: "/usr/share/weblabel/static"
(Re-)start and enable (if needed) weblabel:
systemctl restart weblabel
systemctl enable weblabel
If you use a Brother 2430PC, make sure the switch is in the "E" (not "EL") position.
Note: the API is not stable yet.
Printing text:
curl 'http://localhost:8081/api/v1/printer/print' -H 'Accept: application/json' --data '{"document": {"text":"bar"}}'
Rendering a preview:
curl 'http://localhost:8081/api/v1/renderer/render' -H 'Accept: application/json' --data '{"document": {"text":"bar"}}'
Printing a PNG file:
curl 'http://localhost:8081/api/v1/printer/image' -H 'Accept: application/json' -F 'data={}' -F 'image=@label.png'
You'll need go for the backend and yarn for the frontend.
It's recommended to use a simple image viewer like feh to simulate printing.
The following sections show some useful commands.
Using a real labelprinter would get expensive fast. notify-send
, which shows an OSD, provides a good alternative. Use port 8081 for the backend - the frontend dev server at port 8080 will proxy API requests to there.
Put this in config.yml
:
---
Address: "127.0.0.1:8081"
PrintCommand: "feh {}"
StaticPath: ./static/dist/
export GOPATH="$(pwd)"
Fetching source code and dependencies:
go get github.com/fxkr/weblabel
Running directly:
go run cmd/weblabel/weblabel.go
Running tests:
go test ./...
Compiling a binary:
go build github.com/fxkr/weblabel/cmd/weblabel
Cross compiling for Raspberry Pi:
GOARM=6 GOOS=linux GOARCH=arm go build -v github.com/fxkr/weblabel/cmd/weblabel
cd static
Fetching dependencies:
yarn install
Running a dev webserver:
export PATH="$PATH:$(yarn bin)"
webpack-dev-server