flightlessmango / MangoHud

A Vulkan and OpenGL overlay for monitoring FPS, temperatures, CPU/GPU load and more. Discord: https://discordapp.com/invite/Gj5YmBb
MIT License
6.33k stars 278 forks source link

Keybinds do not work on Wayland #658

Closed fee1-dead closed 2 months ago

bonscji1 commented 2 years ago

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.

papaya2k commented 2 years ago

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

cyberconan commented 2 years ago

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

flightlessmango commented 2 years ago

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

soredake commented 2 years ago

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

zany130 commented 2 years ago

@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

jackun commented 2 years ago

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

zany130 commented 2 years ago

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

jackun commented 2 years ago

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)

Etaash-mathamsetty commented 1 year ago

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.

orowith2os commented 1 year ago

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()

flightlessmango commented 1 year ago

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

Etaash-mathamsetty commented 1 year ago

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

Etaash-mathamsetty commented 6 months ago

merged :)

flightlessmango commented 2 months ago

this has been resolved