keep server device awake if have connection

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2023-06-05 20:24:16 +08:00
parent f1cc42769c
commit 98740dbfd7
6 changed files with 344 additions and 11 deletions

View File

@@ -701,3 +701,18 @@ pub fn elevate(args: Vec<&str>, prompt: &str) -> ResultType<bool> {
}
}
}
pub struct WakeLock(Option<keepawake::AwakeHandle>);
impl WakeLock {
pub fn new(display: bool, idle: bool, sleep: bool) -> Self {
WakeLock(
keepawake::Builder::new()
.display(display)
.idle(idle)
.sleep(sleep)
.create()
.ok(),
)
}
}