From 673cddfff682e730667625a0b5f1e0ed5d4ef7b8 Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Thu, 19 Nov 2026 18:49:30 +0100 Subject: [PATCH] app: build as a windowed app so no console opens with it The exe was a console-subsystem binary, so every launch allocated a console window: from Explorer, from the Run key at login, everywhere. The PE header now says windowed (`windows_subsystem = "windows"`), and Windows creates no console for the process. The printing modes still work from a shell: `attach_console` borrows the console of whatever started the app, and does nothing when nothing did. The daemon was already spawned with `DETACHED_PROCESS`, so it never had a window of its own, and ffmpeg goes through `ffmpeg-sidecar`, which passes `CREATE_NO_WINDOW` on each spawn. --- app/Cargo.toml | 1 + app/README.md | 5 +++++ app/src/main.rs | 22 ++++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/app/Cargo.toml b/app/Cargo.toml index 5bec074..db86dbf 100644 --- a/app/Cargo.toml +++ b/app/Cargo.toml @@ -27,6 +27,7 @@ ureq = "3.5" winreg = "0.56" windows = { version = "0.62", features = [ "Win32_Foundation", + "Win32_System_Console", "Win32_System_Diagnostics_ToolHelp", "Win32_System_Threading", ] } diff --git a/app/README.md b/app/README.md index d2b1552..39956e5 100644 --- a/app/README.md +++ b/app/README.md @@ -9,6 +9,11 @@ named-pipe protocol and draws with [rune](https://github.com/anomalyco/rune). cargo run ``` +The binary is a windowed app on Windows (`windows_subsystem = "windows"` in `main.rs`), so +launching it from Explorer, the Run key or the login item never opens a console. The printing +modes still work from a shell: `attach_console` borrows the console of whatever started the app, +and nothing happens when nothing did. + The app starts the daemon if it isn't running, then reads its settings and status. `cargo run -- --probe` does the same without a window and prints the daemon's answers; `cargo run -- --games` prints how many timelines load from disk. diff --git a/app/src/main.rs b/app/src/main.rs index b3e9706..7a05a06 100644 --- a/app/src/main.rs +++ b/app/src/main.rs @@ -2,6 +2,11 @@ //! //! Replaces `tauri-app`. The daemon keeps its IPC protocol; this app is a client of it. //! `cargo run` opens the window; `cargo run -- --snap out.png` renders it headless. +//! +//! The binary is a windowed app on Windows, so launching it from Explorer, the Run key or the +//! login item never opens a console. The printing modes (`--games`, `--probe`, `--snap`) borrow +//! the console of the shell that started them (`attach_console`). +#![cfg_attr(target_os = "windows", windows_subsystem = "windows")] mod app; mod daemon; @@ -19,9 +24,26 @@ mod settings; mod theme; mod ui; +/// Print to the shell that started this app, when there is one. +/// +/// A windowed process has no console of its own, so `println!` from `--probe` or `--snap` would +/// go nowhere under `cmd`. The shell's console is still there to attach to; when the app is +/// started from Explorer or the login item there is none and this does nothing. +#[cfg(target_os = "windows")] +fn attach_console() { + use windows::Win32::System::Console::{ATTACH_PARENT_PROCESS, AttachConsole}; + unsafe { + let _ = AttachConsole(ATTACH_PARENT_PROCESS); + } +} + +#[cfg(not(target_os = "windows"))] +fn attach_console() {} + use rune::AppSpec; fn main() { + attach_console(); if std::env::args().any(|arg| arg == "--games") { println!("{} timelines", crate::history::timeline_paths().len()); return;