mirror of
https://github.com/VallierDev/uu-remote-linux.git
synced 2026-11-16 16:50:41 +01:00
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]>
36 lines
1015 B
Rust
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))
|
|
}
|
|
}
|
|
}
|