get_password/
get_password.rs1use nm_rs::Client;
2use nm_rs::prelude::ConnectionExt;
3
4fn get_password(client: &Client) {
5 let connections = client.connections();
6 let Some(remote_connection) = connections.first() else {
7 return;
8 };
9 println!(
10 "Password for connection {} is {}",
11 remote_connection.id(),
12 remote_connection.setting_wireless_security().psk()
13 )
14}
15
16fn main() {
17 let mainloop = glib::MainLoop::new(None, false);
18 mainloop.context().spawn_local(glib::clone!(
19 #[strong]
20 mainloop,
21 async move {
22 let client = match Client::new_future().await {
23 Ok(client) => client,
24 Err(e) => {
25 glib::g_error!("app", "Failed to create new client: {e}");
26 return;
27 }
28 };
29 get_password(&client);
30 mainloop.quit();
31 }
32 ));
33 mainloop.run();
34}