Wayland 세션에서 노트북 덮개가 닫힐 때 입력 장치를 자동으로 비활성화하려면 어떻게 해야 합니까?

Wayland 세션에서 노트북 덮개가 닫힐 때 입력 장치를 자동으로 비활성화하려면 어떻게 해야 합니까?

X11 실행 acpid를 설치하고 /etc/acpi/handler.sh 스크립트를 수정하여 xinput을 사용하여 이 작업을 수행할 수 있습니다.

    button/lid)
    case "$3" in
        close)
            #set variables so xinput can access the desktop session
            XAUTHORITY=/home/netsplit/.Xauthority DISPLAY=:0 xinput disable 10
            XAUTHORITY=/home/netsplit/.Xauthority DISPLAY=:0 xinput disable 11
            logger 'LID closed'
            ;;
        open)
            XAUTHORITY=/home/netsplit/.Xauthority DISPLAY=:0 xinput enable 10
            XAUTHORITY=/home/netsplit/.Xauthority DISPLAY=:0 xinput enable 11
            logger 'LID opened'

그러나 xinput은 Wayland에서 작동하지 않습니다. 또한 xauthority는 Wayland와 아무런 관련이 없습니다. libinput을 살펴봤지만 셸에서 특정 기능을 비활성화/활성화하는 방법을 제공하지 않는 것 같습니다.

수동으로 절전 모드를 활성화하는 것을 선호하므로 절전은 옵션이 아닙니다. 가끔은 노트북 덮개를 닫은 채 작업을 하기도 합니다.

때로는 덮개를 닫으면 트랙패드와 키보드가 꺼져서 여러 텍스트와 창으로 돌아가는 경우도 있습니다. X에서 덮개를 닫을 때 비활성화하면 문제가 해결되었습니다. Wayland를 작동시키려고 합니다.

답변1

좋아요, 저는 Plasma와 Wayland에서만 작동하지 않는 솔루션을 찾았습니다.

리눅스 5.11 추가금지입력 장치의 속성은 정확히 내가 원하는 것입니다.

내가 해야 할 일은 다음과 같습니다.

cat /proc/bus/input/devices | more

그런 다음 입력 장치 Sysfs=... 값을 찾습니다.

예를 들어 키보드는 다음과 같습니다.

I: Bus=0011 Vendor=0001 Product=0001 Version=ab41
N: Name="AT Translated Set 2 keyboard"
P: Phys=isa0060/serio0/input0
S: Sysfs=/devices/platform/i8042/serio0/input/input3
U: Uniq=
H: Handlers=sysrq kbd leds event3 rfkill 
B: PROP=0
B: EV=120013
B: KEY=20000 20 0 0 1100f02100000 3803078f900d401 feffffdfffefffff fffffffffffffffe
B: MSC=10
B: LED=7

Sysfs=/devices/platform/i8042/serio0/input/input3은 /sys/devices/platform/i8042/serio0/input/input3/inhibited에 1을 쓰면 커널이 키보드 입력을 비활성화한다고 알려줍니다. 재부팅하지 않으면 해결하기 어려우므로 주의해서 수행하세요.

마찬가지로 터치패드의 값은 Sysfs=/devices/platform/i8042/serio1/input/input8입니다. 같은. echo 1 > /sys/devices/platform/i8042/serio1/input/input8/inhibited는 터치패드를 비활성화합니다.

수행 방법에 대한 부분은 다음과 같습니다.

acpid 설치(정확한 명령은 패키지 관리자에 따라 다름)

/etc/acpi/handler.sh를 맨 아래에 있도록 수정합니다. 입력 장치의 sysfs 값이 다른 경우 경로를 변경해야 할 수도 있습니다.

button/lid)
    case "$3" in
        close)
    echo 1 > /sys/devices/platform/i8042/serio1/input/input8/inhibited 
    echo 1 > /sys/devices/platform/i8042/serio0/input/input3/inhibited
            logger 'LID closed'
            ;;
        open)
    echo 0 > /sys/devices/platform/i8042/serio1/input/input8/inhibited
    echo 0 > /sys/devices/platform/i8042/serio0/input/input3/inhibited
            logger 'LID opened'
            ;;
        *)
            logger "ACPI action undefined: $3"
            ;;

참고로 내 전체 /etc/acpi/handler.sh 파일은 다음과 같습니다.

#!/bin/bash
# Default acpi script that takes an entry for all actions

case "$1" in
    button/up)
;;
    button/down)
;;
    button/right)
;;
    button/left)
;;
    button/power)
        case "$2" in
            PBTN|PWRF)
                logger 'PowerButton pressed'
                ;;
            *)
                logger "ACPI action undefined: $2"
                ;;
        esac
        ;;
    button/sleep)
        case "$2" in
            SLPB|SBTN)
                logger 'SleepButton pressed'
                ;;
            *)
                logger "ACPI action undefined: $2"
                ;;
        esac
        ;;
    ac_adapter)
        case "$2" in
            AC|ACAD|ADP0)
                case "$4" in
                    00000000)
                        logger 'AC unpluged'
                        ;;
                    00000001)
                        logger 'AC pluged'
                        ;;
                esac
                ;;
            *)
                logger "ACPI action undefined: $2"
                ;;
        esac
        ;;
    battery)
        case "$2" in
            BAT0)
                case "$4" in
                    00000000)
                        logger 'Battery online'
                        ;;
                    00000001)
                        logger 'Battery offline'
                        ;;
                esac
                ;;
            CPU0)
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/lid)
        case "$3" in
            close)
        echo 1 > /sys/devices/platform/i8042/serio1/input/input8/inhibited 
        echo 1 > /sys/devices/platform/i8042/serio0/input/input3/inhibited
                logger 'LID closed'
                ;;
            open)
        echo 0 > /sys/devices/platform/i8042/serio1/input/input8/inhibited
        echo 0 > /sys/devices/platform/i8042/serio0/input/input3/inhibited
                logger 'LID opened'
                ;;
            *)
                logger "ACPI action undefined: $3"
                ;;
    esac
    ;;
    *)
        logger "ACPI group/action undefined: $1 / $2"
        ;;
esac

# vim:set ts=4 sw=4 ft=sh et:

관련 정보