1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-25 14:02:53 -05:00
Files
DankMaterialShell/core/internal/utils/exec.go
2025-12-28 04:50:39 -03:00

25 lines
470 B
Go

package utils
import (
"os/exec"
"strings"
)
func CommandExists(cmd string) bool {
_, err := exec.LookPath(cmd)
return err == nil
}
func IsServiceActive(name string, userService bool) bool {
if !CommandExists("systemctl") {
return false
}
args := []string{"is-active", name}
if userService {
args = []string{"--user", "is-active", name}
}
output, _ := exec.Command("systemctl", args...).Output()
return strings.TrimSpace(string(output)) == "active"
}