device.led()后的grab()关闭led

2024-05-15 18:03:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我可以使用evdev读取NUML\u的LED状态。但是,如果我在退出程序时读取led后抓取()设备,led将关闭,即使系统的状态仍为打开

import evdev

device = evdev.InputDevice('/dev/input/event3')

try:
    print(device.leds(verbose=True))
    print("Using device:\n" + str(device))
    device.grab()
except  (KeyboardInterrupt, SystemExit):
    pass

如果我只做grab()device.leds()中的一个而不做另一个,它们(如预期的那样)不会关闭。但调用这两个都会使LED出现问题

编辑: 我刚刚意识到,如果LED\ NUML和LED\ CAPSL在我退出时打开,则LED熄灭,但当我按下num\ U lock或caps\ U lock时,另一个按钮的状态也会得到修复

即:

- LED_NUML and LED_CAPSL are on
- run script
- LED_NUML and LED_CAPSL are off
- press num_lock turns num_lock off (LED_NUML is already off so it stays off)
- LED_CAPSL turns on

Tags: andlockleddevice状态numareprint
1条回答
网友
1楼 · 发布于 2024-05-15 18:03:34

在这个时候是不可能的。内核中有一个问题。正如ssieb在python evdev问题页面about this issue上所说的那样

When a device is released, all handlers attached to the device get restarted. My guess is that there is some handler that is resetting the LEDs.

相关问题 更多 >