diff --git a/.gitignore b/.gitignore index ebe541e..8d7a724 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /node_modules /.direnv result +.DS_Store diff --git a/CHANGELOG.md b/CHANGELOG.md index e3823fa..9de78aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ For changes in `@project-gauntlet/tools` see [separate CHANGELOG.md](https://git ## [Unreleased] +- Global shortcut how hides the main window if it is already open - It is now possible to run commands and open views using CLI command - Format: `gauntlet run ` - Plugin ID can be found in Settings UI diff --git a/rust/client/src/global_shortcut.rs b/rust/client/src/global_shortcut.rs index 02e9707..32bad0d 100644 --- a/rust/client/src/global_shortcut.rs +++ b/rust/client/src/global_shortcut.rs @@ -17,7 +17,7 @@ pub fn register_listener(msg_sender: Sender) { if let global_hotkey::HotKeyState::Released = e.state() { handle.spawn(async move { - if let Err(err) = msg_sender.send(AppMsg::ShowWindow).await { + if let Err(err) = msg_sender.send(AppMsg::ToggleWindowFocus).await { tracing::warn!(target = "rpc", "error occurred when receiving shortcut event {:?}", err) } }); diff --git a/rust/client/src/ui/mod.rs b/rust/client/src/ui/mod.rs index bc9cceb..cf82f2d 100644 --- a/rust/client/src/ui/mod.rs +++ b/rust/client/src/ui/mod.rs @@ -245,6 +245,7 @@ pub enum AppMsg { FontLoaded(Result<(), font::Error>), ShowWindow, HideWindow, + ToggleWindowFocus, ToggleActionPanel { keyboard: bool, }, @@ -1132,6 +1133,7 @@ fn update(state: &mut AppModel, message: AppMsg) -> Task { result.expect("unable to load font"); Task::none() } + AppMsg::ToggleWindowFocus => state.toggle_window_focus(), AppMsg::ShowWindow => state.show_window(), AppMsg::HideWindow => state.hide_window(), AppMsg::ShowPreferenceRequiredView { @@ -2203,6 +2205,14 @@ impl AppModel { } } + fn toggle_window_focus(&mut self) -> Task { + if self.focused { + self.hide_window() + } else { + self.show_window() + } + } + fn hide_window(&mut self) -> Task { self.focused = false; self.opened = false;