尋找負責的設備

尋找負責的設備

我有一台2022 HP 14" Spectre x360,它可以翻轉為平板電腦模式,並有一個加速度計來切換螢幕方向。但是,當我在其上安裝Ubuntu 22.04 時,我發現將其切換到或退出平板電腦模式時,會切換螢幕方向,或關閉或開啟蓋子都可以切換飛行模式。

這似乎是惠普筆記型電腦上比較常見的問題(雖然我之前的Spectre從未遇過)。在第一個答案中找到了修復程序這個帖子,但不幸的是它似乎不適用於我的系統。

此修復依賴將「關閉蓋子」和「定向」操作(分別為 e057 和 e058)的鍵碼設定為「KEY_UNKNOWN」鍵碼 (240)。我關於它為什麼不適用於我的系統的理論是因為由於某種原因我的新筆記型電腦或 Ubuntu 22.04 更改了關閉蓋子和更改方向的操作 ID。我嘗試使用 找出新的鍵碼 xev,但切換方向/平板電腦模式沒有顯示任何內容,並且合上蓋子給出的輸出我沒有發現有幫助(如下所示):

MappingNotify event, serial 37, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

FocusOut event, serial 37, synthetic NO, window 0x3400001,
    mode NotifyGrab, detail NotifyAncestor

FocusIn event, serial 38, synthetic NO, window 0x3400001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 38, synthetic NO, window 0x0,
    keys:  4294967225 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

FocusOut event, serial 38, synthetic NO, window 0x3400001,
    mode NotifyGrab, detail NotifyAncestor

FocusIn event, serial 38, synthetic NO, window 0x3400001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 38, synthetic NO, window 0x0,
    keys:  2   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

FocusOut event, serial 38, synthetic NO, window 0x3400001,
    mode NotifyGrab, detail NotifyAncestor

FocusIn event, serial 38, synthetic NO, window 0x3400001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 38, synthetic NO, window 0x0,
    keys:  2   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

MappingNotify event, serial 38, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyPress event, serial 38, synthetic NO, window 0x3400001,
    root 0x7b9, subw 0x0, time 3122108, (1160,-364), root:(1209,776),
    state 0x0, keycode 248 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 39, synthetic NO, window 0x3400001,
    root 0x7b9, subw 0x0, time 3122125, (1160,-364), root:(1209,776),
    state 0x0, keycode 248 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

PropertyNotify event, serial 39, synthetic NO, window 0x3400001,
    atom 0x1a4 (_GTK_EDGE_CONSTRAINTS), time 3122199, state PropertyNewValue

PropertyNotify event, serial 39, synthetic NO, window 0x3400001,
    atom 0x1a4 (_GTK_EDGE_CONSTRAINTS), time 3122203, state PropertyNewValue

KeyPress event, serial 39, synthetic NO, window 0x3400001,
    root 0x7b9, subw 0x0, time 3123167, (1160,-364), root:(1209,776),
    state 0x0, keycode 248 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 39, synthetic NO, window 0x3400001,
    root 0x7b9, subw 0x0, time 3123184, (1160,-364), root:(1209,776),
    state 0x0, keycode 248 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

PropertyNotify event, serial 39, synthetic NO, window 0x3400001,
    atom 0x1a4 (_GTK_EDGE_CONSTRAINTS), time 3123191, state PropertyNewValue

PropertyNotify event, serial 39, synthetic NO, window 0x3400001,
    atom 0x1a4 (_GTK_EDGE_CONSTRAINTS), time 3123197, state PropertyNewValue

MappingNotify event, serial 39, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

FocusOut event, serial 39, synthetic NO, window 0x3400001,
    mode NotifyGrab, detail NotifyAncestor

FocusIn event, serial 40, synthetic NO, window 0x3400001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 40, synthetic NO, window 0x0,
    keys:  2   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

FocusOut event, serial 40, synthetic NO, window 0x3400001,
    mode NotifyNormal, detail NotifyNonlinear

PropertyNotify event, serial 40, synthetic NO, window 0x3400001,
    atom 0x175 (_NET_WM_STATE), time 3151384, state PropertyNewValue

PropertyNotify event, serial 40, synthetic NO, window 0x3400001,
    atom 0x1a4 (_GTK_EDGE_CONSTRAINTS), time 3151384, state PropertyNewValue

MappingNotify event, serial 40, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

我還查看了journalctl -f,它在切換平板電腦模式、切換方向或打開/關閉蓋子時提供以下輸出:

Aug 27 10:48:57 puter gnome-shell[2029]: Window manager warning: Overwriting existing binding of keysym 32 with keysym 32 (keycode b).
Aug 27 10:48:57 puter gnome-shell[2029]: Window manager warning: Overwriting existing binding of keysym 31 with keysym 31 (keycode a).
Aug 27 10:48:57 puter gnome-shell[2029]: Window manager warning: Overwriting existing binding of keysym 33 with keysym 33 (keycode c).
Aug 27 10:48:57 puter gnome-shell[2029]: Window manager warning: Overwriting existing binding of keysym 34 with keysym 34 (keycode d).
Aug 27 10:48:57 puter gnome-shell[2029]: Window manager warning: Overwriting existing binding of keysym 35 with keysym 35 (keycode e).
Aug 27 10:48:57 puter gnome-shell[2029]: Window manager warning: Overwriting existing binding of keysym 36 with keysym 36 (keycode f).
Aug 27 10:48:57 puter gnome-shell[2029]: Window manager warning: Overwriting existing binding of keysym 37 with keysym 37 (keycode 10).
Aug 27 10:48:57 puter gnome-shell[2029]: Window manager warning: Overwriting existing binding of keysym 39 with keysym 39 (keycode 12).
Aug 27 10:48:57 puter gnome-shell[2029]: Window manager warning: Overwriting existing binding of keysym 38 with keysym 38 (keycode 11).
Aug 27 10:48:57 puter systemd[1]: Starting Load/Save RF Kill Switch Status...
Aug 27 10:48:57 puter NetworkManager[675]: <info>  [1661618937.7480] manager: rfkill: Wi-Fi now enabled by radio killswitch
Aug 27 10:48:57 puter systemd[1]: Started Load/Save RF Kill Switch Status.
Aug 27 10:48:58 puter NetworkManager[675]: <info>  [1661618938.0189] manager: rfkill: WWAN hardware radio set enabled
Aug 27 10:48:58 puter NetworkManager[675]: <info>  [1661618938.0193] audit: op="radio-control" arg="wwan-enabled:on" pid=2237 uid=1000 result="success"
Aug 27 10:48:58 puter NetworkManager[675]: <info>  [1661618938.0543] device (wlo1): supplicant interface state: internal-starting -> disconnected
Aug 27 10:48:58 puter NetworkManager[675]: <info>  [1661618938.0544] device (p2p-dev-wlo1): state change: unavailable -> unmanaged (reason 'removed', sys-iface-state: 'removed')
Aug 27 10:48:58 puter NetworkManager[675]: <info>  [1661618938.0549] Wi-Fi P2P device controlled by interface wlo1 created
Aug 27 10:48:58 puter NetworkManager[675]: <info>  [1661618938.0552] manager: (p2p-dev-wlo1): new 802.11 Wi-Fi P2P device (/org/freedesktop/NetworkManager/Devices/7)
Aug 27 10:48:58 puter NetworkManager[675]: <info>  [1661618938.0554] device (p2p-dev-wlo1): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Aug 27 10:48:58 puter NetworkManager[675]: <info>  [1661618938.0558] device (wlo1): state change: unavailable -> disconnected (reason 'supplicant-available', sys-iface-state: 'managed')
Aug 27 10:48:58 puter NetworkManager[675]: <info>  [1661618938.0563] device (p2p-dev-wlo1): state change: unavailable -> disconnected (reason 'none', sys-iface-state: 'managed')
Aug 27 10:48:58 puter gnome-shell[2029]: Removing a network device that was not added
Aug 27 10:49:01 puter wpa_supplicant[696]: wlo1: CTRL-EVENT-REGDOM-CHANGE init=DRIVER type=COUNTRY alpha2=US
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.2389] policy: auto-activating connection 'hcdj' (4888999a-9a1c-4c66-9e1a-a833d092f6c0)
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.2396] device (wlo1): Activation: starting connection 'hcdj' (4888999a-9a1c-4c66-9e1a-a833d092f6c0)
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.2397] device (wlo1): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.2401] manager: NetworkManager state is now CONNECTING
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.2403] device (wlo1): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.2407] device (wlo1): Activation: (wifi) access point 'hcdj' has security, but secrets are required.
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.2408] device (wlo1): state change: config -> need-auth (reason 'none', sys-iface-state: 'managed')
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.2425] device (wlo1): state change: need-auth -> prepare (reason 'none', sys-iface-state: 'managed')
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.2428] device (wlo1): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.2431] device (wlo1): Activation: (wifi) connection 'hcdj' has security, and secrets exist.  No new secrets needed.
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.2432] Config: added 'ssid' value 'hcdj'
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.2432] Config: added 'scan_ssid' value '1'
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.2432] Config: added 'bgscan' value 'simple:30:-70:86400'
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.2433] Config: added 'key_mgmt' value 'WPA-PSK WPA-PSK-SHA256 FT-PSK SAE FT-SAE'
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.2433] Config: added 'auth_alg' value 'OPEN'
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.2433] Config: added 'psk' value '<hidden>'
Aug 27 10:49:01 puter wpa_supplicant[696]: wlo1: SME: Trying to authenticate with 58:24:29:94:95:3a (SSID='hcdj' freq=5745 MHz)
Aug 27 10:49:01 puter kernel: wlo1: authenticate with 58:24:29:94:95:3a
Aug 27 10:49:01 puter kernel: wlo1: send auth to 58:24:29:94:95:3a (try 1/3)
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.2651] device (wlo1): supplicant interface state: disconnected -> authenticating
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.2652] device (p2p-dev-wlo1): supplicant management interface state: disconnected -> authenticating
Aug 27 10:49:01 puter wpa_supplicant[696]: wlo1: Trying to associate with 58:24:29:94:95:3a (SSID='hcdj' freq=5745 MHz)
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.3030] device (wlo1): supplicant interface state: authenticating -> associating
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.3031] device (p2p-dev-wlo1): supplicant management interface state: authenticating -> associating
Aug 27 10:49:01 puter kernel: wlo1: authenticated
Aug 27 10:49:01 puter kernel: wlo1: associate with 58:24:29:94:95:3a (try 1/3)
Aug 27 10:49:01 puter kernel: wlo1: RX AssocResp from 58:24:29:94:95:3a (capab=0x1011 status=0 aid=8)
Aug 27 10:49:01 puter wpa_supplicant[696]: wlo1: Associated with 58:24:29:94:95:3a
Aug 27 10:49:01 puter wpa_supplicant[696]: wlo1: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Aug 27 10:49:01 puter kernel: wlo1: associated
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.3324] device (wlo1): supplicant interface state: associating -> 4way_handshake
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.3324] device (p2p-dev-wlo1): supplicant management interface state: associating -> 4way_handshake
Aug 27 10:49:01 puter wpa_supplicant[696]: wlo1: WPA: Key negotiation completed with 58:24:29:94:95:3a [PTK=CCMP GTK=CCMP]
Aug 27 10:49:01 puter wpa_supplicant[696]: wlo1: CTRL-EVENT-CONNECTED - Connection to 58:24:29:94:95:3a completed [id=0 id_str=]
Aug 27 10:49:01 puter kernel: IPv6: ADDRCONF(NETDEV_CHANGE): wlo1: link becomes ready
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.3791] device (wlo1): supplicant interface state: 4way_handshake -> completed
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.3792] device (wlo1): Activation: (wifi) Stage 2 of 5 (Device Configure) successful. Connected to wireless network "hcdj"
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.3793] device (p2p-dev-wlo1): supplicant management interface state: 4way_handshake -> completed
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.3795] device (wlo1): state change: config -> ip-config (reason 'none', sys-iface-state: 'managed')
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.3803] dhcp4 (wlo1): activation: beginning transaction (timeout in 45 seconds)
Aug 27 10:49:01 puter avahi-daemon[669]: Joining mDNS multicast group on interface wlo1.IPv6 with address fe80::821d:62c4:9abf:42fa.
Aug 27 10:49:01 puter avahi-daemon[669]: New relevant interface wlo1.IPv6 for mDNS.
Aug 27 10:49:01 puter avahi-daemon[669]: Registering new address record for fe80::821d:62c4:9abf:42fa on wlo1.*.
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.4146] dhcp4 (wlo1): state changed new lease, address=192.168.86.82
Aug 27 10:49:01 puter kernel: wlo1: Limiting TX power to 30 (30 - 0) dBm as advertised by 58:24:29:94:95:3a
Aug 27 10:49:01 puter avahi-daemon[669]: Joining mDNS multicast group on interface wlo1.IPv4 with address 192.168.86.82.
Aug 27 10:49:01 puter avahi-daemon[669]: New relevant interface wlo1.IPv4 for mDNS.
Aug 27 10:49:01 puter avahi-daemon[669]: Registering new address record for 192.168.86.82 on wlo1.IPv4.
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.4191] device (wlo1): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'managed')
Aug 27 10:49:01 puter dbus-daemon[673]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.10' (uid=0 pid=675 comm="/usr/sbin/NetworkManager --no-daemon " label="unconfined")
Aug 27 10:49:01 puter systemd[1]: Starting Network Manager Script Dispatcher Service...
Aug 27 10:49:01 puter dbus-daemon[673]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Aug 27 10:49:01 puter systemd[1]: Started Network Manager Script Dispatcher Service.
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.4349] device (wlo1): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.4351] device (wlo1): state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.4354] manager: NetworkManager state is now CONNECTED_LOCAL
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.4367] manager: NetworkManager state is now CONNECTED_SITE
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.4368] policy: set 'hcdj' (wlo1) as default for IPv4 routing and DNS
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.4380] device (wlo1): Activation: successful, device activated.
Aug 27 10:49:01 puter systemd-resolved[607]: wlo1: Bus client set search domain list to: lan
Aug 27 10:49:01 puter systemd-resolved[607]: wlo1: Bus client set default route setting: yes
Aug 27 10:49:01 puter systemd-resolved[607]: wlo1: Bus client set DNS server list to: 192.168.86.1
Aug 27 10:49:01 puter wpa_supplicant[696]: wlo1: CTRL-EVENT-SIGNAL-CHANGE above=1 signal=-54 noise=9999 txrate=234000
Aug 27 10:49:01 puter NetworkManager[675]: <info>  [1661618941.5717] manager: NetworkManager state is now CONNECTED_GLOBAL
Aug 27 10:49:02 puter systemd[1]: systemd-rfkill.service: Deactivated successfully.
Aug 27 10:49:06 puter NetworkManager[675]: <info>  [1661618946.0826] manager: rfkill: Wi-Fi now disabled by radio killswitch
Aug 27 10:49:06 puter NetworkManager[675]: <info>  [1661618946.0827] device (wlo1): state change: activated -> unavailable (reason 'none', sys-iface-state: 'managed')
Aug 27 10:49:06 puter systemd[1]: Starting Load/Save RF Kill Switch Status...
Aug 27 10:49:06 puter kernel: wlo1: deauthenticating from 58:24:29:94:95:3a by local choice (Reason: 3=DEAUTH_LEAVING)
Aug 27 10:49:06 puter NetworkManager[675]: <info>  [1661618946.0829] dhcp4 (wlo1): canceled DHCP transaction
Aug 27 10:49:06 puter NetworkManager[675]: <info>  [1661618946.0829] dhcp4 (wlo1): activation: beginning transaction (timeout in 45 seconds)
Aug 27 10:49:06 puter NetworkManager[675]: <info>  [1661618946.0830] dhcp4 (wlo1): state changed no lease
Aug 27 10:49:06 puter systemd[1]: Started Load/Save RF Kill Switch Status.
Aug 27 10:49:06 puter wpa_supplicant[696]: wlo1: CTRL-EVENT-DISCONNECTED bssid=58:24:29:94:95:3a reason=3 locally_generated=1
Aug 27 10:49:06 puter wpa_supplicant[696]: BSSID 58:24:29:94:95:3a ignore list count incremented to 2, ignoring for 10 seconds
Aug 27 10:49:06 puter avahi-daemon[669]: Interface wlo1.IPv6 no longer relevant for mDNS.
Aug 27 10:49:06 puter avahi-daemon[669]: Leaving mDNS multicast group on interface wlo1.IPv6 with address fe80::821d:62c4:9abf:42fa.
Aug 27 10:49:06 puter avahi-daemon[669]: Interface wlo1.IPv4 no longer relevant for mDNS.
Aug 27 10:49:06 puter avahi-daemon[669]: Leaving mDNS multicast group on interface wlo1.IPv4 with address 192.168.86.82.
Aug 27 10:49:06 puter avahi-daemon[669]: Withdrawing address record for fe80::821d:62c4:9abf:42fa on wlo1.
Aug 27 10:49:06 puter avahi-daemon[669]: Withdrawing address record for 192.168.86.82 on wlo1.
Aug 27 10:49:06 puter wpa_supplicant[696]: rfkill: WLAN soft blocked
Aug 27 10:49:06 puter wpa_supplicant[696]: rfkill: WLAN soft blocked
Aug 27 10:49:06 puter systemd-resolved[607]: wlo1: Bus client reset search domain list.
Aug 27 10:49:06 puter systemd-resolved[607]: wlo1: Bus client set default route setting: no
Aug 27 10:49:06 puter systemd-resolved[607]: wlo1: Bus client reset DNS server list.
Aug 27 10:49:06 puter NetworkManager[675]: <info>  [1661618946.1568] manager: NetworkManager state is now DISCONNECTED
Aug 27 10:49:06 puter wpa_supplicant[696]: p2p-dev-wlo1: CTRL-EVENT-DSCP-POLICY clear_all
Aug 27 10:49:06 puter wpa_supplicant[696]: p2p-dev-wlo1: CTRL-EVENT-DSCP-POLICY clear_all
Aug 27 10:49:06 puter wpa_supplicant[696]: nl80211: deinit ifname=p2p-dev-wlo1 disabled_11b_rates=0
Aug 27 10:49:06 puter wpa_supplicant[696]: wlo1: CTRL-EVENT-DSCP-POLICY clear_all
Aug 27 10:49:06 puter NetworkManager[675]: <info>  [1661618946.2158] device (p2p-dev-wlo1): state change: disconnected -> unavailable (reason 'supplicant-failed', sys-iface-state: 'managed')
Aug 27 10:49:06 puter NetworkManager[675]: <info>  [1661618946.2379] manager: rfkill: WWAN hardware radio set disabled
Aug 27 10:49:06 puter NetworkManager[675]: <info>  [1661618946.2380] audit: op="radio-control" arg="wwan-enabled:off" pid=2237 uid=1000 result="success"
Aug 27 10:49:06 puter wpa_supplicant[696]: wlo1: CTRL-EVENT-DSCP-POLICY clear_all
Aug 27 10:49:06 puter wpa_supplicant[696]: nl80211: deinit ifname=wlo1 disabled_11b_rates=0
Aug 27 10:49:08 puter google-chrome.desktop[2759]: [2753:2782:0827/104908.122472:ERROR:connection_factory_impl.cc(425)] Failed to connect to MCS endpoint with error -106
Aug 27 10:49:11 puter systemd[1]: systemd-rfkill.service: Deactivated successfully.
Aug 27 10:49:16 puter systemd[1]: NetworkManager-dispatcher.service: Deactivated successfully.

它以多個密鑰 ID 開頭,但更改其中任何一個都不能解決問題。

所以我想我的問題是找出將哪些鍵 ID 設置為 240 的最佳方法是什麼,以便在更改筆記型電腦螢幕時防止飛行模式。

答案1

我遇到了同樣的問題,飛行模式會被啟動和停用(至少在移動蓋子時)。

  • 裝置: HP HP Spectre x360 二合一筆記型電腦 14-ef2xxx
  • 帶德語鍵盤
  • Ubuntu 22.04 LTS

將掃描碼 e057 和 e058 對應到鍵碼 240 沒有幫助。使用

sudo showkey

移動蓋子表明,如果蓋子在向前或向後方向上與桌子(或圈:D)相交約 45 度,則按下並釋放鍵 247(在我的機器上是飛行模式)。

但是,重複相同的過程

sudo showkey -s

顯示沒有掃描碼被啟動。因此,僅使用將某些掃描代碼對應到某些鍵代碼可能無法解決此問題setkeycodes

我在[1]的幫助下修復了它,這與[2]類似。遵循後者一對一對我來說不起作用。顯然,我需要與作者不同的設備才能受到鍵映射的影響。

我花了很長時間尋找答案、反覆試驗,並對專家級的貼文感到困惑。至少我學到了一些東西。為了希望您和其他人免受這種情況的困擾,我嘗試使這個逐步解決方案盡可能對新手友好。

尋找負責的設備

透過 Ctrl + Alt + T 開啟終端機。

鍵入(然後輸入)

cat /proc/bus/input/devices

取得設備清單。一個名為「英特爾 HID 事件」的事件,

I: Bus=0019 Vendor=0000 Product=0000 Version=0000
N: Name="Intel HID events"
P: Phys=
S: Sysfs=/devices/platform/INTC1070:00/input/input35
U: Uniq=
H: Handlers=rfkill kbd event17 
B: PROP=0
B: EV=13
B: KEY=1000300000000 5000004000 1e294000000020 0
B: MSC=10

可能是負責的,因為它有 rfkill(停用所有無線電,即 wlan、藍牙等)作為處理程序。我將其稱為裝置從現在開始。

取得鍵碼

在測試設備並取得金鑰代碼之前,請安裝 evtest。鍵入(然後輸入)

sudo apt install -y evtest

如果出現提示,請提供您的密碼。要測試裝置是否負責並取得金鑰程式碼,請開啟一個虛擬終端(在普通終端 X 中,基本上就是您的 Ubuntu GUI,可能會使此測試變得不可能)。通常這是透過 Ctrl + Alt + F1 完成的,但在我的例子中,F1 必須替換為 F3。若要回到 X,請按 Ctrl + Alt + F2(在我的範例中)。在其他機器上,它通常看起來是 F7。我透過反覆試驗找到了適合我的鑰匙。

提供您的使用者名稱和密碼。鍵入(然後輸入)

sudo evtest /dev/input/event17

在我的例子中,它是 event17,因為它位於裝置的 Handler 欄位中,請參見上文。我注意到,如果我將滑鼠和鍵盤連接到我的筆記型電腦,數字會改變。因此,在您的情況下,它可能是一個不同的數字。

接下來,關閉並打開蓋子。透過Ctrl + C退出evtest的測試模式,透過Ctrl + Alt + F2退出虛擬終端(在我的例子中)。在我的螢幕上,這是在 evtest 期間列印的:

Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x0 product 0x0 version 0x0
Input device name: "Intel HID events"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 69 (KEY_NUMLOCK)
    Event code 102 (KEY_HOME)
    Event code 104 (KEY_PAGEUP)
    Event code 107 (KEY_END)
    Event code 109 (KEY_PAGEDOWN)
    Event code 113 (KEY_MUTE)
    Event code 114 (KEY_VOLUMEDOWN)
    Event code 115 (KEY_VOLUMEUP)
    Event code 116 (KEY_POWER)
    Event code 142 (KEY_SLEEP)
    Event code 164 (KEY_PLAYPAUSE)
    Event code 166 (KEY_STOPCD)
    Event code 224 (KEY_BRIGHTNESSDOWN)
    Event code 225 (KEY_BRIGHTNESSUP)
    Event code 240 (KEY_UNKNOWN)
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
Properties:
Testing ... (interrupt to exit)
Event: time 1684340717.813043, type 4 (EV_MSC), code 4 (MSC_SCAN), value 08
Event: time 1684340717.813043, type 1 (EV_KEY), code 247 (KEY_RFKILL), value 1
Event: time 1684340717.813043, -------------- SYN_REPORT ------------
Event: time 1684340717.813055, type 1 (EV_KEY), code 247 (KEY_RFKILL), value 0
Event: time 1684340717.813055, -------------- SYN_REPORT ------------
Event: time 1684340721.308956, type 4 (EV_MSC), code 4 (MSC_SCAN), value 08
Event: time 1684340721.308956, type 1 (EV_KEY), code 247 (KEY_RFKILL), value 1
Event: time 1684340721.308956, -------------- SYN_REPORT ------------
Event: time 1684340721.308963, type 1 (EV_KEY), code 247 (KEY_RFKILL), value 0
Event: time 1684340721.308963, -------------- SYN_REPORT ------------

如果您希望將其列印在檔案中,例如您的主目錄中的 evtest_output.txt ~,請輸入

sudo evtest /dev/input/event17 > ~/evtest_output.txt

而是在上面的步驟中。但請注意,在測試期間您不會看到螢幕上列印的輸出。

讓我們檢查一下 evtest_output.txt 的內容。首先,它告訴我們一些設備規格和支援的事件。下面Testing...有十個在蓋子移動過程中列印的事件。前五事屬於關蓋,後五事屬於開蓋。請注意,我沒有完全關閉它。傾斜約45度就足以觸發飛行模式。這證實了設備「Intel HID 事件」對此負責。

使用 hwdb 修復

為了使用 hwdb 解決此問題,我透過在終端機中鍵入(然後按 Enter)建立了檔案 intel-HID-events.hwdb

sudo nano /etc/udev/hwdb.d/intel-HID-events.hwdb

我輸入的內容是(就我而言)

evdev:input:b0019v0000p0000e0000-*
 KEYBOARD_KEY_08=unknown

第一行中的數字是設備的匯流排 (0019)、供應商 (0000)、產品 (0000) 和版本 (0000) 欄位(請參閱cat /proc/us/input/devices上面提示的輸出)。之後的星號*是任意數量符號的佔位符。然而,我沒有像[1]中進一步指定。我的原因是,當我(斷開)連接其他硬體(例如我的滑鼠)時,設備的模態似乎會改變。

注意第二行的縮排。鍵 08,即 evtest 中關閉或開啟時第一個事件的值(MSC_SCAN 之後),被設定為未知。

使用 Ctrl + O 儲存,按 Enter,然後使用 Ctrl + X 關閉。

sudo systemd-hwdb update

sudo udevadm trigger

這是來自[2]。

移動蓋子。它不應再觸發飛行模式。我不必像[2]中所做的那樣使這些更改“永久”。重新啟動後問題仍然修復。讓我們看看下一次更新是否會取消修復...

我希望這對您或其他人有幫助!

乾杯jk


參考

[1]https://yulistic.gitlab.io/2017/12/linux-keymapping-with-udev-hwdb/

[2]切換到平板電腦模式時飛航模式切換 (HP Spectre x360)

相關內容