From 0c88e36ccdc6e93ee273145a52ab3f8f3c96449c Mon Sep 17 00:00:00 2001 From: unsecretised Date: Thu, 16 Jul 2026 16:02:04 +0800 Subject: [PATCH] feat: add ability to not show rustcast automatically on startup --- src/app.rs | 1 + src/app/pages/settings.rs | 10 ++++++++++ src/app/tile/elm.rs | 12 ++++++++---- src/app/tile/update.rs | 1 + src/config.rs | 2 ++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/app.rs b/src/app.rs index fc14b39..1953840 100644 --- a/src/app.rs +++ b/src/app.rs @@ -187,6 +187,7 @@ pub enum SetConfigFields { ShowMenubarIcon(bool), SetPage(MainPage), SetEventDuration(String), + SetShowOnStartup(bool), Modes(Editable<(String, String)>), Aliases(Editable<(String, String)>), SearchDirs(Editable), diff --git a/src/app/pages/settings.rs b/src/app/pages/settings.rs index 2c8739c..4c4a3d8 100644 --- a/src/app/pages/settings.rs +++ b/src/app/pages/settings.rs @@ -282,6 +282,15 @@ fn general_tab(config: Box, theme: crate::config::Theme) -> Column<'stat .into(), ])); + let show_on_startup = settings_row_without_reset(settings_item_row([ + settings_hint_text(theme.clone(), "Show on startup", None::), + Space::new().width(Length::Fill).into(), + toggler(config.clone().show_on_startup) + .style(move |_, status| settings_toggle_style(status)) + .on_toggle(|a| Message::SetConfig(SetConfigFields::SetShowOnStartup(a))) + .into(), + ])); + let auto_update = settings_row_without_reset(settings_item_row([ settings_hint_text(theme.clone(), "Auto update", None::), Space::new().width(Length::Fill).into(), @@ -467,6 +476,7 @@ fn general_tab(config: Box, theme: crate::config::Theme) -> Column<'stat start_at_login, position_dropdown, auto_update, + show_on_startup, haptic, tray_icon, clipboard_history, diff --git a/src/app/tile/elm.rs b/src/app/tile/elm.rs index eeb2fd7..a7db829 100644 --- a/src/app/tile/elm.rs +++ b/src/app/tile/elm.rs @@ -44,12 +44,19 @@ pub fn new(hotkeys: Hotkeys, config: &Config) -> (Tile, Task) { let pos = config.window_location; + let show_on_start = config.show_on_startup; + let open = open.discard().chain(window::run(id, move |handle| { platform::window_config( &handle.window_handle().expect("Unable to get window handle"), pos, ); transform_process_to_ui_element(); + if show_on_start { + Message::OpenWindow + } else { + Message::HideWindow(id) + } })); info!("MacOS platform config applied"); @@ -112,10 +119,7 @@ pub fn new(hotkeys: Hotkeys, config: &Config) -> (Tile, Task) { previous_input_source: None, conn, }, - Task::batch([ - open.map(|_| Message::OpenWindow), - Task::done(Message::LoadClipboardData(300)), - ]), + Task::batch([open, Task::done(Message::LoadClipboardData(300))]), ) } diff --git a/src/app/tile/update.rs b/src/app/tile/update.rs index f4b834e..5b381f8 100644 --- a/src/app/tile/update.rs +++ b/src/app/tile/update.rs @@ -852,6 +852,7 @@ pub fn handle_update(tile: &mut Tile, message: Message) -> Task { SetConfigFields::Modes(Editable::Create((key, value))) => { final_config.modes.insert(key, value); } + SetConfigFields::SetShowOnStartup(show) => final_config.show_on_startup = show, SetConfigFields::SetEventDuration(duration) => { if duration.trim().is_empty() { final_config.event_duration = 0; diff --git a/src/config.rs b/src/config.rs index 7986001..f0cc1e3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -101,6 +101,7 @@ pub struct Config { pub start_at_login: bool, pub theme: Theme, pub window_location: Position, + pub show_on_startup: bool, pub placeholder: String, pub search_url: String, pub haptic_feedback: bool, @@ -132,6 +133,7 @@ impl Default for Config { search_url: "https://duckduckgo.com/search?q=%s".to_string(), cbhist: true, cbhist_paste_on_select: false, + show_on_startup: true, haptic_feedback: false, auto_update: true, show_trayicon: true,