Module ashpd::desktop::location

source ·
Expand description

Query the user’s GPS location.

§Examples

use ashpd::{
    desktop::location::{Accuracy, LocationProxy},
    WindowIdentifier,
};
use futures_util::{FutureExt, StreamExt};

async fn run() -> ashpd::Result<()> {
    let proxy = LocationProxy::new().await?;
    let identifier = WindowIdentifier::default();
    let session = proxy
        .create_session(None, None, Some(Accuracy::Street))
        .await?;
    let mut stream = proxy.receive_location_updated().await?;
    let (_, location) = futures_util::join!(
        proxy
            .start(&session, &identifier)
            .map(|e| e.expect("Couldn't start session")),
        stream.next().map(|e| e.expect("Stream is exhausted"))
    );
    println!("{}", location.accuracy());
    println!("{}", location.longitude());
    println!("{}", location.latitude());
    session.close().await?;
    Ok(())
}

Structs§

  • The response received on a location_updated signal.
  • The interface lets sandboxed applications query basic information about the location.

Enums§