luxafor-cli
A command-line tool for controlling the Luxafor Flag USB
notification light, built on the luxafor-go
library.
It includes luxafor watch, which mirrors desktop notifications from the D-Bus
session bus onto the Flag (Linux).
Install
go install github.com/MarcMeszaros/luxafor-cli@latest
Or grab a .deb/.rpm from the releases (see Packaging).
On Linux the device needs a udev rule for non-root access — see
Permissions. On macOS and Windows the build uses
hidapi via cgo, so it requires a C toolchain (CGO_ENABLED=1).
Usage
Built with cobra; run luxafor --help (or
luxafor <command> --help) for the full list. Required values are positional;
optional ones are flags.
luxafor red # named-color shortcut
luxafor color 0 128 255 # RGB triple
luxafor color red --led flag # target one bank of LEDs
luxafor black # black = off
luxafor fade green --speed 40
luxafor strobe red --speed 20 --repeat 5
luxafor wave 2 blue -s 30 -r 3
luxafor pattern 5 --repeat 2
luxafor firmware
luxafor watch # mirror D-Bus activity (Linux)
D-Bus watcher (Linux)
luxafor watch mirrors D-Bus session-bus activity onto the Flag. It uses the
modern BecomeMonitor API (not the deprecated eavesdrop=true match) and runs
until interrupted.
A YAML config is required (-c, or ~/.config/luxafor/config.yaml, or the
system default /etc/xdg/luxafor/config.yaml). Everything lives under a
top-level watch key, with one section per source:
watch:
notifications:
Slack:
- name: "*" # any Slack notification
color: magenta
"*":
- name: BUSY
color: red
See docs/watch.md for the full schema, supporting other apps,
and running it as a systemd service.
Permissions (Linux)
By default /dev/hidraw* nodes are root-only. The
.deb/.rpm packages install the udev rule automatically.
To install it manually:
sudo cp packaging/99-luxafor.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules && sudo udevadm trigger
# ensure your user is in the plugdev group, then re-plug the device
Building & testing
The repo uses Task as a runner. With task installed:
task # test + build the CLI (default)
task test # run the test suite
task build # build the CLI into ./bin/luxafor
task clean # remove build artifacts
Plain go works too:
go test ./...
go run . red
Cross-compiling
Linux builds are pure Go; macOS/Windows use hidapi via cgo and need a C
toolchain for the target.
task build:linux # GOOS=linux CGO_ENABLED=0 (pure Go)
task build:windows # GOOS=windows CGO_ENABLED=1, needs a mingw cross-compiler
task build:darwin # GOOS=darwin CGO_ENABLED=1, run on a Mac (Xcode CLT) or with osxcross
Packaging (Linux)
.deb and .rpm packages are built with nfpm
(go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest). They bundle the
CLI, the udev rule, a systemd user unit
for luxafor watch, and a default config.
VERSION=0.1.0 task package # writes dist/*.deb and dist/*.rpm
Installing the package places the udev rule in /usr/lib/udev/rules.d/ and
reloads udev, installs the watch service to /usr/lib/systemd/user/, and writes
a default config to /etc/xdg/luxafor/config.yaml (so watch works before you
create ~/.config/luxafor/config.yaml). Enable the service per user — run
systemctl --user daemon-reload once so your session picks up the freshly
installed unit, then systemctl --user enable --now luxafor-watch.service (see
docs/watch.md).
License
MIT — see LICENSE.