# rcalc Desktop calculator for Linux/Windows/macOS, inspired by the Windows Calculator (standard mode). Built with Rust + [Slint](https://slint.dev). ## Run ```bash cargo run --release # or ./dist/rcalc ``` ## Install as a Debian package ```bash ./scripts/build-deb.sh # → dist/rcalc_-_.deb sudo apt install ./dist/rcalc_*_amd64.deb rcalc # or start it from the application menu ``` The binary is compiled in an Ubuntu 22.04 container (Docker) by default, so the package keeps a glibc 2.35 baseline and installs on Ubuntu 22.04 / 24.04 / 26.04. `Depends:` are generated from the ELF with `dpkg-shlibdeps`. Menu/taskbar icons come from `ico/` — every PNG there is placed into the hicolor slot matching its real pixel size (file names do not matter), and the remaining smaller sizes are downsampled from the biggest one. Without `ico/` the icons are resized from `assets/icon.png`. The icon inside the window (`ui/app.slint`) and the Windows `rcalc.exe` icon still use `assets/`. Useful switches: | Variable | Effect | | --- | --- | | `DEB_REVISION=` | packaging revision, `1` by default → `Version: 0.1.28-1` | | `REPO=1` | also write `dist/Packages(.gz)` so `dist/` works as a local apt repo | | `SKIP_DOCKER=1` | build on the host (needs this host's glibc on the target) | | `PREBUILT=1` | package the existing `dist/rcalc`, no compile | | `NO_STRIP=1` | keep symbols (bigger package) | | `KEEP_STAGE=1` | leave `dist/deb-root/` for inspection | | `DOCKER_IMAGE=` | other build image, e.g. `debian:12` for an older baseline | | `DEB_MAINTAINER=` | `"Name "` in `Maintainer:` (default: git user) | ### Version and updates Package version = `-`, e.g. `0.1.28-1`. * changed app code → bump `version` in `Cargo.toml` (it is also the window title); * changed only packaging (icon, `.desktop`, `Depends`, rebuilt binary) → `DEB_REVISION=2`. `dpkg` compares these in order (`0.1.28-1 < 0.1.28-2 < 0.1.29-1`, and `0.1.9 < 0.1.10`), so every new build is an upgrade, never a downgrade. The script prints the resulting upgrade path and warns if the version being built is not newer than the installed one — an `apt upgrade` of such a package does nothing. Release notes live in `packaging/deb/changelog` and are installed as `/usr/share/doc/rcalc/changelog.Debian.gz`. Update in place (config in `~/.config/rcalc/config.json` is a user file, it survives): ```bash sudo apt install ./dist/rcalc_0.1.28-2_amd64.deb ``` Or keep `dist/` as a local repository and update with plain `apt` (build with `REPO=1`, then point apt at the folder): ```bash echo 'deb [trusted=yes] file:/path/to/RCalc/dist ./' | sudo tee /etc/apt/sources.list.d/rcalc.list sudo apt update && sudo apt install rcalc # later: sudo apt upgrade ``` > If `scripts/install-desktop.sh` was ever run, `~/.local/bin/rcalc` (a symlink to > `dist/rcalc`) shadows `/usr/bin/rcalc` — remove it after switching to the package, > otherwise `rcalc` in the terminal still starts the old binary. The script warns > about this during the build. ### Icon (Linux / Wayland) On **Wayland** the window `icon` property is ignored — the desktop uses `.desktop` + `app_id`. Install once: ```bash ./scripts/install-desktop.sh ``` Then start **rcalc** from the app menu (or `~/.local/bin/rcalc`), not by clicking a random binary path, so KDE/GNOME can match `app_id=rcalc` to `rcalc.desktop` and show the icon. ## Features - Modes: **Standard**, **Engineering**, **Programmer**, **Convert**, **CRC**, **Settings** - Standard: `+ − × ÷`, `%`, `±`, `1/x`, `x²`, `√x`, memory, formula panel - Engineering: trig functions, log/pow, DEG/RAD, SI prefixes - Programmer: simultaneous **HEX / DEC / OCT / BIN**, sizes **QWORD / DWORD / DINT / WORD / INT / BYTE**, bitwise ops, clickable bits (WORD/DWORD — unsigned DEC; INT/DINT — signed) - Convert: **float32 ↔ two 16-bit words** with endian **AB CD / CD AB / BA DC / DC BA** - Convert → **Ratio**: float → minimal **num/den** for electronic gear (Byte≤255 / Word≤65535) - Convert → **ASCII**: Char ↔ Hex ↔ Dec (control names for NUL…DEL) - **CRC**: Modbus RTU CRC-16 + Modbus ASCII LRC from hex bytes (`01 03 00 00 00 0A`) - Keyboard input ## Project layout - `src/engine.rs` — standard calculator logic - `src/programmer.rs` — programmer mode logic - `src/convert.rs` — float32 / word endian convert - `src/main.rs` — UI wiring - `ui/app.slint` — Slint interface - `dist/rcalc` — release binary - `scripts/build-deb.sh` + `packaging/deb/` — .deb package (control, desktop file, AppStream metainfo, maintainer scripts) - `scripts/build-appimage.sh` — portable AppImage - `scripts/install-desktop.sh` — per-user launcher + icon (no root needed)