Skip to content
Wedgewood-shellPublic

About

A fast, modular, Raycast style launcher backend for Wedgewood shell.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

Repository files navigation

hyprbeam

A fast, Raycast-style launcher backend for Wayland, written in Rust. Frontends are thin clients that talk to hyprbeamd over a Unix socket.

frontend ──unix socket (msgpack frames)──▶ hyprbeamd
                                            ├─ in-memory indexes (inotify / IPC-driven, never rescanned per keystroke)
                                            ├─ nucleo fuzzy matcher + decaying frecency
                                            ├─ built-ins: apps · calculator · niri windows
                                            └─ plugins: long-lived child processes (NDJSON over stdio), with timeouts

Typical full round trip from client to daemon and back is about 25 µs at p50 and under 100 µs at p99 (hyprbeam bench). Indexing 50 desktop files takes about 2 ms at startup.

Layout

crate what
crates/proto wire types + framing, shared by daemon and clients
crates/core Engine, Provider trait, frecency, .desktop parser, built-in providers
crates/daemon hyprbeamd: tokio server, query streaming/cancellation, plugin manager
crates/icons bundled default SVG icons (written to ~/.cache/hyprbeam/icons/ on first use) and the shared cache directory, used by the plugins
crates/cli hyprbeam: debug client (query, activate, repl, bench, reload, ping) and pipe, a JSON bridge for frontends

Install

cargo install --root ~/.local --path crates/daemon && cargo install --root ~/.local --path crates/cli
cp dist/systemd/hyprbeam.{socket,service} ~/.config/systemd/user/
systemctl --user enable --now hyprbeam.socket   # daemon starts on first connection
hyprbeam q fire

The daemon needs NIRI_SOCKET / WAYLAND_DISPLAY in the systemd user environment, which niri exports by default.

Protocol (client ↔ daemon)

Each frame is a big-endian u32 length followed by a MessagePack map (named fields). See crates/proto/src/lib.rs.

Requests (type tag): query {id, text, limit}, activate {item, action?}, reload, ping. Responses: results {id, items, done}, activated, reloaded, pong, error {message}.

  • A query may produce several results frames. Each one replaces the previous list, and the last has done: true. Built-in results always arrive first, and plugin results follow as they come in.
  • A new query on the same connection cancels the previous one. Clients should still drop any frame whose id is not the latest.
  • items[].highlights are char indices into title. items[].actions are secondary actions; pass one as activate.action. items[].data holds provider-specific string fields for frontends. A frontend that recognises data.kind may handle the item itself instead of sending activate.

Frontends that can't do binary framing (QML, shell scripts) can run hyprbeam pipe instead: it holds one daemon connection and speaks the same messages as JSON, one request per stdin line and one response per stdout line (e.g. {"type":"query","id":1,"text":"fire"}). It exits 0 when stdin closes; if the daemon is unreachable or goes away it prints an error line and exits 1.

Plugins

Put a manifest in ~/.config/hyprbeam/plugins/<name>/plugin.json (or plugins/<name>.json):

{ "name": "bm", "exec": ["./bookmarks.py"], "prefix": "bm", "timeout_ms": 200, "min_chars": 0, "lazy": false }
  • exec: argv. ~/ expands to $HOME, and other relative paths are resolved against the manifest directory. The systemd unit's PATH lacks ~/.local/bin, so use ~/.local/bin/….
  • prefix (optional): the plugin only sees bm <text> and receives <text>. A prefixed query is scoped to that plugin, and its results are boosted.
  • timeout_ms: replies arriving later are dropped. The UI is never blocked waiting for them.
  • lazy: by default plugins start with the daemon, so the first query doesn't pay for process startup.

The plugin reads one JSON object per line on stdin and writes one per line on stdout:

// daemon → plugin
{"type":"query","id":1,"text":"git"}
{"type":"activate","id":2,"key":"https://…","action":null}
// plugin → daemon (echo the id)
{"type":"results","id":1,"items":[{"key":"…","title":"…","subtitle":"…","icon":"…","score":12.0,"actions":[{"id":"copy","title":"Copy"}],"data":{"kind":"…"}}]}
{"type":"ok","id":2}
{"type":"error","id":2,"message":"…"}

score is optional; without it the daemon fuzzy-scores title itself. Item ids become <plugin name>:<key>, and frecency applies to them as well. Crashed plugins restart on the next query (at most once per second). See examples/plugins/bookmarks/.

Browser: tabs, bookmarks, history (hyprbeam-helide)

For Helide/Helium. One ranked list mixed into normal search, deduplicated so an open tab beats a bookmark, which beats history. The plugin only finds things. Each item carries data for the frontend, which opens it itself, and Activate on these items returns an error:

data.kind fields frontend opens it with (Quickshell HyprbeamMenu)
browser-tab tab_id, window_id, title, url island-tabs-ctl activate (switch to the open tab)
browser-url url helium-browser <url>; action here uses the address bar socket

Both kinds have a copy action, and browser-url also has here.

cargo install --root ~/.local --path crates/plugin-helide
mkdir -p ~/.config/hyprbeam/plugins/helide && cp dist/plugins/helide/plugin.json ~/.config/hyprbeam/plugins/helide/
hyprbeam reload
source read from kept fresh by
tabs $XDG_RUNTIME_DIR/island-tabs.json, written by the Island Tabs extension's native host. The visible tab of each window is skipped, since it's already a niri window. inotify
bookmarks <profile>/Bookmarks (JSON) inotify
history <profile>/History (SQLite, read with immutable=1, because the browser holds a lock) inotify, at most every 3 s
  • Filtering: a match must be close to a perfect one and coherent: few contiguous runs, or every run starting a word, so gh matches GitHub and yt matches YouTube. History is weighted below apps, then by visits, typed count and recency.
  • Icons: icon is an absolute path. Favicons are cached per domain in ~/.cache/hyprbeam/favicons/<host>.png. Missing ones are copied out of the profile's Favicons database (refreshed after 30 days, never read while searching), then Island Tabs' own ~/.cache/island-tabs/<host>.png is tried. Nothing is fetched from the network. With no favicon, file:// URLs get a file-type icon and everything else the bundled web page icon.
  • Env: HELIDE_USER_DATA_DIR (default ~/.config/net.imput.helium), HELIDE_PROFILE (default: the last used profile), HELIDE_TABS_FILE, HELIDE_MIN_QUALITY (default 0.5).

Files (hyprbeam-files)

Indexes file and directory names under ~/Downloads, ~/Documents, ~/Pictures and ~/Videos, and nothing else. Like helide it only finds: items carry data.kind = file with path, name, dir and is_dir ("true"/"false"), plus reveal and copy actions. Activate returns an error.

cargo install --root ~/.local --path crates/plugin-files
mkdir -p ~/.config/hyprbeam/plugins/files && cp dist/plugins/files/plugin.json ~/.config/hyprbeam/plugins/files/
cp dist/plugins/files/files.toml ~/.config/hyprbeam/files.toml   # optional: every key has a default
hyprbeam reload

Config is ~/.config/hyprbeam/files.toml (or $HYPRBEAM_FILES_CONFIG); a missing file means defaults, and an invalid one is logged and ignored. Unknown keys are an error.

key default
roots the four dirs above Must be one of them or inside one. Roots are canonicalised, so .. and symlinks can't escape. Others are skipped with a warning.
exclude node_modules, target, __pycache__, *.part, *.crdownload, *.tmp, *~ Globs on file names. A directory match skips the subtree.
include_hidden false dotfiles and dot-directories
include_dirs true directories as results
max_depth 12 levels below a root
max_entries 100000 the index is partial beyond this
limit 8 results per query
min_quality 0.5 how close to a perfect match a result must be (0 to 1)

Results get a bundled icon by file type (folder, image, video, audio, PDF, document, spreadsheet, presentation, archive, code, generic file).

Symlinks are never followed. The index is built at startup (about a millisecond per 500 entries) and rebuilt 1.5 s after the last inotify change under a root. Names match fully, a match only through a parent directory name counts 0.6, and files modified recently get up to a 25% boost.

Writing a built-in provider

Implement hyprbeam_core::Provider and add it to providers::defaults(). query runs on every keystroke, so it must only read in-memory snapshots (Arc<Vec<…>> swapped by a background watcher) with pre-converted Utf32String haystacks.

Environment

var default
HYPRBEAM_SOCKET $XDG_RUNTIME_DIR/hyprbeam.sock
HYPRBEAM_TERMINAL derived from $TERMINAL (for Terminal=true apps)
state $XDG_STATE_HOME/hyprbeam/frecency.mpk

About

A fast, modular, Raycast style launcher backend for Wedgewood shell.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages