Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

fastpaste-rs

Clipboard history + snippet manager, written in Rust. One codebase, built for Linux (Wayland — KDE Plasma 6 / KWin; X11 sessions are not supported) and for Windows.

Everything the OS is asked for sits behind a trait, and each platform supplies one implementation:

Linux Windows
Global hotkeys XGrabKey on the XWayland root window RegisterHotKey
Clipboard changes wl-clipboard-watch, arboard polling as fallback WM_CLIPBOARDUPDATE
Paste keystroke /dev/uinput SendInput
Paste target window GetInputFocus / SetInputFocus on XWayland GetForegroundWindow / SetForegroundWindow
Single instance abstract unix socket named mutex

Everything above fastpaste-platform is platform-independent; adding an OS means adding an implementation there, not a fork.

Linux only — the global hotkeys are not truly global. They are grabbed with XGrabKey on the XWayland root window, and under a Wayland compositor keyboard input only reaches XWayland while an X11/XWayland window has focus. With a Wayland-native window focused the keystroke never reaches us and goes to that application instead.

On a current Plasma 6 desktop most applications are Wayland-native (Chrome and Chromium run that way whenever --ozone-platform=wayland is in effect), so in practice the shortcuts fire rarely. Making them work everywhere needs a different mechanism — the org.freedesktop.portal.GlobalShortcuts portal, or delegating the shortcut to KDE and giving the app an IPC entry point. Until then, the tray icon and the main window are the reliable ways in.

Windows does not have this problem: RegisterHotKey is honoured whatever has focus.

Screenshots

Selection dialog — the quick-paste popup. Type to filter, arrow to a row, Enter pastes. Saved snippets first, clipboard history last, each group under its own heading.

Selection dialog

Main window — snippet/folder tree with an editor pane. The clipboard history appears as a virtual folder alongside the real ones.

Main window

Options — applied live; a rejected hotkey is reported in the dialog rather than silently reverted.

Options dialog

Features

  • Main window: snippet/folder tree (CRUD) with an editor pane and toolbar. Double-click or Enter on a row pastes it. Deleting a folder — which removes its whole subtree, with no undo — asks first
  • Selection dialog: keyboard-driven quick-paste popup over the clipboard history and the snippet library, with type-to-filter and wrapping arrow-key navigation. PageUp/PageDown move by a screenful; Home/End jump to the ends while the filter box is empty (once you have typed a filter they move the text cursor instead)
  • Options dialog: general / hotkeys / clipboard-history / paste settings, applied live (hotkey changes re-register immediately). A rejected hotkey is reported in the dialog and leaves the other changes intact
  • Global hotkeys (defaults, configurable): Ctrl+Alt+V → selection dialog, Ctrl+Alt+M → main window; layout-independent physical-keycode grabs that work under any keyboard layout. Letters, digits, F1-F12, and named keys (Space, Tab, Esc, Home, arrows, punctuation…) are accepted, with at least one modifier. See the limitation above for when they actually fire, and note that KDE's own Klipper may already hold Ctrl+Alt+V — the options dialog reports that case as "already claimed by another application"
  • Clipboard history folder: bounded ring populated by watching the system clipboard (wlr-data-control), rendered as a virtual folder in the tree
  • Paste by emulating Ctrl+V — or Shift+Insert, for terminals — into the window that had focus when the hotkey was pressed, with the previous clipboard contents (text, an image, or copied files) restored afterwards. A clipboard holding anything else that cannot be saved cancels the paste rather than being overwritten
  • System tray icon with context menu (Slint native SystemTrayIcon)
  • Localization: English, Russian, German, Spanish, Simplified Chinese
  • Single-instance guard (abstract unix socket, kernel-released on exit)
  • Optional database encryption: SQLCipher whole-file encryption, keyed by a passphrase you set in Options → Security. Off by default; you can turn it on and off again at any time. The passphrase can be remembered in the system keyring so launches stay silent, and there is no way to recover a forgotten one. Two things worth knowing before you rely on it: the threat model is someone who obtains the database file (a backup, a synced folder, a stolen disk), not code already running as you — so (1) encrypting an existing library deletes the plaintext original, but on an SSD or a copy-on-write/journalling filesystem that is not secure erasure, and its previous contents may still be recoverable from the raw device; and (2) the keyring stores the passphrase itself, so any process running as you, not only fastpaste, can read a remembered one

Degraded modes

The app starts and stays useful when a piece of the desktop is missing:

Missing Effect
/dev/uinput Paste puts the payload on the clipboard and leaves it there for a manual Ctrl+V; nothing else changes
Synthetic input reaching the target (Windows: an elevated window refuses it, under UIPI) Same as above: the payload is left on the clipboard for a manual paste, instead of the old clipboard being put back
A Wayland session (Linux) No window opens at all: the GUI is built with Slint's Wayland backend only, so an X11 session — already unsupported — fails at startup instead of half-working
An X11 window with focus when the hotkey fires (Linux) No target window is captured, so the paste goes to whichever window the compositor focuses once the dialog closes. See the Linux paste notes below
XWayland / X connection Global hotkeys do not fire at all (as opposed to firing only over X11 windows — see the limitation at the top). The tray, main window and clipboard history all still work. A connection that drops later is reconnected automatically (up to 5 attempts, 500 ms apart), replaying the registered grabs; past that the hotkeys are inert until the app is restarted
System tray The app quits when the main window is closed, rather than staying resident with no way to reach it
A readable config.toml The unreadable file is moved to config.toml.bak and defaults are used, rather than failing to start
A decodable database row The row is skipped and logged; the rest of the library still loads
A credential store (Secret Service / Credential Manager) Only matters with an encrypted database: the passphrase cannot be remembered, so it is prompted at every launch. The Remember checkbox is disabled and says why
A correct passphrase on the first try, for an encrypted database A wrong passphrase re-prompts with a localized "wrong passphrase" message. Any other failure (a corrupt schema from a newer build, a fatal platform-backend error) shows the real error instead of blaming the passphrase, since retyping the same correct one cannot fix it. Cancelling, or closing the dialog's window, exits cleanly and releases the single-instance guard
A remembered passphrase that no longer works The stale keyring entry is cleared and the dialog is shown, rather than the app refusing to start — but only when the failure was actually a wrong passphrase. Any other failure (a transient backend fault, a full disk) leaves the saved passphrase alone and just falls back to the prompt
A clean shutdown during an encrypt / change / remove conversion The original file is untouched — nothing is written to it until the replacement has been verified — and the partial <name>.sqlite.new left behind by the crash is deleted automatically at the next launch
A way to recover a forgotten passphrase None exists. Options → Security says so before you ever set one

Install

Packages are on the Releases page, with a SHA256SUMS file to check them against.

Debian, Ubuntu (Ubuntu 22.04 / Debian 12 or newer):

sudo apt install ./fastpaste_X.Y.Z-1_amd64.deb

Fedora:

sudo dnf install ./fastpaste-X.Y.Z-1.x86_64.rpm

Either one installs /usr/bin/fastpaste, a menu entry, and a udev rule, /usr/lib/udev/rules.d/70-fastpaste-uinput.rules, that gives the user of the active local session access to /dev/uinput. Pasting needs that access; without it the snippet is left on the clipboard for you to paste by hand. The package applies the rule straight away — if getfacl /dev/uinput does not list your user afterwards, log out and back in. The trade-off is the usual one for this rule (Steam ships the same one): any program running as you can then synthesize keyboard input.

The binary is built on Ubuntu 22.04, so it needs glibc 2.35 or newer, and it needs a Wayland session (see the limitation at the top).

Windows (10 or later):

  • fastpaste-X.Y.Z-windows-x64-setup.exe installs for the current user only — no administrator rights — with a Start-menu entry, an optional Automatically start fastpaste checkbox, and an uninstaller under Settings → Apps.
  • fastpaste-X.Y.Z-windows-x64-portable.zip holds the same fastpaste.exe, to run from wherever you unpack it. It is portable in the sense of needing no install: settings and snippets still live in your profile, under %APPDATA%\fastpaste, not next to the exe.

Neither is code-signed yet, so SmartScreen warns the first time you run them ("Windows protected your PC"); More info → Run anyway proceeds. Check the download against SHA256SUMS first (Get-FileHash <file> -Algorithm SHA256 in PowerShell).

Build prerequisites (Linux)

  • Rust 1.95+ (rustup recommended)
  • libfontconfig1-dev (required by Slint):
    sudo apt install libfontconfig1-dev
    
  • A Wayland session (KDE Plasma 6 / KWin target) with XWayland available (global hotkeys grab via XGrabKey on the XWayland root window).
  • For paste via /dev/uinput: the user must have read/write access to /dev/uinput; check with getfacl /dev/uinput. The packages install a udev rule for this. From a source build, install the same rule:
    sudo cp packaging/linux/70-fastpaste-uinput.rules /etc/udev/rules.d/
    sudo udevadm control --reload-rules
    sudo udevadm trigger --action=change --sysname-match=uinput
    

Build

cargo build --release

Looking at the UI

The app needs a compositor to run, which makes "does this layout look right" hard to answer on a build machine. examples/ui_preview.rs renders a window with representative data straight to a pixel buffer via Slint's software renderer — no display, no compositor:

cargo run --example ui_preview -- options 2 out.ppm      # options dialog, page 2
cargo run --example ui_preview -- main   0 out.ppm       # main window
cargo run --example ui_preview -- main   1 out.ppm       # …with the delete confirmation
cargo run --example ui_preview -- select 0 out.ppm       # selection dialog
cargo run --example ui_preview -- select 0 out.ppm en    # …seeded in English
ffmpeg -i out.ppm out.png                                # P6 -> PNG

It seeds the longest shipped locale (Russian) by default, because label clipping and column overflow only show up in the widest strings. Pass en as the fourth argument for English — that is how the screenshots above are produced. The example pulls in slint's software-renderer-systemfonts feature as a dev-dependency, so the shipped binary is unaffected — but it does make cargo test builds larger.

Run

cargo run --release --bin fastpaste-gui

Workspace crates

Four crates layered bottom-up. app imports data + platform; gui imports all three (it uses data types and platform hotkey ids directly, not only through app):

fastpaste-data — storage layer

No GUI, no platform code, no I/O beyond SQLite.

  • item.rs — Item / ItemKind: the snippet/folder value type that crosses all layers (a plain Clone struct — it owns Strings, so not Copy — with serde + chrono timestamps)
  • database.rs — Database: SQLite CRUD for items and folders. Owns the tree invariant: update / move_to_parent reject a parent_id that is the item itself, one of its own descendants, or a row that does not exist, and every recursive query uses UNION so a cycle that reached the file some other way still terminates
  • error.rs — DataError, the layer's error enum
  • migrations/ — refinery SQL migrations (V001__initial_schema.sql)

Linux paste notes

  • The paste chord uses physical keys. /dev/uinput emits the physical KEY_V (and KEY_INSERT) position, and the compositor maps it through your layout. On a non-Latin layout such as Russian, toolkits fall back to the Latin layout for shortcuts and Ctrl+V works; on a Latin layout that moves V — Dvorak, Colemak — the chord lands on whatever letter sits at the QWERTY V position, and the paste does not happen. Insert is in the same place on every layout, so the Shift+Insert paste method (Options → Paste) is the layout-proof choice there, and the one terminals want anyway.
  • Held modifiers are not released. On Windows, a modifier you are still holding when the chord fires is released first, so the chord is exactly Ctrl+V. A uinput device cannot read the real keyboards' state, so Linux does not do this; by the time you pick a snippet from the dialog the hotkey is long released.
  • Focus restore is X11-only. The target window is captured with GetInputFocus, so it is only known when an X11/XWayland window had focus — which is also the only time the hotkeys fire (see the limitation at the top). The compositor may still ignore the SetInputFocus; then, as with no target at all, the paste goes to whichever window it focuses after the dialog closes.

fastpaste-platform — Linux platform layer

Everything that touches the OS/desktop environment:

  • hotkey.rs — GlobalHotkey trait + X11GlobalHotkey (XGrabKey on the XWayland root window, layout-independent physical keycodes), and the OPEN_DIALOG_ID / OPEN_MAIN_WINDOW_ID action ids. The reader thread owns the X connection, reconnects when the server goes away, and exits cleanly when the backend is dropped. Registering one id never disturbs another's live grab, so the two shortcuts can be swapped in one apply
  • clipboard.rs — Clipboard trait + ArboardClipboard (read/write via data-control) and the wl-clipboard-watch-based change watcher with an arboard-polling fallback. Own writes are announced by content with a short TTL (suppress_text), so an announced write that never lands — or that the polling fallback never observes — expires instead of swallowing the user's next real copy
  • paste_keys.rs — PasteKeys trait + EvdevPasteKeys (/dev/uinput) / WindowsPasteKeys (SendInput) / NullPasteKeys. The chord for each PasteMethod (Ctrl+V, Shift+Insert) comes from a pure builder that is tested without a device; on Windows every stroke carries a scan code and held modifiers are released first
  • foreground.rs — ForegroundWindow trait: capture the window that had focus when the hotkey fired, give it focus back before the keystroke
  • take_once.rs — TakeOnceChannel, a one-shot hand-off primitive used by the hotkey event path

fastpaste-app — service layer

Orchestrates data + platform into long-lived services:

  • context.rs — AppContext: composition root bundling every service behind Arc for the UI controllers, plus the single-instance guard — acquired first, before the database is opened or any device claimed. AppContext::new takes the services directly (the seam the tests use); build is the production wrapper that resolves XDG paths and opens the real backends. set_settings owns the "every field applies live" contract
  • settings.rs — Settings: typed config.toml load/save (confy), grouped into general / hotkeys / clipboard-history / paste sections
  • clipboard_history.rs — ClipboardHistory: the bounded ring fed by the clipboard watcher, exposed as a virtual folder. max_items resizes live, trimming from the oldest end
  • paster.rs — Paster: the paste sequence (snapshot → set clipboard → refocus the target → delay → keystroke → delay → restore). The second delay matters: the keystroke is only queued, and restoring at once let the target paste the old clipboard. Whole sequences are serialised, the restore runs even when the keystroke fails, it is skipped when no keystroke was sent or the OS refused it (so the manual-paste fallback has something left to paste), and it is skipped when you copied something else mid-paste (your newer copy wins)
  • paths.rs — single source of truth for XDG config_dir / data_dir

fastpaste-gui — Slint frontend (binary fastpaste-gui)

  • ui/main_window.slint — snippet tree + editor + toolbar
  • ui/selection_dialog.slint — the quick-paste popup
  • ui/options_dialog.slint — settings dialog
  • ui/tray_icon.slint — FastpasteTray (native SystemTrayIcon + menu)
  • ui/widgets.slint — compact in-house widget set + design tokens
  • ui/translations.slint — global singleton carrying every UI string
  • src/tree_builder.rs — flattens Item rows + history entries into the TreeItem list consumed by the TreeView
  • src/i18n.rs — fluent runtime (embedded .ftl, per-locale fallback, live language switch)
  • src/main.rs — controllers wiring Slint callbacks/hotkey events to AppContext. Editor changes are debounced (~300 ms) into one write instead of one per keystroke, and flushed on selection change and on close; the editor is seeded from the database rather than the tree model, which lags a rename
  • src/ui_state.rs — thread-local keep-alive slots for the windows and the tray. hide() drops the only other strong handle, so without these a hidden window would be freed and rebuilt on every reopen
  • build.rs — slint_build compilation of the .slint files

Choosing a shortcut

The two defaults differ by the key (V / M), not by a modifier. That is deliberate. A pair that differs only by Shift is fragile: on many layouts Alt+Shift is the layout switcher, a compositor can claim the longer combination before it reaches the app, and anything that normalises Shift away collapses the two into one — which shows up as "the four-key combination triggers the three-key action". Two different keys cannot collapse that way.

Note that KDE's own Klipper may already hold Ctrl+Alt+V. The options dialog reports that case as "already claimed by another application" rather than silently reverting the field.

If a shortcut behaves unexpectedly, ask the app what it actually received:

RUST_LOG=fastpaste_platform=debug cargo run --bin fastpaste-gui

Every registration is logged with its resolved keycode and modifier mask, and every fire is logged with the id that claimed it plus the raw modifier state that arrived. If the state that arrives does not match the mask that was registered, the compositor or the keymap changed it on the way.

Data & configuration

What Path
Settings ~/.config/fastpaste/config.toml
Database ~/.local/share/fastpaste/fastpaste.sqlite

The config file is created on first save with these defaults. Missing fields fall back to their defaults, so a config written by an older version keeps loading after upgrades:

[general]
language = "system"          # "system" follows the OS locale; or a BCP-47 tag

[hotkeys]
open_dialog = "Ctrl+Alt+V"
open_main_window = "Ctrl+Alt+M"

[clipboard_history]
enabled = true
max_items = 10               # clamped to 1..=500
position = "bottom"          # "top" | "bottom"

[paste]
delay_ms = 70                # pause between clipboard set and Ctrl+V; clamped to 0..=5000
restore_clipboard = true     # put the previous clipboard back after paste
restore_delay_ms = 120       # pause between the keystroke and the restore; clamped to 0..=5000
method = "ctrl_v"            # "ctrl_v" | "shift_insert"; an unknown value falls back to "ctrl_v"

Numeric values are clamped to the ranges above on load, so a hand-edited typo cannot turn into a failed allocation or a wedged paste worker. A file that cannot be parsed at all is moved aside to config.toml.bak and defaults are used — the app never fails to start over its config.

Dependencies

Versions used by more than one crate are pinned in the workspace root Cargo.toml ([workspace.dependencies]) and pulled in via dependency.workspace = true. Single-consumer dependencies (rusqlite, refinery, directories, confy, single-instance, …) are pinned in the crate that owns them.

Crate Used by Purpose
slint gui Declarative UI toolkit: main window, dialogs, system tray
slint-tree-view gui Slint TreeView component for the snippet tree
slint-build gui (build) Compiles .slint files at build time; experimental-module-builds feature resolves import { TreeView } from "@TreeView" against the library crate
fluent-templates gui Fluent static loader: embeds the .ftl files at compile time, per-key fallback chain to English
sys-locale gui Resolves the "system" language setting from the OS locale
fluent-syntax gui (dev) Parses .ftl sources in the key-parity test
tracing platform, app, gui Structured logging
tracing-subscriber gui Log output with RUST_LOG env-filter support
anyhow app, gui Ergonomic error handling at the service/main level
thiserror data, platform, app Derive error enums for each layer's error type
rusqlite (features bundled, chrono) data SQLite driver; bundled builds the C library in, chrono gives native DateTime<Utc> ↔ TEXT conversion
refinery data SQL migrations (fastpaste-data/migrations/)
serde data, app Serialization: Item rows and config.toml
chrono data, app, gui (dev) Timestamps: RFC 3339 in the DB, history entry times
directories app XDG data_dir/config_dir resolution
confy app TOML config load/save
single-instance app Single-instance guard: abstract unix socket keyed on the data dir (no lock file, kernel-released on exit)
arboard (feature wayland-data-control) platform Clipboard read/write (text, and images and file lists for the paste snapshot): native data-control protocol on Wayland — the same transport as the watcher — with arboard's X11 backend as fallback when the compositor offers no data-control
wl-clipboard-watch platform Event-driven clipboard change detection (ext/wlr-data-control); the platform layer falls back to arboard polling when neither protocol is available
wl-clipboard-rs platform The paste snapshot on Wayland: one MIME listing decides what to read, and an image is read and offered back as its raw bytes, never decoded. Already built as arboard's data-control backend
clipboard-win platform (Windows) The paste snapshot of an image: its PNG / DIB clipboard formats copied and put back as raw bytes. Already built as arboard's Windows backend
evdev platform /dev/uinput virtual keyboard to emit Ctrl+V / Shift+Insert; KeyCode: FromStr also resolves hotkey key names to physical kernel keycodes
x11rb platform XGrabKey global hotkeys on XWayland — physical keycodes, layout-independent (the global-hotkey crate resolves keysyms via the core keymap and fails under Cyrillic layouts); GetModifierMapping resolves real Alt/NumLock/Super modifier bits
libc platform poll(2) for the hotkey reader's blocking loop (wakes on X traffic or a wake-pipe byte); already a transitive dep of x11rb
tempfile data, app (dev) Temp directories in tests
serde_json data (dev) Serde round-trip asserts in tests (enum #[serde(...)] attributes)

Version constraints worth knowing when upgrading:

  • slint, slint-build, and slint-tree-view are all pinned in the workspace root [workspace.dependencies] and must stay on compatible versions — the TreeView library exports .slint types compiled against the same Slint compiler.
  • fluent-templates 0.15 (fluent-bundle 0.16, fluent-syntax 0.12, unic-langid 0.9) and the dev-only fluent-syntax 0.12 share the same unic-langid-impl major; mixing older majors conflicts.
  • wl-clipboard-rs (pulled in transitively by arboard's wayland-data-control feature) exposes no watch API in any published version — its watch surface lives only in the separate wl-clipboard-rs-tools binary (verified against docs.rs, 2026-08). Clipboard watching therefore stays on wl-clipboard-watch; don't "simplify" it away in favor of the transitive wl-clipboard-rs.

Releasing

A release is built by .github/workflows/release.yml from a tag, and nothing becomes public until you publish the draft it makes.

  1. Bump the version. It lives in one place, version under [workspace.package] in the root Cargo.toml; every crate, both packages and the Windows version resource take it from there. Run cargo check so Cargo.lock follows.
  2. Update CHANGELOG.md. Move the Unreleased entries under a new ## [X.Y.Z] - YYYY-MM-DD heading. That section becomes the release notes.
  3. Commit both, and get the commit onto main.
  4. Tag and push that commit:
    git tag -a vX.Y.Z -m "fastpaste X.Y.Z"
    git push origin vX.Y.Z
    
  5. Watch the Release workflow. It refuses a tag that does not match the version in Cargo.toml, or that has no CHANGELOG.md section. It builds the .deb and .rpm on Ubuntu 22.04, installs each in clean Ubuntu 22.04 / 24.04, Debian 12 and Fedora containers (packaging/linux/smoke-test.sh), builds the Windows installer and portable zip, and creates a draft release with them and SHA256SUMS.
  6. Review the draft under Releases on GitHub: the notes, the file list, and ideally one install. Then Publish it.

A tag such as v1.2.0-rc.1 (with the same version in Cargo.toml) makes a pre-release; the packages call it 1.2.0~rc.1 so that it sorts before 1.2.0.

To try the whole pipeline without tagging, run the workflow by hand (Actions → Release → Run workflow): everything is built and tested, the release step is skipped, and the files are left as the run's artifacts.

If a tagged run fails, fix the problem, then move the tag: git push --delete origin vX.Y.Z, git tag -d vX.Y.Z, and tag again. Delete any draft the failed run left behind.

What goes into the packages is in packaging/ — the desktop file, the udev rule, the icons (packaging/make-icons.py regenerates them from new artwork) and the Inno Setup script — and in the [package.metadata.deb] and [package.metadata.generate-rpm] tables of crates/fastpaste-gui/Cargo.toml. The Windows files are not code-signed; the workflow has a marked stub where signing would go.

License

MIT — see LICENSE.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages