Skip to content

Global shortcut to show the main window (Ctrl+Alt+H) - #379

Merged
fylorn merged 1 commit into
devfrom
feat/377-global-shortcut
Oct 27, 2026
Merged

fylorn merged 1 commit into
devfrom
feat/377-global-shortcut

Conversation

@fylorn

@fylorn fylorn commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Summary

A global shortcut opens the main window from any app. Pressing it again while the window is in front and focused closes it, like the close button.

  • Default: Ctrl+Alt+H (Control+Option+H on macOS), the same keys on all three platforms. On Windows and Linux, Ctrl+Alt acts as AltGr. On US-International, Hungarian, Czech, Polish, German, French and Nordic layouts, H is the only letter that produces no character with AltGr, so the default does not block typing |, @, €, ł and similar characters. It does not clash with system, browser or VS Code defaults; it does clash with "Call Hierarchy" in JetBrains IDEs and Eclipse, and those users can change or turn it off.
  • Settings > General > Global shortcut: click the field and press a combination; Esc cancels. Also Turn Off / Restore Default. A modifier (Ctrl, Alt, Cmd/Win/Super) is required, except for F1–F12. Combinations the app already uses (Ctrl/Cmd+K, +1..9, +=, +-, +0, +, ...) are rejected, because registering them globally would take them away from the app. The current shortcut is unregistered while recording, so it can be recorded again. It is re-registered on cancel, blur, unmount or window close.
  • Registration: the new combination is registered before it is saved. If another app holds it, the previous one stays registered, the setting is unchanged, and the row shows the error. If the default cannot be registered at startup, no notice is shown; the row says it is in use.
  • Storage: app.json "hotkey", e.g. "Ctrl+Alt+H"; "" is off and a missing field is the default. Invalid values read as the default. The setting is per computer and not synced, like the interface size.
  • macOS menu bar: "Open ThinkWatch Lite" shows the shortcut as its key equivalent. Menu item keys now carry their own modifiers (model::Key). When the menu bar is hidden, the Menu bar row's description also mentions the shortcut.
  • Linux Wayland sessions: not supported, so the plugin is not installed and the row is disabled with an explanation. global-hotkey 0.8 uses X11 only, and when it cannot reach X its register still returns Ok without ever receiving keys.
  • The handler hops to the main thread before touching the window, because on Linux the plugin calls it from its own X11 thread.

Uses the official tauri-plugin-global-shortcut 2.4.1 (Carbon RegisterEventHotKey on macOS, which needs no Accessibility permission; RegisterHotKey on Windows; XGrabKey on X11). It is Rust-only, with no JS API or capability.

Test plan

  • cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test (new: text form and off/default, unreadable values, modifier rule, every allowed key maps to a plugin Code, the default is Control+Alt+H, prefs round trip and invalid value, not synced, the menu item key and key-equivalent mapping)
  • tsc -b --noEmit, vitest run (new: key labels, modifier order, in-app combinations rejected)
  • Full-app preview with the commands mocked: the default, recording, the "needs a modifier" and "already used in the app" rejections, Esc clears the message, Turn Off / Restore Default, taken at startup, save rejected as taken (the old combination stays), Wayland (disabled), English
  • Not run in the real app: the global registration and toggle on macOS, Windows and Linux

Closes #377

🤖 Generated with Claude Code

A global shortcut opens the main window from any app; pressing it again
while the window is in front closes it. It is Ctrl+Alt+H by default
(Control+Option+H on macOS), the same keys on all three platforms. H is the
only letter that produces no character with AltGr (Ctrl+Alt on Windows and
Linux) on the common European layouts, so the default does not block typing.

- Settings > General > Global shortcut: record another combination, turn it
  off, or restore the default. A modifier is required except for F1-F12;
  combinations the app already uses (Ctrl/Cmd+K, +1..9, +=, ...) are
  rejected. The current shortcut is released while recording.
- Stored per computer in app.json as "hotkey" ("" = off, missing =
  default); not synced. A combination another app holds is not saved; the
  default failing at startup is shown in the row, not as a notice.
- macOS: the menu bar's "Open ThinkWatch Lite" item shows the shortcut.
- Linux Wayland sessions: not supported (the plugin only speaks X11 and
  would report success without receiving keys); the row is disabled.

Closes #377

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn merged commit f22906b into dev Oct 27, 2026
6 checks passed
@fylorn
fylorn deleted the feat/377-global-shortcut branch October 27, 2026 12:52
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant