Skip to content

Commit 91c96ae

Browse files
avalonresetclaude
andcommitted
Unified tray: HYPERYAP tooltip, hotkeys toggle, close = full exit
- Tray tooltip changed from "HYPERYAP STT" to "HYPERYAP" - Right-click menu now has "Hotkeys Enabled" checkbox toggle (kills daemon to pause, relaunches to resume) - Closing the app window now exits entirely (kills daemon too) instead of hiding to background silently Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 88db1ce commit 91c96ae

2 files changed

Lines changed: 44 additions & 6 deletions

File tree

src-tauri/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,9 @@ pub fn run() {
278278
Ok(())
279279
})
280280
.on_window_event(|window, event| {
281-
if let tauri::WindowEvent::CloseRequested { api, .. } = event {
282-
api.prevent_close();
283-
let _ = window.hide();
281+
if let tauri::WindowEvent::CloseRequested { .. } = event {
282+
// Close the app entirely (daemon gets killed via RunEvent::Exit)
283+
window.app_handle().exit(0);
284284
}
285285
})
286286
.invoke_handler(tauri::generate_handler![

src-tauri/src/overlay/tray.rs

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1-
use tauri::menu::{Menu, MenuItem};
1+
use std::sync::atomic::{AtomicBool, Ordering};
2+
use tauri::menu::{CheckMenuItem, Menu, MenuItem};
23
use tauri::tray::{TrayIconBuilder, TrayIconEvent};
34
use tauri::{AppHandle, Manager};
45

6+
static HOTKEYS_PAUSED: AtomicBool = AtomicBool::new(false);
7+
8+
/// Check whether the user has paused hotkeys from the tray menu.
9+
pub fn are_hotkeys_paused() -> bool {
10+
HOTKEYS_PAUSED.load(Ordering::SeqCst)
11+
}
12+
513
pub fn setup_tray(app: &AppHandle) -> Result<(), Box<dyn std::error::Error>> {
614
let show_i = MenuItem::with_id(app, "show", "Open HyperYap", true, None::<&str>)?;
15+
let hotkeys_i = CheckMenuItem::with_id(app, "hotkeys", "Hotkeys Enabled", true, true, None::<&str>)?;
716
let quit_i = MenuItem::with_id(app, "quit", "Quit", true, None::<&str>)?;
8-
let menu = Menu::with_items(app, &[&show_i, &quit_i])?;
17+
let menu = Menu::with_items(app, &[&show_i, &hotkeys_i, &quit_i])?;
918

1019
let builder = TrayIconBuilder::new()
1120
.menu(&menu)
@@ -16,6 +25,11 @@ pub fn setup_tray(app: &AppHandle) -> Result<(), Box<dyn std::error::Error>> {
1625
let _ = window.set_focus();
1726
}
1827
}
28+
"hotkeys" => {
29+
let was_paused = HOTKEYS_PAUSED.load(Ordering::SeqCst);
30+
HOTKEYS_PAUSED.store(!was_paused, Ordering::SeqCst);
31+
toggle_hotkeys_daemon(!was_paused);
32+
}
1933
"quit" => {
2034
app.exit(0);
2135
}
@@ -42,8 +56,32 @@ pub fn setup_tray(app: &AppHandle) -> Result<(), Box<dyn std::error::Error>> {
4256

4357
let _tray = builder
4458
.icon(app.default_window_icon().unwrap().clone())
45-
.tooltip("HYPERYAP STT")
59+
.tooltip("HYPERYAP")
4660
.build(app)?;
4761

4862
Ok(())
4963
}
64+
65+
/// Toggle the hotkey daemon: kill it to pause, relaunch to resume.
66+
#[cfg(target_os = "windows")]
67+
fn toggle_hotkeys_daemon(pause: bool) {
68+
use std::os::windows::process::CommandExt;
69+
use std::process::Command;
70+
71+
if pause {
72+
let _ = Command::new("cmd")
73+
.args(["/C", "taskkill /F /IM hyperyap-hotkeys.exe >nul 2>&1"])
74+
.creation_flags(0x08000000)
75+
.status();
76+
} else {
77+
let hotkeys_path = std::path::PathBuf::from(std::env::var("LOCALAPPDATA").unwrap_or_default())
78+
.join("HyperYap")
79+
.join("hyperyap-hotkeys.exe");
80+
if hotkeys_path.exists() {
81+
let _ = Command::new(&hotkeys_path).arg("--no-tray").spawn();
82+
}
83+
}
84+
}
85+
86+
#[cfg(not(target_os = "windows"))]
87+
fn toggle_hotkeys_daemon(_pause: bool) {}

0 commit comments

Comments
 (0)