Track caller of screensaver "Inhibit"
This commit is contained in:
parent
a0ddfa80b7
commit
bd5487331d
1 changed files with 17 additions and 8 deletions
|
|
@ -6,6 +6,7 @@ use std::collections::HashMap;
|
||||||
struct Inhibitor {
|
struct Inhibitor {
|
||||||
application_name: String,
|
application_name: String,
|
||||||
reason_for_inhibit: String,
|
reason_for_inhibit: String,
|
||||||
|
client: zbus::names::UniqueName<'static>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
@ -16,15 +17,23 @@ pub struct Screensaver {
|
||||||
|
|
||||||
#[zbus::interface(name = "org.freedesktop.ScreenSaver")]
|
#[zbus::interface(name = "org.freedesktop.ScreenSaver")]
|
||||||
impl Screensaver {
|
impl Screensaver {
|
||||||
fn inhibit(&mut self, application_name: String, reason_for_inhibit: String) -> u32 {
|
fn inhibit(
|
||||||
|
&mut self,
|
||||||
|
application_name: String,
|
||||||
|
reason_for_inhibit: String,
|
||||||
|
#[zbus(header)] header: zbus::message::Header<'_>,
|
||||||
|
) -> u32 {
|
||||||
self.last_cookie += 1;
|
self.last_cookie += 1;
|
||||||
|
if let Some(sender) = header.sender() {
|
||||||
self.inhibitors.insert(
|
self.inhibitors.insert(
|
||||||
self.last_cookie,
|
self.last_cookie,
|
||||||
Inhibitor {
|
Inhibitor {
|
||||||
application_name,
|
application_name,
|
||||||
reason_for_inhibit,
|
reason_for_inhibit,
|
||||||
|
client: sender.to_owned(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
}
|
||||||
self.last_cookie
|
self.last_cookie
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue