WaylandKeybinds: localized info panel with setup steps

- Info panel in the plugin modal: live status with the number of keybinds
  GNOME registered, the three setup steps and a button that opens
  Discord's Keybinds page (closes only the plugin modal, which otherwise
  blocks settings navigation).
- Follows Discord's language: English, Portuguese (pt-BR) and Spanish
  (es-ES and es-419 use each region's action names); bold labels quote
  Discord's own strings.
- Shared helpers moved to discord.ts; copy and locale choice in copy.ts,
  covered by basis-path tests (41 tests).
- README: current settings path (User Settings > System > Keybinds).
This commit is contained in:
Evandro Fonseca Junior committed 2026-11-02 01:24:50 -03:00
1 parent a3a9149184
commit 34b61e2509
7 files changed
+351 -18

No files matched your search

+8 -16
View File
@@ -4,15 +4,14 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { IS_LINUX } from "@utils/constants";
import { Logger } from "@utils/Logger";
import definePlugin from "@utils/types";
import { findStoreLazy } from "@webpack";
import { AboutPanel } from "./about";
import { KeybindsStore, portalActive, portalTrigger, Shortcut } from "./discord";
import { adjustOptions, Callback, createDispatcher, Dispatcher, fixPortalState, KeyEventOptions, planRegistration, PortalState, Scheduler } from "./logic";
import { PATCHES } from "./patches";
type Shortcut = [number, number, ...unknown[]][];
import managedStyle from "./style.css?managed";
// Discord's own native keybind bridge (the object the KeybindsStore registers through)
interface Bridge {
@@ -28,28 +27,21 @@ const scheduler: Scheduler = {
};
const logger = new Logger("WaylandKeybinds");
const KeybindsStore = findStoreLazy("KeybindsStore");
function discordUtils() {
return DiscordNative.nativeModules.requireModule("discord_utils");
}
function portalTrigger(shortcut: Shortcut): string {
return discordUtils().getWaylandPortalTrigger?.(shortcut.map(([type, code]) => [type, code])) ?? "";
}
export default definePlugin({
name: "WaylandKeybinds",
description: "Makes Discord's global keybinds reliable on GNOME Wayland: toggles (mute, deafen) fire on key press and push-to-talk recovers from key releases GNOME drops",
description: "Makes Discord's keybinds work in every app on Linux Wayland: set them up in Discord's Keybinds page as usual and allow the system prompt",
authors: [{ name: "Evandro", id: 281463271758888960n }],
// only changes behaviour when Discord registers keybinds through the Wayland GlobalShortcuts portal
enabledByDefault: true,
patches: PATCHES,
managedStyle,
settingsAboutComponent: AboutPanel,
wrapRegistration(bridge: Bridge, id: number, shortcut: Shortcut, callback: Callback, options: KeyEventOptions): [Callback, KeyEventOptions] {
try {
const portalActive = IS_LINUX && discordUtils().isWaylandGlobalShortcutsAvailable?.() === true;
const mode = planRegistration(options, portalActive, portalActive && portalTrigger(shortcut) !== "");
const active = portalActive();
const mode = planRegistration(options, active, active && portalTrigger(shortcut) !== "");
const adjusted = adjustOptions(options, mode);
dispatchers.get(id)?.cancel();
const dispatcher = createDispatcher(callback, mode, () => {