🚧 fix user services

This commit is contained in:
Vladislav Nepogodin 2023-04-02 21:09:11 +04:00
parent 61357e7261
commit a75b1a0280
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9
1 changed files with 12 additions and 16 deletions

View File

@ -511,20 +511,19 @@ fn on_servbtn_clicked(button: &gtk::CheckButton) {
signal_handler = *button.data("signalHandle").unwrap().as_ptr(); signal_handler = *button.data("signalHandle").unwrap().as_ptr();
} }
let (user_only, pkexec_only) =
if action_type == "user_service" { ("--user", "--user $(logname)") } else { ("", "") };
let local_units = &G_LOCAL_UNITS.lock().unwrap().enabled_units; let local_units = &G_LOCAL_UNITS.lock().unwrap().enabled_units;
let cmd = if !local_units.contains(&String::from(action_data)) { let cmd = if !local_units.contains(&String::from(action_data)) {
format!( if action_type == "user_service" {
"/sbin/pkexec {pkexec_only} bash -c \"systemctl {user_only} enable --now --force \ format!("systemctl --user enable --now --force {action_data}")
{action_data}\""
)
} else { } else {
format!( format!("/sbin/pkexec bash -c \"systemctl enable --now --force {action_data}\"")
"/sbin/pkexec {pkexec_only} bash -c \"systemctl {user_only} disable --now \ }
{action_data}\"" } else {
) if action_type == "user_service" {
format!("systemctl --user disable --now {action_data}")
} else {
format!("/sbin/pkexec bash -c \"systemctl disable --now {action_data}\"")
}
}; };
// Create context channel. // Create context channel.
@ -543,11 +542,8 @@ fn on_servbtn_clicked(button: &gtk::CheckButton) {
} }
Exec::shell(cmd).join().unwrap(); Exec::shell(cmd).join().unwrap();
if action_type == "user_service" {
load_global_enabled_units(); load_global_enabled_units();
} else {
load_enabled_units(); load_enabled_units();
}
}); });
let button_sh = button.clone(); let button_sh = button.clone();