MangoHud icon indicating copy to clipboard operation
MangoHud copied to clipboard

Keybinds do not work on Wayland

Open fee1-dead opened this issue 3 years ago • 14 comments

fee1-dead avatar Dec 19 '21 13:12 fee1-dead

Hi folks, could i ask that description for shortcuts is updated to say this is not supported on wayland? I am a dummy and tried for some hours now to fix this perceived issue not realizing it is not implemented yet :D.

bonscji1 avatar May 18 '22 08:05 bonscji1

I second fixing this, as Wayland is the future of desktop Linux, not X11.

papaya2k avatar May 22 '22 18:05 papaya2k

+1 Please, fix keybinding in Wayland. Thanks!!!

cyberconan avatar May 25 '22 19:05 cyberconan

So far I'm unaware of a way to achieve this in Wayland. It almost seems to me like it's not doable by design

flightlessmango avatar May 27 '22 16:05 flightlessmango

https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/73 https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/56 Maybe related.

soredake avatar May 27 '22 16:05 soredake

@flightlessmango not sure if this could be done in mangohud but a lot of apps that require hotkeys to use the app, such as ulauncher (to toggle to launcher) and nyrna(to toggle whether an application is suspended or not) use a terminal command to achieve the desired toggable effect and then ask the user to map that command to a keyboard shortcut with the DE shortcutmanager

for example ulauncher added the ulauncher-toggle and then i just add a keyboard shortcut for that in kde

image

zany130 avatar Jun 02 '22 20:06 zany130

What a PITA but you can test drive with native wayland vulkan apps: https://github.com/flightlessmango/MangoHud/tree/focus_loss

@zany130 probably a simpler way indeed

jackun avatar Jun 02 '22 20:06 jackun

I was able to get around this with this script

File: Scripts/toggleMangoHud.sh
#!/bin/bash
config_file=~/.config/MangoHud/MangoHud.conf
no_disp=$(grep -i 'no_display=' "$config_file" | awk '{ print $3 }')

if grep -q "no_display=0" "$config_file"; then
    sed -i 's/no_display=0/no_display=1/' "$config_file"
    notify-send "MangoHud was turned Off"
elif grep -q "no_display=1" "$config_file"; then
    sed -i 's/no_display=1/no_display=0/' "$config_file"
    notify-send "MangoHud was turned On"
else
    notify-send "ERROR value not found"
fi

and then adding it to kde shortcut settings image

zany130 avatar Jun 11 '22 03:06 zany130

Git master can also use python script for some basic control in https://github.com/flightlessmango/MangoHud/tree/master/control if you enable abstract socket with control = mangohud or per-process control = mangohud-%p and specify socket with e.g. -s mangohud-$(pidof vkcube)

jackun avatar Jun 11 '22 14:06 jackun

There is a way to achieve this under Wayland, it would work basically identically to the wayland keylogger project. The other option is the global shortcuts portal, but we don't need it to be global.

Etaash-mathamsetty avatar Aug 16 '23 18:08 Etaash-mathamsetty

Via jadahl:

create a .so file that has wl_display_connect() exported. in there, dlopen libwayland-client.so and find the correct wl_display_connect address. when you get called, call the "real" function, but store away a proxy wrapper of the return value. get your own registry, find the seat, get a wl_keyboard and start listening to events.

And a bit of a warning, if relevant, from Arnavion:

Note that the LD_PRELOAD'ing to hook libwayland-client functions only works for processes that use libwayland-client Worst case you'll have to hook connect()

orowith2os avatar Aug 16 '23 19:08 orowith2os

This has been attempted before, might be worth to look at for reference https://github.com/flightlessmango/MangoHud/commit/26c8d1dbdda16ae3af53c3aa7a71eaeb3ffd4acd

flightlessmango avatar Aug 16 '23 19:08 flightlessmango

very initial version ready: https://github.com/flightlessmango/MangoHud/pull/1093

Etaash-mathamsetty avatar Aug 17 '23 01:08 Etaash-mathamsetty

merged :)

Etaash-mathamsetty avatar Feb 29 '24 04:02 Etaash-mathamsetty