Skip to content

Commit

Permalink
Add an example for the Background portal
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuamegnauth54 committed Aug 3, 2024
1 parent 71e2990 commit 373abfd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions examples/background.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,26 @@ use ashpd::desktop::background::Background;

#[tokio::main(flavor = "current_thread")]
async fn main() -> ashpd::Result<()> {
let command = std::env::args()
.nth(1)
.unwrap_or_else(|| "FakeTestApp".into());

// Based off of the ashpd docs
// https://docs.rs/ashpd/latest/ashpd/desktop/background/index.html
let response = Background::request()
.reason("Testing the background portal")
.auto_start(false)
.dbus_activatable(false)
.command(&[command])
.send()
.await?
.response()?;

assert!(!response.auto_start(), "Auto start should be disabled");
assert!(
response.run_in_background(),
"App should have background permissions"
);

Ok(())
}

0 comments on commit 373abfd

Please sign in to comment.