This commit is contained in:
jahruz67
2026-05-09 10:59:26 -07:00
parent 4ea6675450
commit 52cf789eab
8 changed files with 98 additions and 33 deletions
+10 -22
View File
@@ -10,7 +10,6 @@ import (
"os"
"runtime"
"strings"
"sync"
"wis-free-v3/internal/config"
"wis-free-v3/internal/logger"
@@ -22,6 +21,9 @@ import (
//go:embed icon.ico
var iconData []byte
//go:embed icon.png
var iconPNGData []byte
//go:embed icon_recording.png
var iconRecordingData []byte
@@ -152,30 +154,16 @@ func buildTooltip(app App) string {
return trayLabel + " - " + shortcut + " to record"
}
var (
defaultIconOnce sync.Once
defaultIconBytes []byte
)
func getDefaultIcon() []byte {
if runtime.GOOS != "linux" {
return iconData
if runtime.GOOS == "linux" {
return iconPNGData
}
return iconData
}
defaultIconOnce.Do(func() {
pngData, err := icoToPNG(iconData)
if err != nil {
logger.Error("Failed to convert tray icon to PNG for Linux: %v", err)
defaultIconBytes = iconData
return
}
defaultIconBytes = pngData
})
if len(defaultIconBytes) == 0 {
return iconData
}
return defaultIconBytes
// DefaultIconBytes returns the raw default icon bytes for the current platform.
func DefaultIconBytes() []byte {
return getDefaultIcon()
}
func icoToPNG(data []byte) ([]byte, error) {