From 80d2e7fd71e111d299ec0d738a3b08b1f2d1e910 Mon Sep 17 00:00:00 2001 From: Uber Veng Date: Fri, 29 May 2026 13:17:30 +0700 Subject: [PATCH] Fix first startup on macOS 2 --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 43c9925..4e0fb84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1203,7 +1203,7 @@ dependencies = [ [[package]] name = "ostiary" -version = "1.1.3" +version = "1.1.4" dependencies = [ "anyhow", "base64", diff --git a/Cargo.toml b/Cargo.toml index 7d08af6..b969d1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ostiary" -version = "1.1.3" +version = "1.1.4" edition = "2024" [dependencies] diff --git a/src/main.rs b/src/main.rs index b790a77..d27f444 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,8 @@ mod updater; use std::io; use anyhow::Result; +#[cfg(unix)] +use libc; use crossterm::{ event::{DisableMouseCapture, EnableMouseCapture}, execute, @@ -29,6 +31,18 @@ async fn main() -> Result<()> { config::Config::create_with_endpoint(&url, &name)? }; + // Before initializing the TUI, ensure our process group is the terminal's + // foreground group. When launched from a non-interactive install script on + // macOS, the parent shell may not have granted terminal ownership, causing + // crossterm's kqueue-based input reader to fail silently. + #[cfg(unix)] + { + use std::os::unix::io::AsRawFd; + if let Ok(tty) = std::fs::File::open("/dev/tty") { + unsafe { libc::tcsetpgrp(tty.as_raw_fd(), libc::getpgrp()); } + } + } + enable_raw_mode()?; let mut stdout = io::stdout(); execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?;