Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pynput not detecting media keys on kde plasma wayland #580

Open
walksanatora opened this issue Dec 12, 2023 · 1 comment
Open

pynput not detecting media keys on kde plasma wayland #580

walksanatora opened this issue Dec 12, 2023 · 1 comment

Comments

@walksanatora
Copy link

walksanatora commented Dec 12, 2023

Description
A clear and concise description of what the bug is.
all keyboard and numpad keys (excluding the media keys) are being detected but not the play/pause, stop, or skip foward/back buttons

Platform and pynput version
Your operating system and version, and the version of pynput.
Linux archiev3 6.6.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 11 Dec 2023 11:48:23 +0000 x86_64 GNU/Linux
pynput 1.7.6
I should also specify I am on wayland desktop

To Reproduce

def on_press(key):
    if str(key) == 'Key.media_next':
        print("media next")
    elif str(key) == 'Key.media_play_pause':
        print("media play/pause")
    elif str(key) == '<269025045>':
        print("media stop")
    elif str(key) == 'Key.media_previous':
        print("media previous")
    else: 
        print("unknown key:", str(key))
        pass

listener_thread = Listener(on_press=on_press, on_release=None)
listener_thread.start()

while true:
    pass

press mmedia keys and none appear

@blu006
Copy link

blu006 commented Mar 20, 2024

Hello,

I have had a similar issue in KDE plasma wayland.

My function keys f13-f18 (haven't tested further yet) do not work.

I think this is because "under the hood," pynput does not have bindings for wayland but only for xorg.

Here is what my code looks like, btw. Nice to see that somebody else has found another way to work around this issue:

#!/usr/bin/python3

# toggles LEDs based on the button pressed

import sys
import sal_kblib as sal
import json
from pynput import keyboard
from threading import Event

def on_press(key):
    print(key)
    if key == keyboard.KeyCode(269025153):
        sal.toggle_led(interface, 0)
    if key == keyboard.KeyCode(269025093):
        sal.toggle_led(interface, 1)
    if key == keyboard.KeyCode(269025094):
        sal.toggle_led(interface, 2)
    if key == keyboard.KeyCode(269025095):
        sal.toggle_led(interface, 3)
    if key == keyboard.KeyCode(269025096):
        sal.toggle_led(interface, 4)
    if key == keyboard.KeyCode(269025097):
        sal.toggle_led(interface, 5)


if __name__ == '__main__':
    evnt = Event()
    interface = sal.get_hid_interface();

    listener = keyboard.Listener(on_press = on_press)
    listener.start()

    while True:
        # essentially does nothing but reset the watchdog
        sal.toggle_led(interface, 0xff)
        evnt.wait(1);

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

No branches or pull requests

2 participants