Skip to content

Commit 4bc8e51

Browse files
authored
Add shortcut to open settings (#935)
* Add command+comma shortcut to open settings * Update apps/desktop/src-tauri/src/hotkeys.rs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * unsafe double unwrap replaced with proper error handling * make preferences keybind non-configurable * fix HotkeyAction type * handle OpenSettings outside of hotkey store
1 parent f93c941 commit 4bc8e51

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

apps/desktop/src-tauri/src/hotkeys.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{RequestStartRecording, recording};
1+
use crate::{RequestStartRecording, recording, windows::ShowCapWindow};
22
use global_hotkey::HotKeyState;
33
use serde::{Deserialize, Serialize};
44
use specta::Type;
@@ -81,6 +81,13 @@ pub fn init(app: &AppHandle) {
8181
OnEscapePress.emit(app).ok();
8282
}
8383

84+
if shortcut.key == Code::Comma && shortcut.mods == Modifiers::META {
85+
let app = app.clone();
86+
tokio::spawn(async move {
87+
let _ = ShowCapWindow::Settings { page: None }.show(&app).await;
88+
});
89+
}
90+
8491
let state = app.state::<HotkeysState>();
8592
let store = state.lock().unwrap();
8693

@@ -94,7 +101,14 @@ pub fn init(app: &AppHandle) {
94101
)
95102
.unwrap();
96103

97-
let store = HotkeysStore::get(app).unwrap().unwrap_or_default();
104+
let mut store = match HotkeysStore::get(app) {
105+
Ok(Some(s)) => s,
106+
Ok(None) => HotkeysStore::default(),
107+
Err(e) => {
108+
eprintln!("Failed to load hotkeys store: {e}");
109+
HotkeysStore::default()
110+
}
111+
};
98112

99113
let global_shortcut = app.global_shortcut();
100114
for hotkey in store.hotkeys.values() {

apps/desktop/src/routes/(window-chrome)/settings/hotkeys.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function Inner(props: { initialStore: HotkeysStore | null }) {
169169
when={hotkeys[item()]}
170170
fallback={
171171
<p
172-
class="flex items-center text-[11px] uppercase transition-colors hover:bg-gray-6 hover:border-gray-7
172+
class="flex items-center text-[11px] uppercase transition-colors hover:bg-gray-6 hover:border-gray-7
173173
cursor-pointer py-3 px-2.5 h-5 bg-gray-4 border border-gray-5 rounded-lg text-gray-11 hover:text-gray-12"
174174
>
175175
None

0 commit comments

Comments
 (0)