diff --git a/core/internal/config/embedded/niri-binds.kdl b/core/internal/config/embedded/niri-binds.kdl index 6b3d5ac0f..4d4410f8f 100644 --- a/core/internal/config/embedded/niri-binds.kdl +++ b/core/internal/config/embedded/niri-binds.kdl @@ -94,6 +94,12 @@ binds { XF86TouchpadToggle allow-when-locked=true repeat=false { spawn "niri" "msg" "action" "toggle-touchpad"; } + XF86TouchpadOn allow-when-locked=true repeat=false { + spawn "dms" "ipc" "call" "niri" "showTouchpadOsd" "true"; + } + XF86TouchpadOff allow-when-locked=true repeat=false { + spawn "dms" "ipc" "call" "niri" "showTouchpadOsd" "false"; + } // === Window Management === Mod+Q repeat=false { close-window; } diff --git a/quickshell/Services/NiriService.qml b/quickshell/Services/NiriService.qml index d727761d0..66e7650c7 100644 --- a/quickshell/Services/NiriService.qml +++ b/quickshell/Services/NiriService.qml @@ -462,15 +462,19 @@ Singleton { } } - function handleTouchpadToggled(data) { - // Each subscription starts with a snapshot; only later changes show the OSD. - const showOsd = _touchpadStateInitialized && touchpadEnabled !== data.on; - touchpadEnabled = data.on; + function updateTouchpadState(enabled, forceOsd) { + const showOsd = forceOsd || (_touchpadStateInitialized && touchpadEnabled !== enabled); + touchpadEnabled = enabled; _touchpadStateInitialized = true; if (showOsd) touchpadToggled(); } + function handleTouchpadToggled(data) { + // Each subscription starts with a snapshot; only later changes show the OSD. + updateTouchpadState(data.on, false); + } + function handleWorkspacesChanged(data) { const newWorkspaces = {}; @@ -1923,6 +1927,14 @@ window-rule { } IpcHandler { + function showTouchpadOsd(enabled: bool): string { + if (!CompositorService.isNiri) + return "NIRI_NOT_AVAILABLE"; + + root.updateTouchpadState(enabled, true); + return "TOUCHPAD_OSD_SHOWN"; + } + function screenshot(): string { if (!CompositorService.isNiri) { return "NIRI_NOT_AVAILABLE";