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.
This commit is contained in:
vhaudiquet committed 2026-11-19 18:49:30 +01:00
1 parent eabc3780c9
commit 673cddfff6
3 files changed
+28

No files matched your search

+1
View File
@@ -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",
] }
+5
View File
@@ -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.
+22
View File
@@ -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;