🆕 Add window size persistence, exit codes, and screen size detection

This commit is contained in:
2026-07-05 01:02:44 +08:00
parent d82a8df7e0
commit 9511143a72
4 changed files with 160 additions and 1 deletions
+32
View File
@@ -0,0 +1,32 @@
//go:build darwin
package main
import (
"os/exec"
"strconv"
"strings"
)
// desktopSize returns the visible desktop size in points (device-independent
// pixels), matching Fyne's coordinate system. It uses osascript instead of
// cgo so the binary stays a plain Go build. Returns (0, 0) if it can't be
// determined, in which case the caller skips clamping.
func desktopSize() (float32, float32) {
// "bounds of window of desktop" -> "0, 0, W, H" in points.
out, err := exec.Command("osascript", "-e",
`tell application "Finder" to get bounds of window of desktop`).Output()
if err != nil {
return 0, 0
}
parts := strings.Split(strings.TrimSpace(string(out)), ", ")
if len(parts) < 4 {
return 0, 0
}
w, errW := strconv.ParseFloat(strings.TrimSpace(parts[2]), 32)
h, errH := strconv.ParseFloat(strings.TrimSpace(parts[3]), 32)
if errW != nil || errH != nil {
return 0, 0
}
return float32(w), float32(h)
}