Nothing Special   »   [go: up one dir, main page]

Skip to content

hongquan/CoBang

Repository files navigation

CoBang

https://madewithlove.now.sh/vn?heart=true&colorA=%23ffcd00&colorB=%23da251d

A missing native QR Code and barcode scanner application for Linux desktop.

CoBang can scan barcode, QR code from webcam or static image, local or remote.

In the future, it will support generating QR code and running on Linux phones.

Name

It is "Cỏ bàng" (Lepironia articulata), in Vietnamese. This plant is used for making handicraft which has pattern like QR code.

Motivation

QR codes are more and more widely used in daily life, even in developing countries like Việt Nam. While there already are lot of QR code scanner apps for mobile phones, very few exist for Linux desktop. All don't satisfy me in some aspects:

  • QtQR:
    • Pretty old code.
    • Its integration of other library is not good: cannot embed webcam video into its window.
    • Depend on X Window System.
  • Some Electron-based programs in GitHub:
    • Using Electron stack, which is unnecessary fat [1].
    • The UI doesn't look native.
    • Depend on X Window System.

X-dependence is a major concern because I want to boost up the migration of Linux desktop from old X Window System to more modern Wayland. Those X-dependent applications drag the transition, not only does it make the OS installation big (have to include an X server next to Wayland compositor), but also waste time fixing bugs of X - Wayland cooperation.

So I decide to build CoBang, a new, native Linux application for scanning QR code.

Screenshots

https://i.imgur.com/K3TU9bm.png

https://i.imgur.com/bIV57cV.png

https://i.imgur.com/ldynPU6.png

https://i.imgur.com/gtmPSpM.png

https://i.imgur.com/MyH9CEC.png

https://i.imgur.com/065FVXb.png

Install

For now, there is no way to install with Python standard tools (pip, Poetry) because we cannot tell them to install desktop-integration files (icons, *.desktop etc.) to correct places for a desktop app. You have to install it with OS package manager.

Ubuntu

CoBang is packaged as *.deb file for Ubuntu and derivatives (Linux Mint etc.). You can install it from PPA:

sudo add-apt-repository ppa:ng-hong-quan/ppa
sudo apt update
sudo apt install cobang

ArchLinux

CoBang is available via AUR.

Fedora

CoBang is available via COPR.

Other distros

Users of other distros can install CoBang from FlatHub.

flatpak install flathub vn.hoabinh.quan.CoBang

The release on FlatHub is lagging behind traditional distribution channels (PPA, AUR, COPR) because I often having difficulty building CoBang as Flatpak.

Compatibility

Though being targeted at Wayland, this app can still work in X11 desktop environments, like KDE (in Kubuntu), Xfce (in Xubuntu), LxQt (in Lubuntu). But due to a gap between GTK and Qt, the app gets some minor quirky issue when running in Qt-based DEs like KDE and LxQt. CoBang should not be tried in VirtualBox virtual machine, because of poor graphics stack VirtualBox provides.

There is an known issue with file chooser button when running from Flatpak. Hope that it can be solved in the future.

Development

This section is for someone who wants to join development of CoBang.

CoBang is written in Python, using GTK+ for UI, GStreamer for webcam capture and a part of ZBar for decoding QR code from image.

Install dependencies

1. Create Python virtual environment

Because Python binding of many GObject-based libraries (like GTK+, GStreamer) are not distributable via PyPI, you have to create a Python virtual environment with --system-site-packages flag, so that the project can access those system-installed Python libraries.

My recommended tool is virtualenvwrapper. Because of the requirement of --system-site-packages flag, you cannot use more modern tool, like `Poetry`_, for this task yet.

Example:

$ mkvirtualenv cobang --system-site-packages

$ workon cobang

2. Install GObject-based Python packages

The GObject-based dependencies are listed in deb-packages.txt file, under the name of Debian packages. On Debian, Ubuntu and derivates, you can quickly install them with this command:

xargs -a deb-packages.txt sudo apt install

On other distros (Fedora, ArchLinux etc.), please try to figure out equivalent package names and install with your favorite package manager.

3. Install PyPI-hosted Python packages

For other Python dependencies, this project is using PDM to manage. Please install it, then, inside the created virtual environment, run:

pdm install --no-self

to install those dependencies.

Run from source

python3 -m cobang

To print debug messages, set environment variable G_MESSAGES_DEBUG to cobang:

G_MESSAGES_DEBUG=cobang python3 -m cobang

Translation

pybabel extract -F babel.cfg -o po/cobang.pot .
./devtool.py update-translation
./devtool.py compile-translation

Package for Debian/Ubuntu

This repo is organized in two branches:

  • main: Main place for development. Latest code is here.
  • packaging/ubuntu: This branch is based on main, but added debian folder, used for building *.deb file.

Follow this step to package:

  • Checkout to main branch, and export source code:

    export VER='0.1.0'  # Change to version you want
    git archive --format=tar --prefix=cobang-$VER/ HEAD | gzip -c > ../cobang_$VER.orig.tar.gz
  • Move the *.orig.tar.gz file to somewhere, then extract it, as cobang-0.1.0 for example.

  • Checkout to packaging/ubuntu branch, copy debian folder and setup.py file, putting to just-extracted cobang-0.1.0 folder.

  • If you are about to build deb file locally, run:

    debuild -us -uc
  • If you are about to create source package which are suitable to build on Ubuntu's PPA [2], run:

    debuild -S

Package as Flatpak

You can package as Flatpak from the source.

flatpak-builder _build --force-clean vn.hoabinh.quan.CoBang.yaml
flatpak-builder --run _build vn.hoabinh.quan.CoBang.yaml cobang

Alternatives

These applications were born after CoBang, that is why they are not mentioned in "Motivation" section.

  • Decoder: Scan and generate QR code. Built with GTK4 and targeting Flatpak environment.
  • Megapixels: Camera application for Linux phones. The only one can access PinePhone camera. Can read QR code.

Credit

  • Brought to you by Nguyễn Hồng Quân.
  • Application logo is from Shadd Gallegos.
  • One icon is composed from ones made by Good Ware (allowed by Flaticon license).
  • Some contributors who proposed nicer UI for this app.
[1]Every Electron application brings along a pair of NodeJS + Chromium, which make the package size > 50MB, no matter how small the application code is. To make the situation worse, those NodeJS + Chromium set are not shared. It means that if you installed two Electron apps, you end up having two set of NodeJS & Chromium in your system!
[2]Ubuntu PPA requires to upload source package, not prebuilt binary. Read more at: https://help.launchpad.net/Packaging/PPA/Uploading