Skip to content
notfatnotfunnyPublic

About

Native Linux Nutri-Score lookup via Open Food Facts

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Librefood

Configurable food scores from Open Food Facts — barcode, search, or camera scan, with editable JSON scoring profiles.

Scoring details: docs/scoring-engine.md.

Build & install

make
sudo make install

Installs to /usr/bin/librefood, /usr/share/applications/org.librefood.Librefood.desktop, and hicolor icons under /usr/share/icons/hicolor/…. Override with PREFIX= / DESTDIR=. Uninstall: sudo make uninstall.

Optional: librefood --barcode 3017620422003 or --page profiles|history|favorites.

Arch Linux

sudo pacman -S rust gtk4 libadwaita pkgconf gstreamer gst-plugins-base
# camera (optional): v4l-utils; usermod -aG video $USER  # then re-login
# phone/libcamera path: libcamera gst-plugin-libcamera pipewire

Alpine Linux

sudo apk add build-base cargo glib-dev pango-dev gdk-pixbuf-dev gtk4.0-dev clang23-dev libadwaita-dev
# camera (phones / CAMSS): see Camera section below
# USB webcam only: sudo apk add v4l-utils; sudo adduser $USER video  # then re-login

Same list: alpine-dependencies.txt.

Camera

Two capture paths:

  1. USB webcams — raw V4L2 (MJPEG / YUYV single-plane). Needs /dev/video* + video group.
  2. Phone cameras (Qualcomm CAMSS, e.g. OnePlus fajita) — GStreamer libcamerasrc (preferred) or pipewiresrc. Raw V4L2 STREAMON usually fails with Broken pipe; librefood detects CAMSS and skips retrying all nodes.

Alpine phone (fajita / postmarketOS)

PipeWire is enough for Scan + Switch camera (Front↔Back). gst-plugin-libcamera is optional.

sudo apk add gst-plugins-base gstreamer-tools \
  pipewire wireplumber xdg-desktop-portal xdg-desktop-portal-gtk
# optional (preferred when packaged): libcamera + libcamerasrc
sudo apk add libcamera libcamera-tools || true
sudo apk add gst-plugin-libcamera || sudo apk add gst-plugins-libcamera || true
sudo adduser $USER video   # then log out / in

Build deps for GStreamer Rust crates (already covered by glib-dev + typically):

sudo apk add gstreamer-dev gst-plugins-base-dev

Verify (pipewire-only OK):

gst-inspect-1.0 pipewiresrc     # required on Alpine without libcamerasrc
gst-inspect-1.0 libcamerasrc    # optional
gst-device-monitor-1.0 Video/Source | head -80   # Front/Back + object.serial
LIBREFOOD_CAMERA_DEBUG=1 ./target/release/librefood
# Scan → expect Back; Switch camera → preview must change (no freeze)

Arch (dev / USB)

sudo pacman -S v4l-utils gstreamer gst-plugins-base
# phone-class / libcamera path:
sudo pacman -S libcamera gst-plugin-libcamera pipewire

Env knobs

Variable Purpose
LIBREFOOD_CAMERA_DEBUG=1 Log probe / backend / STREAMON / chosen facing
LIBREFOOD_CAMERA_DEVICE=/dev/video0 Force a V4L2 node (USB)
LIBREFOOD_CAMERA_BACKEND=auto Default: libcamera first on CAMSS, else V4L2 then gst
…=libcamera / pipewire / v4l2 Force one backend
LIBREFOOD_CAMERA_FACING=back Prefer rear cameras (default). front / any also OK
LIBREFOOD_CAMERA_NAME=… Exact camera id (PipeWire object.serial, libcamera id, or display name)
LIBREFOOD_CAMERA_INDEX=0 Among matching facing cams, pick Nth (0 = primary rear)
LIBREFOOD_CAMERA_ROTATE=auto Upright preview/decode: auto (default), or 0 / 90 / 180 / 270 (CW). Persist with make set-rotate ANGLE=90 → ~/.config/librefood/camera-rotate
LIBREFOOD_CAMERA_MIRROR=auto Mirror after rotate: auto (front only), 1, or 0

On fajita (multiple cams), default is back (largest back area). Preview RGB is uprighted for portrait phones (sensor/api.libcamera.rotation when present, else 90° CW on CAMSS landscape frames) before GTK Picture and barcode decode. Switch camera cycles Back → Wide → Front → … (CAMSS V4L junk filtered). Last choice: ~/.config/librefood/camera-id.

LIBREFOOD_CAMERA_DEBUG=1 ./target/release/librefood
# if preview is still sideways: LIBREFOOD_CAMERA_ROTATE=270
# or: LIBREFOOD_CAMERA_NAME='<object.serial from gst-device-monitor>'

Typed barcodes always work. Window placement follows Fractal/Snapshot patterns: phones (Phosh / ≤1080p short edge, e.g. fajita) maximize into the shell workarea; desktops open a floating ~800×640 window (resizable). Escape force-maximize: LIBREFOOD_NO_FULLSCREEN=1.

License

GPL-3.0-or-later

About

Native Linux Nutri-Score lookup via Open Food Facts

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages