# WinRust mods Mods add your own features to WinRust: hotkeys, search commands, timers, reactions to what happens on the PC, widgets on the bar, text expansions. ## The mod store Open Start: **Mod store** is pinned at the top and opens the store window (typing `mods` in the search card, Alt+Space / Win+S, opens it too). Every mod in this folder is a card, checked ones first; the tabs show all, checked or installed mods, and typing searches names, descriptions and authors: - **✓ Checked by a moderator**: a WinRust moderator reviewed this exact file and signed it. WinRust verifies the signature and the file's hash before installing; a file changed after the review loses the mark and is refused. - **Not checked**: in the catalog but not reviewed yet. You are warned before installing. **Install** shows what the mod is, who made it and which permissions it asks for, and asks first; **Remove** takes it away. An installed script mod has two small buttons: its **log** (what it printed, its errors) and its **settings**. Installed mods live in `%APPDATA%\WinRust\mods\`; the search card picks up changes the next time it opens. ## Writing a mod **New mod** at the bottom of the store creates `my-mod.rhai` from a template and opens it in Notepad. Save, open the search card (Alt+Space), and the mod is loaded. Check a file from a terminal: ```powershell & "C:\Program Files\rs-search\rs-launcher.exe" --check my-mod.rhai ``` ### The language A script mod is a `.rhai` file: the WinRust mod language, [Rhai](https://rhai.rs) with block statements on top. Line ends need no `;`. ```rust // name: Battery guard // author: your-github-name // description: warns when the battery runs low, shows it on the bar // permissions: system every 1.min { if battery() < 15 { say(`Battery ${battery()}%`) } } widget "Battery" 30.sec { `🔋 ${battery()}%` } hotkey "Win+Shift+B" { say(`Battery ${battery()}%, CPU ${cpu()}%, memory ${ram()}%`) } ``` The head comment (`name`, `author`, `description`, `permissions`) is shown in the store. The top level runs once when the mod loads and registers the blocks; the blocks run later. ### Blocks | Block | Runs | |---|---| | `hotkey "Win+Shift+D" { ... }` | on a global shortcut | | `command "Copy date" { ... }` | from a row in the search card (type part of the name) | | `every 5.min { ... }` | again and again (`30.sec`, `5.min`, `2.hours`; at least 1 second) | | `at "09:00" { ... }` | once a day at that time | | `on window_opened(w) { ... }` | when a window appears (`w` is the window) · needs `windows` | | `on window_focused(w) { ... }` | when another window comes to the front · needs `windows` | | `on battery(level) { ... }` | when the battery level changes · needs `system` | | `on clipboard(text) { ... }` | when the clipboard changes · needs `clipboard` | | `widget "Name" 30.sec { "text" }` | the block's text shows on the bar, refreshed at that interval (5 s if left out) | | `search q { [ ... ] }` | adds rows to the search card for the typed text `q`: return a string, an array of strings, or maps `#{title: "...", subtitle: "...", copy: "..."}` / `#{title: "...", open: "https://..."}` | | `expand ";mail" { "me@example.com" }` | typing the trigger replaces it with the block's text · needs `keyboard` | ### Functions | Function | | Permission | |---|---|---| | `say(text)`, `say(title, text)` | a message box | | | `open(target)` | a web page (`https://...`), a Settings page (`ms-settings:...`), a shell folder (`shell:...`), a folder or a document. Never a program or a script: returns `false` | | | `now()`, `today()`, `time()` | `"2026-11-29 12:34:56"`, `"2026-11-29"`, `"12:34"` | | | `setting(key, default)` | a value the user can change: the store's settings button opens the mod's settings file | | | `save(key, value)`, `load(key, default)` | the mod's own memory, kept between restarts | | | `print(x)` | a line in the mod's log | | | `copy(text)`, `paste()` | the clipboard | `clipboard` | | `windows()`, `active()` | the open windows / the one in front: `w.title`, `w.app` (`"chrome"`), `w.pid` | `windows` | | `w.focus()`, `w.close()`, `w.minimize()`, `w.maximize()`, `w.restore()` | | `windows` | | `w.snap("left")` | `left`, `right`, `top`, `bottom`, `full` of its screen | `windows` | | `w.move(x, y, width, height)` | | `windows` | | `cpu()`, `ram()`, `battery()` | percent (battery `-1` without one) | `system` | | `play_pause()`, `next_track()`, `previous_track()`, `volume_up()`, `volume_down()`, `mute()` | | `system` | | `keys("Ctrl+V")` | presses a combo | `keyboard` | | `type(text)` | types text into the window in front | `keyboard` | | `fetch(url)` | the text of an https page, only from hosts in the permission; `parse_json(text)` turns JSON into a map | `net:host` | Everything else is plain Rhai: `let`, `if`, `for`, `while`, functions (`fn name(x) { ... }`), strings (`` `text ${expr}` ``), numbers, arrays, maps. ### Permissions ```rust // permissions: clipboard, windows, system, keyboard, net:api.open-meteo.com api.github.com ``` Without a permission its functions stop the block with a clear error. The store shows the permissions before installing, and moderators check that a mod uses them for what it says. What a script mod can never do: start programs, read or write files (beyond its own settings, memory and log), load other code, reach hosts it did not declare, run as administrator. A runaway loop is stopped. ### Errors Errors name the line and, for a typo, the function you probably meant (`line 4: unknown function cpy — did you mean copy?`). They go to the mod's log (the store's log button), a failing hotkey or command also says so on screen. ## Command mods (`.txt`) The simple older format, one line per feature: ```text hotkey Win+Shift+T = wt.exe command Restart Explorer = taskkill /f /im explorer.exe startup Clipboard tool = ditto.exe ``` Commands run like the Run box (Win+R) with your normal rights: unlike scripts they can start any program, so they get a closer review. Key names (both formats): modifiers `Win`, `Ctrl`, `Alt`, `Shift` (at least one for a hotkey), then a letter, a digit, `F1`–`F24`, `Space`, `Enter`, `Tab`, `Esc`, arrows, `Home`, `End`, `Insert`, `Delete`. A combo another program already holds is skipped. ## Publishing a mod 1. Open a pull request that adds your file to this folder (`name.rhai` or `name.txt`: letters, digits, `-`, `_`) and one line to [`index.txt`](index.txt): `name.rhai | Name | What it does | your-github-name`. CI checks that the catalog and the files match and that every script loads. 2. A moderator reviews the code. Accepted mods are merged and signed: they appear in everyone's store with **✓ Checked by a moderator**, no WinRust update needed. ### For moderators After reviewing a mod (and its every later change): ```powershell powershell -ExecutionPolicy Bypass -File scripts\sign-mods.ps1 name.rhai ``` It writes the file's SHA-256 into `verified.txt` and signs the list into `verified.sig` with the project key (the same key as the update manifests). Commit both with the mod. Files in this folder keep LF line ends (`.gitattributes`), so the hash matches what GitHub serves.