Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cmd/restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ func SpotifyKill() {
isRunning := exec.Command("pgrep", "spotify")
_, err := isRunning.Output()
if err == nil {
exec.Command("pkill", "spotify").Run()
exec.Command("pkill", "-x", "spotify").Run()
}
case "darwin":
isRunning := exec.Command("sh", "-c", "ps aux | grep 'Spotify' | grep -v grep")
_, err := isRunning.CombinedOutput()
if err == nil {
exec.Command("pkill", "Spotify").Run()
exec.Command("pkill", "-x", "Spotify").Run()
}
Comment on lines 26 to 31
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Use pgrep with exact match for consistency.

Line 27 uses ps aux | grep 'Spotify' which will match any process containing "Spotify" in its command line, creating an inconsistency with the exact-match termination on line 30. For consistency with the Linux implementation and to avoid false positives, replace the grep-based detection with pgrep -x Spotify.

Apply this diff:

-		isRunning := exec.Command("sh", "-c", "ps aux | grep 'Spotify' | grep -v grep")
-		_, err := isRunning.CombinedOutput()
+		isRunning := exec.Command("pgrep", "-x", "Spotify")
+		_, err := isRunning.Output()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
case "darwin":
isRunning := exec.Command("sh", "-c", "ps aux | grep 'Spotify' | grep -v grep")
_, err := isRunning.CombinedOutput()
if err == nil {
exec.Command("pkill", "Spotify").Run()
exec.Command("pkill", "-x", "Spotify").Run()
}
case "darwin":
- isRunning := exec.Command("sh", "-c", "ps aux | grep 'Spotify' | grep -v grep")
isRunning := exec.Command("pgrep", "-x", "Spotify")
_, err := isRunning.Output()
if err == nil {
exec.Command("pkill", "-x", "Spotify").Run()
}
🤖 Prompt for AI Agents
In src/cmd/restart.go around lines 26 to 31, replace the ps+grep detection with
an exact-match pgrep call: run exec.Command("pgrep", "-x",
"Spotify").CombinedOutput() and use its error/result to decide whether to call
exec.Command("pkill", "-x", "Spotify").Run(); this ensures exact-process
matching consistent with the pkill usage and avoids false positives from
substring matches.

}
}
Expand Down