mirror of
https://github.com/jahruz67/wisp-open.git
synced 2026-08-08 18:14:08 +00:00
- Add platform notes for tray startup, shortcut saving, and Linux-only settings - Handle stat error in processRecording (missing file) - Select correct binary name based on OS in updater - Increase tray icon canvas size from 64 to 128 pixels - Update frontend dist asset hash
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
//go:build linux
|
|
|
|
// ============================================================
|
|
// LINUX-ONLY FILE — Linux media playback management.
|
|
// Uses playerctl to pause/resume media during recording.
|
|
// The Windows equivalent is in internal/windows/
|
|
// ============================================================
|
|
|
|
package linux
|
|
|
|
import (
|
|
"os/exec"
|
|
"strings"
|
|
|
|
"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 strings.EqualFold(strings.TrimSpace(string(out)), "playing")
|
|
}
|
|
|
|
// 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()
|
|
}
|
|
}
|