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

[fix] remove rfkill switch support #254

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions swhkd/src/uinput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ use evdev::{
AttributeSet, Key, RelativeAxisType, SwitchType,
};

use nix::ioctl_none;
use std::fs::File;
use std::os::unix::io::AsRawFd;

ioctl_none!(rfkill_noinput, b'R', 1);

pub fn create_uinput_device() -> Result<VirtualDevice, Box<dyn std::error::Error>> {
let keys: AttributeSet<Key> = get_all_keys().iter().copied().collect();

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

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