🚧 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();
}
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 cmd = if !local_units.contains(&String::from(action_data)) {
format!(
"/sbin/pkexec {pkexec_only} bash -c \"systemctl {user_only} enable --now --force \
{action_data}\""
)
if action_type == "user_service" {
format!("systemctl --user enable --now --force {action_data}")
} else {
format!("/sbin/pkexec bash -c \"systemctl enable --now --force {action_data}\"")
}
} else {
format!(
"/sbin/pkexec {pkexec_only} bash -c \"systemctl {user_only} disable --now \
{action_data}\""
)
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.
@ -543,11 +542,8 @@ fn on_servbtn_clicked(button: &gtk::CheckButton) {
}
Exec::shell(cmd).join().unwrap();
if action_type == "user_service" {
load_global_enabled_units();
} else {
load_enabled_units();
}
load_global_enabled_units();
load_enabled_units();
});
let button_sh = button.clone();