Skip to content

Add X11 global shortcuts - #8

Merged
DevanMetz merged 4 commits into
mainfrom
grok/x11-hotkeys
Oct 28, 2026
Merged

DevanMetz merged 4 commits into
mainfrom
grok/x11-hotkeys

Conversation

@DevanMetz

Copy link
Copy Markdown
Owner

What

On X11, OpenSnip now uses the same global shortcuts as Windows. The defaults are Win + Shift + S, PrtSc, Shift + PrtSc, and Ctrl + PrtSc. Settings → Shortcuts edits them. Wayland still uses the desktop's own bindings for opensnip --snip, --snip-delay, and --repeat.

Why

The Linux app could capture a region, but only after something else launched it. The shortcut strings already live in the shared settings file, so an X11 session can honor the same chords without a new settings format.

A chord the desktop already owns is left alone, and the others still register. Alt + PrtSc and Win + PrtSc stay with the desktop. Changing a shortcut grabs the keyboard only until the next chord, so a bare letter can be rejected and the next try still lands.

How tested

  • dotnet test tests/OpenSnip.Hotkeys.Tests/OpenSnip.Hotkeys.Tests.csproj -c Release — 8 passed. The live test grabs a chord, checks that a plain key stays free, captures a shortcut, then fires the chord that was just captured. It returns immediately when DISPLAY is unset, which is what CI has.
  • dotnet build src/OpenSnip.csproj -c Release -p:EnableWindowsTargeting=true — succeeded, 0 warnings. No Windows source changed.
  • On an X11 session: Win + Shift + S, PrtSc, and Ctrl + PrtSc open the overlay; Shift + PrtSc counts down, then opens it; Alt + PrtSc does not. Changing Snip to Ctrl + Shift + B (after a rejected bare A) opens the overlay on the new chord and not the old one. Clearing the chord and toggling Print Screen updates the grabs. Quitting releases them. error.log stayed empty.
  • Wayland was not available here, so the command list was not clicked through. It is the previous Shortcuts page, shown when the X11 service does not start.

A settings file can move between the two apps, and the grab plan refuses a bare typing key.
The hotkey thread does not share Avalonia's Display. A chord the desktop already owns is skipped, and changing a shortcut grabs the keyboard only until the next chord.
On X11 the Shortcuts page edits the chords. Wayland keeps the command list, and the tray names the snip shortcut.
# Conflicts:
#	.github/workflows/build.yml
#	README.md
#	linux/App.cs
#	linux/SettingsWindow.cs
@DevanMetz
DevanMetz merged commit c6b7eca into main Oct 28, 2026
2 checks passed
@DevanMetz
DevanMetz deleted the grok/x11-hotkeys branch October 28, 2026 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant