diff --git a/main.go b/main.go index d068ba4..1b1e803 100644 --- a/main.go +++ b/main.go @@ -88,19 +88,8 @@ func main() { } handleRequest(conn) - // Restart xochitl if *restart { - services := []string{"xochitl", "remux", "tarnish", "draft"} - for _, service := range services { - _, exitcode := exec.Command("systemctl", "is-active", service).CombinedOutput() - if exitcode == nil { - debug("Restarting " + service) - stdout, err := exec.Command("systemctl", "restart", service).CombinedOutput() - if err != nil { - fmt.Println(service+" restart failed with message:", string(stdout)) - } - } - } + restartUISoftware() } if isSocketActivated { @@ -198,3 +187,18 @@ func handleRequest(conn net.Conn) { conn.Close() } + +// Restarts xochitl or other UI software +func restartUISoftware() { + services := []string{"xochitl", "remux", "tarnish", "draft"} + for _, service := range services { + _, exitcode := exec.Command("systemctl", "is-active", service).CombinedOutput() + if exitcode == nil { + debug("Restarting " + service) + stdout, err := exec.Command("systemctl", "restart", service).CombinedOutput() + if err != nil { + fmt.Println(service+" restart failed with message:", string(stdout)) + } + } + } +}