From 632b0a444595cc267d20d3bb8f2ad713656540c1 Mon Sep 17 00:00:00 2001 From: Mohammad Aadil Shabier Date: Sun, 10 Mar 2024 23:36:11 +0530 Subject: [PATCH 1/2] [fix] remove rfkill switch support The previous fix(0af3d0d) of disabling rfkill-input does not work anymore, this results in the wifi device turning off when starting swhkd. --- swhkd/src/uinput.rs | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/swhkd/src/uinput.rs b/swhkd/src/uinput.rs index f0684ae..1aabd20 100644 --- a/swhkd/src/uinput.rs +++ b/swhkd/src/uinput.rs @@ -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> { let keys: AttributeSet = get_all_keys().iter().copied().collect(); @@ -26,20 +20,6 @@ pub fn create_uinput_device() -> Result Result> { let switches: AttributeSet = 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)? @@ -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, From 9779e6755b9dcd01b57a8e5579471009e66de975 Mon Sep 17 00:00:00 2001 From: Manthan Patil Date: Tue, 7 Jan 2025 19:34:34 +0000 Subject: [PATCH 2/2] update cargo.lock --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index da4ef56..773489a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -767,8 +767,8 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "sweet" -version = "0.3.0" -source = "git+https://github.com/waycrate/sweet.git#a91d1ab6fb7988578ce359cfbf55e75b813d84db" +version = "0.4.0" +source = "git+https://github.com/waycrate/sweet.git#797d88bfefe8242b96da6b20afa40d489d3ec076" dependencies = [ "anyhow", "bitflags 2.6.0",