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