A missing native QR Code scanner application for Linux desktop.
This work is in progress.
It is "Cỏ bàng" (Lepironia articulata), in Vietnamese (I failed to find exact icon for this plant).
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.
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.
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
Unfortunately, I don't use other distro than Ubuntu and don't know how to package CoBang for them. You may have to run it from source (please see below). If you want to help package it for Fedora, ArchLinux, Gentoo, please submit pull request.
This application is written in Python, using GTK+ for UI, GStreamer for webcam capture and a part of ZBar for decoding QR code from image.
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
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.
Note that, please don't install gstreamer1.0-pipewire. We are having conflict issue with that software (will be solved later).
For other Python dependencies, this project is using Poetry to manage. Please install it, then, inside the created virtual environment, run:
poetry install --no-root
to install those dependencies.
python3 -m cobang
Add -v
option to see more detailed log.
This repo is organized in two branches:
master
: Main place for development. Latest code is here.packaging/ubuntu
: This branch is based onmaster
, but added debian folder and setup.py file, used for building *.deb file.
Follow this step to package:
Checkout to
master
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
- Brought to you by Nguyễn Hồng Quân.
- Icons from www.flaticon.com, made by Freepik, Good Ware.
- 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 |