mirror of
https://github.com/GiriNeko/hbb_common.git
synced 2025-12-17 05:47:28 +00:00
Merge pull request #136 from fufesou/feat/linux_is_locked
feat: linux, is locked
This commit is contained in:
commit
ebb4d4a48c
1 changed files with 9 additions and 0 deletions
|
|
@ -204,6 +204,15 @@ pub fn is_active_and_seat0(sid: &str) -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check both "Lock" and "Switch user"
|
||||||
|
pub fn is_session_locked(sid: &str) -> bool {
|
||||||
|
if let Ok(output) = run_loginctl(Some(vec!["show-session", sid, "--property=LockedHint"])) {
|
||||||
|
String::from_utf8_lossy(&output.stdout).contains("LockedHint=yes")
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// **Note** that the return value here, the last character is '\n'.
|
// **Note** that the return value here, the last character is '\n'.
|
||||||
// Use `run_cmds_trim_newline()` if you want to remove '\n' at the end.
|
// Use `run_cmds_trim_newline()` if you want to remove '\n' at the end.
|
||||||
pub fn run_cmds(cmds: &str) -> ResultType<String> {
|
pub fn run_cmds(cmds: &str) -> ResultType<String> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue