Files
uu-remote-linux/src/power.rs
T
VallierDevandClaude Opus 5.5 502635b156 Initial import of uu-remote-linux
Unofficial Linux host for NetEase UU Remote: X11 (production-tested on
GNOME/Ubuntu 24.04), experimental Wayland (Hyprland) and portal
(GNOME/KDE) backends; video, input, clipboard, file transfer, terminal,
sound, quality/fps/resolution settings, lock/unlock and system actions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-14 23:53:16 +08:00

36 lines
1015 B
Rust

//! Native System Power Management (Reboot & Shutdown)
use std::process::Command;
pub struct PowerManager;
impl PowerManager {
pub fn reboot() -> Result<(), String> {
log::info!("Executing system reboot command...");
let status = Command::new("systemctl")
.arg("reboot")
.status()
.map_err(|e| format!("Failed to invoke systemctl reboot: {}", e))?;
if status.success() {
Ok(())
} else {
Err(format!("systemctl reboot exited with status {}", status))
}
}
pub fn shutdown() -> Result<(), String> {
log::info!("Executing system poweroff command...");
let status = Command::new("systemctl")
.arg("poweroff")
.status()
.map_err(|e| format!("Failed to invoke systemctl poweroff: {}", e))?;
if status.success() {
Ok(())
} else {
Err(format!("systemctl poweroff exited with status {}", status))
}
}
}