From a75b1a0280e42cc91baee5ca9fe666afb620c47d Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Sun, 2 Apr 2023 21:09:11 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20fix=20user=20services?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages.rs | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/pages.rs b/src/pages.rs index 940e5a1..0c83cea 100644 --- a/src/pages.rs +++ b/src/pages.rs @@ -511,20 +511,19 @@ fn on_servbtn_clicked(button: >k::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: >k::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();