Invoke loginctl, systemctl and moonlock via PATH
The absolute /usr/bin paths assume an FHS layout, so every power action failed on NixOS with os error 2.
This commit is contained in:
Generated
+1
-1
@@ -616,7 +616,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "moonset"
|
||||
version = "0.9.1"
|
||||
version = "0.9.2"
|
||||
dependencies = [
|
||||
"dirs",
|
||||
"gdk-pixbuf",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "moonset"
|
||||
version = "0.9.1"
|
||||
version = "0.9.2"
|
||||
edition = "2024"
|
||||
description = "Wayland session power menu with GTK4 and Layer Shell"
|
||||
license = "MIT"
|
||||
|
||||
+6
-6
@@ -112,7 +112,7 @@ fn run_command(action: &'static str, program: &str, args: &[&str]) -> Result<(),
|
||||
/// moonlock runs independently until the user unlocks.
|
||||
pub fn lock() -> Result<(), PowerError> {
|
||||
log::debug!("Power action: lock (spawning moonlock)");
|
||||
Command::new("/usr/bin/moonlock")
|
||||
Command::new("moonlock")
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::inherit())
|
||||
@@ -148,7 +148,7 @@ fn resolve_logout_command(
|
||||
|
||||
match session_id {
|
||||
Some(id) if !id.is_empty() => Ok(vec![
|
||||
"/usr/bin/loginctl".to_string(),
|
||||
"loginctl".to_string(),
|
||||
"terminate-session".to_string(),
|
||||
id.to_string(),
|
||||
]),
|
||||
@@ -173,17 +173,17 @@ pub fn logout() -> Result<(), PowerError> {
|
||||
|
||||
/// Hibernate the system via systemctl.
|
||||
pub fn hibernate() -> Result<(), PowerError> {
|
||||
run_command("hibernate", "/usr/bin/systemctl", &["hibernate"])
|
||||
run_command("hibernate", "systemctl", &["hibernate"])
|
||||
}
|
||||
|
||||
/// Reboot the system via systemctl.
|
||||
pub fn reboot() -> Result<(), PowerError> {
|
||||
run_command("reboot", "/usr/bin/systemctl", &["reboot"])
|
||||
run_command("reboot", "systemctl", &["reboot"])
|
||||
}
|
||||
|
||||
/// Shut down the system via systemctl.
|
||||
pub fn shutdown() -> Result<(), PowerError> {
|
||||
run_command("shutdown", "/usr/bin/systemctl", &["poweroff"])
|
||||
run_command("shutdown", "systemctl", &["poweroff"])
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -237,7 +237,7 @@ mod tests {
|
||||
#[test]
|
||||
fn logout_default_uses_loginctl_with_session_id() {
|
||||
let parts = resolve_logout_command(None, Some("3")).unwrap();
|
||||
assert_eq!(parts, vec!["/usr/bin/loginctl", "terminate-session", "3"]);
|
||||
assert_eq!(parts, vec!["loginctl", "terminate-session", "3"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user