Compare commits
No commits in common. "0e076a29ef8cb9cd7d93d411178d7a276df3a2d5" and "4a2f7e5e90cdd27c4ccd956b16e27ff9ef25e089" have entirely different histories.
0e076a29ef
...
4a2f7e5e90
@ -22,7 +22,7 @@ impl BluetoothInfo {
|
|||||||
alias: device.get("Alias")?.0.as_str()?.to_owned(),
|
alias: device.get("Alias")?.0.as_str()?.to_owned(),
|
||||||
connected: matches!(&device.get("Connected")?.0.as_u64(), Some(1)),
|
connected: matches!(&device.get("Connected")?.0.as_u64(), Some(1)),
|
||||||
icon: device.get("Icon")?.0.as_str()?.to_owned(),
|
icon: device.get("Icon")?.0.as_str()?.to_owned(),
|
||||||
battery: None,
|
battery: None
|
||||||
};
|
};
|
||||||
if let Some(battery) = from.get("org.bluez.Battery1") {
|
if let Some(battery) = from.get("org.bluez.Battery1") {
|
||||||
result.battery = Some(battery.get("Percentage")?.0.as_u64()?);
|
result.battery = Some(battery.get("Percentage")?.0.as_u64()?);
|
||||||
@ -31,17 +31,14 @@ impl BluetoothInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_all_bluetooth_devices(
|
pub fn get_all_bluetooth_devices(connection: &dbus::blocking::Connection) -> Result<Vec<BluetoothInfo>> {
|
||||||
&connection: dbus::blocking::Connection,
|
|
||||||
) -> Result<Vec<BluetoothInfo>> {
|
|
||||||
let proxy = connection.with_proxy("org.bluez", "/", Duration::from_millis(5000));
|
let proxy = connection.with_proxy("org.bluez", "/", Duration::from_millis(5000));
|
||||||
let (result,): (HashMap<dbus::Path<'static>, HashMap<String, arg::PropMap>>,) = proxy
|
let (result,): (HashMap<dbus::Path<'static>, HashMap<String, arg::PropMap>>,) = proxy
|
||||||
.method_call(
|
.method_call(
|
||||||
"org.freedesktop.DBus.ObjectManager",
|
"org.freedesktop.DBus.ObjectManager",
|
||||||
"GetManagedObjects",
|
"GetManagedObjects",
|
||||||
(),
|
(),
|
||||||
)
|
)?;
|
||||||
.unwrap_or_default();
|
|
||||||
let result: Vec<BluetoothInfo> = result
|
let result: Vec<BluetoothInfo> = result
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|(_, value)| value.contains_key("org.bluez.Device1"))
|
.filter(|(_, value)| value.contains_key("org.bluez.Device1"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user