Keep Muninn Bluetooth hosts connectable for Move swaps
This commit is contained in:
parent
c8fda33701
commit
a0c62e8d07
1 changed files with 25 additions and 0 deletions
|
|
@ -313,6 +313,10 @@ fn claim_move_host_if_due(options: &Options, last_attempt_at: &mut Option<Instan
|
|||
}
|
||||
*last_attempt_at = Some(Instant::now());
|
||||
|
||||
if let Err(error) = prepare_move_bluetooth_host_for_claim() {
|
||||
eprintln!("Muninn could not prepare Bluetooth host for USB PS Move claim: {error:#}");
|
||||
}
|
||||
|
||||
let Some(host) = move_host_address_for_claim(options) else {
|
||||
return;
|
||||
};
|
||||
|
|
@ -321,6 +325,27 @@ fn claim_move_host_if_due(options: &Options, last_attempt_at: &mut Option<Instan
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn prepare_move_bluetooth_host_for_claim() -> Result<()> {
|
||||
let output = Command::new("bluetoothctl")
|
||||
.args(["pairable", "on"])
|
||||
.output()
|
||||
.context("bluetoothctl pairable on could not run")?;
|
||||
if output.status.success() {
|
||||
return Ok(());
|
||||
}
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
Err(anyhow!(
|
||||
"bluetoothctl pairable on failed: {}",
|
||||
stderr.trim()
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(not(unix))]
|
||||
fn prepare_move_bluetooth_host_for_claim() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn move_host_address_for_claim(options: &Options) -> Option<String> {
|
||||
if let Some(host) = options.move_host_address.as_deref() {
|
||||
if !host.trim().is_empty() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue