refactor: implement cross-platform abstraction for process management, media control, and startup configuration (TESTING)

This commit is contained in:
jahruz67
2026-04-09 21:31:02 -07:00
parent cc644e3059
commit ba0e75c503
25 changed files with 458 additions and 48 deletions
+42
View File
@@ -0,0 +1,42 @@
//go:build linux
package linux
import (
"os/exec"
"wis-free-v3/internal/logger"
)
// IsPlaying checks if media is currently playing using playerctl
func IsPlaying() bool {
cmd := exec.Command("playerctl", "status")
out, err := cmd.Output()
if err != nil {
return false
}
return string(out) == "Playing\n"
}
// TogglePlayPause sends the play-pause command via playerctl
func TogglePlayPause() {
cmd := exec.Command("playerctl", "play-pause")
err := cmd.Run()
if err != nil {
logger.Error("Failed to toggle media on Linux: %v", err)
}
}
// PauseMedia checks if playing, pauses if so, returns whether we paused
func PauseMedia() bool {
wasPlaying := IsPlaying()
if wasPlaying {
TogglePlayPause()
}
return wasPlaying
}
// ResumeMedia resumes only if we paused it
func ResumeMedia(wasPaused bool) {
if wasPaused {
TogglePlayPause()
}
}