Fix calls to rfkill on distros that put in in sbin
This makes the network applet work on Debian, for instance. It may be better to directly use `/dev/rfkill`, but this improves things for now.
This commit is contained in:
parent
19e750c65e
commit
d3ef5b181b
2 changed files with 20 additions and 0 deletions
|
|
@ -72,6 +72,14 @@ fn device_type_to_icon(device_type: &str) -> &'static str {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In some distros, rfkill is only in sbin, which isn't normally in PATH
|
||||||
|
// TODO: Directly access `/dev/rfkill`
|
||||||
|
fn rfkill_path_var() -> std::ffi::OsString {
|
||||||
|
let mut path = std::env::var_os("PATH").unwrap_or_default();
|
||||||
|
path.push(":/usr/sbin");
|
||||||
|
path
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn bluetooth_subscription<I: 'static + Hash + Copy + Send + Sync + Debug>(
|
pub fn bluetooth_subscription<I: 'static + Hash + Copy + Send + Sync + Debug>(
|
||||||
id: I,
|
id: I,
|
||||||
|
|
@ -682,6 +690,7 @@ impl BluerSessionState {
|
||||||
// rfkill will be persisted after reboot
|
// rfkill will be persisted after reboot
|
||||||
let name = adapter_clone.name();
|
let name = adapter_clone.name();
|
||||||
if let Some(id) = tokio::process::Command::new("rfkill")
|
if let Some(id) = tokio::process::Command::new("rfkill")
|
||||||
|
.env("PATH", rfkill_path_var())
|
||||||
.arg("list")
|
.arg("list")
|
||||||
.arg("-n")
|
.arg("-n")
|
||||||
.arg("--output")
|
.arg("--output")
|
||||||
|
|
@ -698,6 +707,7 @@ impl BluerSessionState {
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
if let Err(err) = tokio::process::Command::new("rfkill")
|
if let Err(err) = tokio::process::Command::new("rfkill")
|
||||||
|
.env("PATH", rfkill_path_var())
|
||||||
.arg(if *enabled { "unblock" } else { "block" })
|
.arg(if *enabled { "unblock" } else { "block" })
|
||||||
.arg(id)
|
.arg(id)
|
||||||
.output()
|
.output()
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,14 @@ use self::{
|
||||||
current_networks::{active_connections, ActiveConnectionInfo},
|
current_networks::{active_connections, ActiveConnectionInfo},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// In some distros, rfkill is only in sbin, which isn't normally in PATH
|
||||||
|
// TODO: Directly access `/dev/rfkill`
|
||||||
|
fn rfkill_path_var() -> std::ffi::OsString {
|
||||||
|
let mut path = std::env::var_os("PATH").unwrap_or_default();
|
||||||
|
path.push(":/usr/sbin");
|
||||||
|
path
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum State {
|
pub enum State {
|
||||||
Ready,
|
Ready,
|
||||||
|
|
@ -154,6 +162,7 @@ async fn start_listening(
|
||||||
// bluetooth
|
// bluetooth
|
||||||
success = success
|
success = success
|
||||||
&& Command::new("rfkill")
|
&& Command::new("rfkill")
|
||||||
|
.env("PATH", rfkill_path_var())
|
||||||
.arg(if airplane_mode { "block" } else { "unblock" })
|
.arg(if airplane_mode { "block" } else { "unblock" })
|
||||||
.arg("bluetooth")
|
.arg("bluetooth")
|
||||||
.output()
|
.output()
|
||||||
|
|
@ -402,6 +411,7 @@ impl NetworkManagerState {
|
||||||
let mut self_ = Self::default();
|
let mut self_ = Self::default();
|
||||||
// airplane mode
|
// airplane mode
|
||||||
let airplaine_mode = Command::new("rfkill")
|
let airplaine_mode = Command::new("rfkill")
|
||||||
|
.env("PATH", rfkill_path_var())
|
||||||
.arg("list")
|
.arg("list")
|
||||||
.arg("bluetooth")
|
.arg("bluetooth")
|
||||||
.output()
|
.output()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue