Skip to content

Commit 3f4c0e4

Browse files
authored
Merge pull request #49 from VariableThe/fix/wayland-shortcuts-and-behavior
fix: make window auto-hide and alt keybinds conditional for Hyprland
2 parents 441ae60 + 6f872e0 commit 3f4c0e4

15 files changed

Lines changed: 122 additions & 62 deletions

File tree

AUDIT_LOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
This log tracks all significant changes, updates, and versions in the PaperCache project.
44

5+
## 2026-06-23 - (Uncommitted)
6+
**Change:** fix: shift all keybinds to Alt and disable window auto-hide
7+
8+
**Details/Why:**
9+
Changed default keybindings across the application from `Ctrl/Cmd` to `Alt` to prevent conflicts. Disabled auto-hide on focus loss in `lib.rs` to allow the app to be used as a persistent window, fixing Wayland shortcut issues.
10+
11+
---
512

613
## 2026-06-23 - a250dce8a
714
**Change:** feat: enable auto-updates on startup and add manual check button

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
### Changed
2020
- **Tauri Migration**: PaperCache has been fully migrated from Electron to Tauri, reducing memory usage, startup time, and application size while preserving existing workflows.
2121
- The macOS distribution format is now `.tar.gz` and `.app` to circumvent strict macOS 14 runner restrictions with `osascript`. The Homebrew Cask automation pulls the `.tar.gz` bundle.
22+
- **Keybindings**: Changed default global and internal keybindings from `Ctrl/Cmd` to `Alt` to prevent conflicts with terminal emulators and OS shortcuts.
23+
- **Window Behavior**: Disabled the "hide on focus loss" behavior so the application acts as a standard window, fixing global shortcut limitations on Wayland compositors (like Hyprland).
2224

2325
### Fixed
2426
- Addressed multiple edge-cases with `CodeMirror` state overwrites causing typed text to disappear or duplicate.

package-lock.json

Lines changed: 12 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/src/commands/fs.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,26 @@ pub fn set_dialog_open(state: tauri::State<'_, crate::DialogState>, open: bool)
198198
}
199199

200200
pub fn run_onboarding() {
201+
let is_hyprland = std::env::var("HYPRLAND_INSTANCE_SIGNATURE").is_ok() || std::env::var("HYPRLAND_CMD").is_ok();
202+
let mod_key = if is_hyprland { "Alt" } else { "Command/Ctrl" };
203+
201204
if let Ok(base) = get_papercache_dir() {
202205
let welcome_path = base.join("Welcome.md");
206+
207+
let welcome_content = format!(
208+
"# Welcome to PaperCache\n\nThis is your first note. Start typing to edit it, or use {} + Shift + N to create a new one!",
209+
mod_key
210+
);
211+
203212
if !welcome_path.exists() {
204-
let _ = fs::write(&welcome_path, "# Welcome to PaperCache\n\nThis is your first note. Start typing to edit it, or use shortcuts to create a new one!");
213+
let _ = fs::write(&welcome_path, &welcome_content);
214+
} else {
215+
// Force update if the file contains the old generic shortcut text
216+
if let Ok(content) = fs::read_to_string(&welcome_path) {
217+
if content.contains("use shortcuts to create a new one!") || content.contains("Command/Ctrl + Shift + N") || content.contains("Alt + Shift + N") {
218+
let _ = fs::write(&welcome_path, &welcome_content);
219+
}
220+
}
205221
}
206222

207223
let commands_dir = base.join("commands");

src-tauri/src/commands/system.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,8 @@ pub async fn check_for_updates(app: tauri::AppHandle) -> Result<(), String> {
8787
}
8888
Ok(())
8989
}
90+
91+
#[tauri::command]
92+
pub fn is_hyprland() -> Result<bool, String> {
93+
Ok(std::env::var("HYPRLAND_INSTANCE_SIGNATURE").is_ok() || std::env::var("HYPRLAND_CMD").is_ok())
94+
}

src-tauri/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ pub fn run() {
7676
tauri::WindowEvent::Focused(focused)
7777
if !focused && !is_dialog_open.load(Ordering::SeqCst) =>
7878
{
79-
let _ = w.hide();
79+
let is_hyprland = std::env::var("HYPRLAND_INSTANCE_SIGNATURE").is_ok() || std::env::var("HYPRLAND_CMD").is_ok();
80+
if !is_hyprland {
81+
let _ = w.hide();
82+
}
8083
}
8184
_ => {}
8285
}
@@ -107,6 +110,7 @@ pub fn run() {
107110
commands::system::open_file,
108111
commands::system::set_launch_at_startup,
109112
commands::system::check_for_updates,
113+
commands::system::is_hyprland,
110114
commands::keychain::set_api_key,
111115
commands::keychain::get_api_key_status,
112116
commands::keychain::get_api_key,

src/App.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ function App() {
4747

4848
useEffect(() => {
4949
window.electronAPI.checkForUpdates()
50+
window.electronAPI.isHyprland().then((isHyp) => {
51+
useAppStore.getState().setIsHyprland(isHyp)
52+
})
5053
}, [])
5154

5255
useEffect(() => {

0 commit comments

Comments
 (0)