mirror of
https://codeberg.org/icewind/ptouch-api.git
synced 2026-06-03 10:54:07 +02:00
rename to ptouch-remote
This commit is contained in:
parent
9073a9d217
commit
1422f9b8be
12 changed files with 43 additions and 40 deletions
|
|
@ -21,7 +21,7 @@ jobs:
|
|||
mkdir assets
|
||||
for asset in x86_64-unknown-linux-musl aarch64-unknown-linux-musl; do
|
||||
nix build .#$asset
|
||||
cp result/bin/ptouch-api assets/$asset
|
||||
cp result/bin/ptouch-remote assets/$asset
|
||||
done
|
||||
- name: Create release
|
||||
uses: https://code.forgejo.org/actions/forgejo-release@v2.6.0
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
ENV{ID_VENDOR_ID}=="04f9", ENV{ID_MODEL_ID}=="2001|2004|2007|2011|2019|201f|202c|202d|2030|2031|2041|205e|205f|2061|2062|2064|2065|20df|2073|20e0|2074|20e1|20af|2201", MODE="0600" OWNER="ptouch-api"
|
||||
ENV{ID_VENDOR_ID}=="04f9", ENV{ID_MODEL_ID}=="2001|2004|2007|2011|2019|201f|202c|202d|2030|2031|2041|205e|205f|2061|2062|2064|2065|20df|2073|20e0|2074|20e1|20af|2201", MODE="0600" OWNER="ptouch-remote"
|
||||
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -1212,7 +1212,7 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "ptouch-api"
|
||||
name = "ptouch-remote"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"axum",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "ptouch-api"
|
||||
name = "ptouch-remote"
|
||||
version = "0.1.1"
|
||||
edition = "2024"
|
||||
|
||||
|
|
|
|||
33
README.md
33
README.md
|
|
@ -1,11 +1,14 @@
|
|||
# ptouch-api
|
||||
# ptouch-remote
|
||||
|
||||
Simple REST api for Brother P-touch label printers.
|
||||
Web interface and REST api for Brother P-touch label printers.
|
||||
|
||||

|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
You can download pre-built binaries from the
|
||||
[releases page](https://codeberg.org/icewind/ptouch-api/releases) or build it
|
||||
[releases page](https://codeberg.org/icewind/ptouch-remote/releases) or build it
|
||||
yourself using `cargo build`.
|
||||
|
||||
## Configuring
|
||||
|
|
@ -16,7 +19,7 @@ yourself using `cargo build`.
|
|||
# address = "0.0.0.0" # defaults to "127.0.0.1"
|
||||
# port = 1234 # defaults to 7074
|
||||
# you can set it to listen over a unix socket instead.
|
||||
socket = "/run/ptouch-api.sock"
|
||||
socket = "/run/ptouch-remote.sock"
|
||||
```
|
||||
|
||||
In additional to the `listen` configuration, the server will automatically
|
||||
|
|
@ -26,21 +29,21 @@ provided socket.
|
|||
## Usage
|
||||
|
||||
```bash
|
||||
ptouch-api [--config config.toml]
|
||||
ptouch-remote [--config config.toml]
|
||||
```
|
||||
|
||||
## Permissions
|
||||
|
||||
You'll need to either run `ptouch-api` as root or setup a udev rule to change
|
||||
the owner or permissions to allow `ptouch-api` to access the label printer over
|
||||
You'll need to either run `ptouch-remote` as root or setup a udev rule to change
|
||||
the owner or permissions to allow `ptouch-remote` to access the label printer over
|
||||
usb.
|
||||
|
||||
See [51-ptouch-api.rules](./51-ptouch-api.rules) for an example udev rule,
|
||||
See [51-ptouch-remote.rules](./51-ptouch-remote.rules) for an example udev rule,
|
||||
placing this into `/etc/udev/rules.d` and adjusting the username as desired
|
||||
should give the specified user access to the ptouch printer.
|
||||
|
||||
Alternatively you can use
|
||||
[51-ptouch-api-everyone.rules](./51-ptouch-api-everyone.rules) to give all users
|
||||
[51-ptouch-remote-everyone.rules](./51-ptouch-remote-everyone.rules) to give all users
|
||||
on the system access to the label printer.
|
||||
|
||||
## API
|
||||
|
|
@ -97,24 +100,24 @@ needed run the api.
|
|||
|
||||
```nix
|
||||
{
|
||||
inputs.ptouch-api.url = "git+ssh://git@codeberg.org/icewind/ptouch-api.git";
|
||||
inputs.ptouch-remote.url = "git+ssh://git@codeberg.org/icewind/ptouch-remote.git";
|
||||
|
||||
outputs = { self, nixpkgs, ptouch-api }: {
|
||||
outputs = { self, nixpkgs, ptouch-remote }: {
|
||||
nixosConfigurations.my-machine = nixpkgs.lib.nixosSystem {
|
||||
modules =
|
||||
[
|
||||
ptouch-api.nixosModules.default
|
||||
ptouch-remote.nixosModules.default
|
||||
({config, ...}: {
|
||||
# enable the api service and setup the udev rules
|
||||
services.ptouch-api = {
|
||||
services.ptouch-remote = {
|
||||
enable = true;
|
||||
# socket = "/path/for/socket/to/listen"; # defaults to /run/ptouch-api/ptouch-api.sock
|
||||
# socket = "/path/for/socket/to/listen"; # defaults to /run/ptouch-remote/ptouch-remote.sock
|
||||
};
|
||||
# expose the api to the outside world
|
||||
services.nginx = {
|
||||
virtualHosts."ptouch.example.com" = {
|
||||
locations."/" = {
|
||||
proxyPass = "http://unix://${config.services.ptouch-api.socket}";
|
||||
proxyPass = "http://unix://${config.services.ptouch-remote.socket}";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@
|
|||
mill-scale ./. {
|
||||
withOverlays = [(import ./nix/overlay.nix)];
|
||||
extraPaths = [
|
||||
./51-ptouch-api.rules
|
||||
./51-ptouch-remote.rules
|
||||
./web
|
||||
];
|
||||
|
||||
packages = rec {
|
||||
ptouch-api = pkgs: pkgs.ptouch-api;
|
||||
ptouch-remote = pkgs: pkgs.ptouch-remote;
|
||||
};
|
||||
|
||||
crossTargets = [
|
||||
|
|
@ -35,9 +35,9 @@
|
|||
...
|
||||
}: {
|
||||
imports = [./nix/module.nix];
|
||||
config = lib.mkIf config.services.ptouch-api.enable {
|
||||
config = lib.mkIf config.services.ptouch-remote.enable {
|
||||
nixpkgs.overlays = [outputs.overlays.default];
|
||||
services.ptouch-api.package = lib.mkDefault pkgs.ptouch-api;
|
||||
services.ptouch-remote.package = lib.mkDefault pkgs.ptouch-remote;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
BIN
images/dark.png
Normal file
BIN
images/dark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
BIN
images/light.png
Normal file
BIN
images/light.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
|
|
@ -5,14 +5,14 @@
|
|||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.services.ptouch-api;
|
||||
cfg = config.services.ptouch-remote;
|
||||
in {
|
||||
options.services.ptouch-api = {
|
||||
enable = mkEnableOption "Enables the ptouch-api service";
|
||||
options.services.ptouch-remote = {
|
||||
enable = mkEnableOption "Enables the ptouch-remote service";
|
||||
|
||||
socket = mkOption rec {
|
||||
type = types.str;
|
||||
default = "/run/ptouch-api/ptouch-api.sock";
|
||||
default = "/run/ptouch-remote/ptouch-remote.sock";
|
||||
description = "The socket to listen on";
|
||||
};
|
||||
|
||||
|
|
@ -29,17 +29,17 @@ in {
|
|||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
users.users.ptouch-api = {
|
||||
users.users.ptouch-remote = {
|
||||
isSystemUser = true;
|
||||
group = "ptouch-api";
|
||||
group = "ptouch-remote";
|
||||
};
|
||||
users.groups.ptouch-api = {};
|
||||
users.groups.ptouch-remote = {};
|
||||
|
||||
services.udev.packages = [cfg.package];
|
||||
|
||||
systemd.services.ptouch-api = {
|
||||
wants = ["ptouch-api.socket"];
|
||||
after = ["ptouch-api.socket"];
|
||||
systemd.services.ptouch-remote = {
|
||||
wants = ["ptouch-remote.socket"];
|
||||
after = ["ptouch-remote.socket"];
|
||||
environment = {
|
||||
RUST_LOG = cfg.logLevel;
|
||||
};
|
||||
|
|
@ -47,7 +47,7 @@ in {
|
|||
serviceConfig = {
|
||||
Restart = "on-failure";
|
||||
ExecStart = getExe cfg.package;
|
||||
User = "ptouch-api";
|
||||
User = "ptouch-remote";
|
||||
PrivateUsers = true;
|
||||
PrivateTmp = true;
|
||||
ProtectSystem = "strict";
|
||||
|
|
@ -67,12 +67,12 @@ in {
|
|||
RestrictRealtime = true;
|
||||
SystemCallFilter = ["~@reboot" "~@cpu-emulation" "~@obsolete" "~@debug" "~@swap" "~@clock" "~@module"];
|
||||
RestrictNamespaces = ["~cgroup"];
|
||||
RuntimeDirectory = "ptouch-api";
|
||||
RuntimeDirectory = "ptouch-remote";
|
||||
UMask = "0007";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.sockets.ptouch-api = {
|
||||
systemd.sockets.ptouch-remote = {
|
||||
enable = true;
|
||||
wantedBy = ["sockets.target"];
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
final: prev: {
|
||||
ptouch-api = final.callPackage ./package.nix {};
|
||||
ptouch-remote = final.callPackage ./package.nix {};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
version = (fromTOML (readFile ../Cargo.toml)).package.version;
|
||||
in
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "ptouch-api";
|
||||
pname = "ptouch-remote";
|
||||
|
||||
inherit src version;
|
||||
|
||||
|
|
@ -19,8 +19,8 @@ in
|
|||
|
||||
postInstall = ''
|
||||
mkdir -p $out/lib/udev/rules.d/
|
||||
cp ./51-ptouch-api.rules $out/lib/udev/rules.d/
|
||||
cp ./51-ptouch-remote.rules $out/lib/udev/rules.d/
|
||||
'';
|
||||
|
||||
meta.mainProgram = "ptouch-api";
|
||||
meta.mainProgram = "ptouch-remote";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue