package commands import ( "os/exec" "strings" "github.com/rs/zerolog/log" "github.com/spf13/cobra" ) // NewStatusCmd creates a new status command to check if the daemon is running. func NewStatusCmd() *cobra.Command { return &cobra.Command{ Use: "status", Short: "Check if the clipboard watcher daemon is running", Run: func(cmd *cobra.Command, args []string) { // Check for the process by name (simple approach) out, err := exec.Command("ps", "-C", "kcm").Output() if err != nil { log.Fatal().Err(err).Msg("Failed to check kcm daemon status") } lines := strings.Split(string(out), "\n") if len(lines) > 1 { log.Info().Msg("kcm daemon is running.") } else { log.Warn().Msg("kcm daemon is not running, start a new one using `kcm watch`.") } }, } }