Repository navigation
feat: make a command and a menu entry for a program with raven env shortcut - #56
Merged
MotherSphere merged 2 commits intoNov 3, 2026
Merged
Conversation
…hortcut` `raven env shortcut <env> <command> -- <argv>` writes three files, the way an installer would: - `~/.local/bin/<command>` (or `$XDG_BIN_HOME`), a shell script that runs `raven run <env> -- <argv> "$@"`. It writes what the program prints to `$XDG_RUNTIME_DIR/raven-logs/<command>.log` and keeps the start before as `.log.1`, since a program started from the menu has no terminal. - `~/.local/share/applications/raven-shortcut-<command>.desktop`, an applications menu entry that runs the command. - The program's icon, read out of its `.exe` and written as a PNG to `~/.local/share/Colony/Raven/icons/<command>.png`. Without a command it lists the environment's shortcuts, and `--remove` deletes all three files. Each file is marked as Raven's, and a file without that mark is never replaced or deleted. Raven also warns when the bin directory is not on PATH, or when another program of that name comes first on it. The icon reader (`icon.rs`) follows the first RT_GROUP_ICON to its largest image. A PNG image is taken as it is. A bitmap is decoded (32-bit with alpha, or 24, 8, 4 and 1 bit with the AND mask) and written as a PNG with stored deflate blocks, so the crate gets no new dependency.
ghahramani
force-pushed
the
feat/shortcut-commands
branch
from
November 3, 2026 02:40
d9a11de to
fe8f91a
Compare
- A shortcut cannot be named `wine` or `wineserver`, nor after any other program on PATH, nor after a bare first word of the command line it runs: `raven run` execs that word by PATH, inside the environment too, and would start the shortcut again instead of Wine. - Without --cwd the program starts in its own directory inside the environment, as a Windows shortcut starts it; `setns` used to leave it in Z:\. When the program is not found, Raven says so. - The log goes to ~/.cache/Colony/Raven/logs, a directory made 0700, instead of the runtime directory, a small tmpfs that also holds the session records. It is written only when no stream is a terminal, so a menu launch is logged and `game > out.txt` typed in a terminal is not redirected. - Another environment's shortcut of the same name is refused instead of taken over. Removal deletes the menu entry, the icon, then the command, reports an entry it kept because it was not Raven's, and stops on an error. Names are at most 64 characters, ownership is checked before the program is read, and the menu entry is written last. - X-Raven-Shortcut= comes right after the header, so a long title cannot push it past what is read. A temporary file is no longer listed. - A program over 512 MiB is not read, and the read is bounded whatever the size claims. A C: path with `..` is refused. Paths that are not UTF-8 are refused instead of rewritten. The layers are found without the runtime directory. - icon.rs: the section offset is added in usize (a PointerToRawData near u32::MAX panicked in debug builds); the images of the group are tried largest first, at most 16; a PNG image needs an IHDR within 1024 pixels and 4 MiB; the palette and pixels are cut out before decoding. from_exe returns the PNG bytes, and the module is crate-private. - The temporary file write is shared with registry::text::write_atomic, which now also uses a dot-prefixed name. - `raven env destroy` says when the environment's shortcuts are left. - Strings, French wording and docs follow; 245 tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Starting a program means typing the whole
raven run <env> -- wine 'C:\…\program.exe'line every time. A program installed by copying a folder (a portable build, a game's own launcher) leaves no Start menu shortcut for Wine to turn into a menu entry, so it never appears in the applications menu. Started from a launcher, it has no terminal either, so whatever it prints when it crashes is lost.What changes
raven env shortcut <env> <command> [--title NAME] [--cwd DIR] -- <argv>writes three files, the way an installer would:~/.local/bin/<command>, or$XDG_BIN_HOME/<command>when that is set. It is a shell script that runsraven run <env> [--cwd DIR] -- <argv> "$@", so arguments given to the command reach the program. It writes stdout and stderr to$XDG_RUNTIME_DIR/raven-logs/<command>.logand keeps the start before as.log.1. Started from a terminal, it first prints where the log is. The script names the Raven binary by its path and falls back toravenonPATHonce that binary has moved.~/.local/share/applications/raven-shortcut-<command>.desktop, which runs the command. It setsStartupWMClassto the program's file name in lower case, as Wine's own entries do, so the panel can match the program's windows to the entry..exeand saved as~/.local/share/Colony/Raven/icons/<command>.png. The program is found by itsC:path in the environment's layers (upper first, names matched without case, no mount needed). When there is no icon to read, the entry shows Raven's.How it behaves:
.exe, unless--titlegives one.--removedeletes all three files. Both still work after the environment is destroyed.ShortcutTaken), and nothing is half-written when the menu entry's name is the one taken.-_.+, not starting with-or.), andraven,rvn,raven-guiandraven-linuxare refused.PATH, or when another program of that name comes first on it.icon.rsreads the icon without a new dependency:RT_GROUP_ICON(the one Explorer shows) and that group's largest image.Other changes:
paths::bin_dirandpaths::logs_dir. The logs go in$XDG_RUNTIME_DIR/raven-logs, besideraven/rather than inside it, because every name inraven/is an environment's.BadShortcutName,ShortcutTaken,NoSuchShortcut,ShortcutFile), with every string in English and French.usage.md, the new files inmount-stack.md's "Where files live", a README bullet, and the test counts.Testing
cargo test --workspace: 231 passed (213 before).sh. They check that arguments containing quotes,$, spaces and*reach Raven intact, that both streams reach the log and the previous start is kept, the fallback toravenonPATH, the menu entry's contents, that files Raven did not write are left alone, listing and removal by environment, finding the program through the layers without case, and the PATH report.cargo clippy --workspace --all-targets -- -D warnings: clean.desktop-file-validate, and the game's 256×256 icon.wine cmd /c ver, started withgio launchon its menu entry, loggedMicrosoft Windows 10.0.22000, the same as when it is started from a shell.winecfg,regedit,taskmgrandcalcall gave the right icon.mspaint, whose Windows 11 executable is a stub with no icon, got Raven's.--removedeleted all three files of each test shortcut.Not tested: a desktop other than KDE Plasma, or a
--cwdshortcut started from the menu.