Skip to content

Commit 471eb4d

Browse files
committed
[fix] remove rfkill switch support (#174)
The previous fix(0af3d0d) of disabling rfkill-input does not work anymore, this results in the wifi device turning off when starting swhkd.
1 parent a4d2ffe commit 471eb4d

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed

swhkd/src/uinput.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ use evdev::{
33
AttributeSet, Key, RelativeAxisType, SwitchType,
44
};
55

6-
use nix::ioctl_none;
7-
use std::fs::File;
8-
use std::os::unix::io::AsRawFd;
9-
10-
ioctl_none!(rfkill_noinput, b'R', 1);
11-
126
pub fn create_uinput_device() -> Result<VirtualDevice, Box<dyn std::error::Error>> {
137
let keys: AttributeSet<Key> = get_all_keys().iter().copied().collect();
148

@@ -26,20 +20,6 @@ pub fn create_uinput_device() -> Result<VirtualDevice, Box<dyn std::error::Error
2620
pub fn create_uinput_switches_device() -> Result<VirtualDevice, Box<dyn std::error::Error>> {
2721
let switches: AttributeSet<SwitchType> = get_all_switches().iter().copied().collect();
2822

29-
// We have to disable rfkill-input to avoid blocking all radio devices. When
30-
// a new device (virtual or physical) with the SW_RFKILL_ALL capability bit
31-
// set appears, rfkill reacts immediately depending on the value bit. This
32-
// value bit defaults to unset, which causes rfkill to use its default mode
33-
// (which is eop - emergency power off). The uinput API does not give any
34-
// way to set the corresponding value bit before creating the device, and we
35-
// have no way to avoid rfkill acting upon the device creation or to change
36-
// its default mode. Thus, we disable rfkill-input temporarily, hopefully
37-
// fast enough that it won't impact anyone. rfkill-input will be enabled
38-
// again when the file gets closed.
39-
let rfkill_file = File::open("/dev/rfkill")?;
40-
unsafe {
41-
rfkill_noinput(rfkill_file.as_raw_fd())?;
42-
}
4323
let device = VirtualDeviceBuilder::new()?
4424
.name("swhkd switches virtual output")
4525
.with_switches(&switches)?
@@ -622,7 +602,6 @@ pub fn get_all_switches() -> &'static [SwitchType] {
622602
SwitchType::SW_LID,
623603
SwitchType::SW_TABLET_MODE,
624604
SwitchType::SW_HEADPHONE_INSERT,
625-
SwitchType::SW_RFKILL_ALL,
626605
SwitchType::SW_MICROPHONE_INSERT,
627606
SwitchType::SW_DOCK,
628607
SwitchType::SW_LINEOUT_INSERT,

0 commit comments

Comments
 (0)