fix: use systemctl instead of loginctl for reboot/poweroff

loginctl has no reboot/poweroff subcommands — these are systemctl
commands. The error was silently swallowed because stderr wasn't
captured and logs went to a non-existent directory.
This commit is contained in:
nevaforget 2026-03-28 00:53:14 +01:00
parent 17f8930ff7
commit 78bcf90492
2 changed files with 3 additions and 3 deletions

2
Cargo.lock generated
View File

@ -693,7 +693,7 @@ dependencies = [
[[package]]
name = "moonlock"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"env_logger",
"gdk-pixbuf",

View File

@ -37,8 +37,8 @@ fn run_command(action: &'static str, program: &str, args: &[&str]) -> Result<(),
Ok(())
}
pub fn reboot() -> Result<(), PowerError> { run_command("reboot", "/usr/bin/loginctl", &["reboot"]) }
pub fn shutdown() -> Result<(), PowerError> { run_command("shutdown", "/usr/bin/loginctl", &["poweroff"]) }
pub fn reboot() -> Result<(), PowerError> { run_command("reboot", "/usr/bin/systemctl", &["reboot"]) }
pub fn shutdown() -> Result<(), PowerError> { run_command("shutdown", "/usr/bin/systemctl", &["poweroff"]) }
#[cfg(test)]
mod tests {