keep working on cli shortcuts, unify visibility management
This commit is contained in:
1 parent
47a3e1cfef
commit
4b06dce7f4
10 files changed
+190
-92
No files matched your search
@@ -1,12 +1,14 @@
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use tauri::{
|
||||
AppHandle,
|
||||
GlobalShortcutManager,
|
||||
Manager,
|
||||
async_runtime as rt,
|
||||
};
|
||||
|
||||
use crate::app::APP;
|
||||
use crate::config::HotkeysConfig;
|
||||
use crate::errors::*;
|
||||
use crate::terminal;
|
||||
|
||||
|
||||
@@ -19,11 +21,18 @@ pub enum ShortcutAction {
|
||||
|
||||
pub fn exec_shortcut(action: ShortcutAction) {
|
||||
match action {
|
||||
ShowWindow => {
|
||||
ShortcutAction::ShowWindow => {
|
||||
let app = APP.get().unwrap();
|
||||
app.get_window("main").map(|w| w.show());
|
||||
app.get_window("main")
|
||||
.ok_or("Couldn't find application main window")
|
||||
.map(|w| w.show().error_popup("Failed to show window"))
|
||||
.error_popup("Failed to show window");
|
||||
},
|
||||
ShortcutAction::LaunchTerminal => {
|
||||
rt::spawn(async {
|
||||
terminal::launch(false).await.error_popup("Failed to launch terminal");
|
||||
});
|
||||
},
|
||||
LaunchTerminal => terminal::launch(false),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +44,7 @@ pub fn register_hotkeys(hotkeys: &HotkeysConfig) -> tauri::Result<()> {
|
||||
|
||||
if hotkeys.show_window.enabled {
|
||||
manager.register(
|
||||
hotkeys.show_window.keys,
|
||||
&hotkeys.show_window.keys,
|
||||
|| exec_shortcut(ShortcutAction::ShowWindow)
|
||||
)?;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user