Embed app icon and polish Windows build

This commit is contained in:
mixeme
2026-06-14 23:53:08 +03:00
parent a9d1d9529e
commit 59718e21b4
9 changed files with 24 additions and 28 deletions
+3 -1
View File
@@ -43,6 +43,8 @@ Windows:
.\scripts\build-windows.bat .\scripts\build-windows.bat
``` ```
The Windows build is created as a GUI application, so it does not open a terminal window.
The binary is written to: The binary is written to:
```text ```text
@@ -160,7 +162,7 @@ Changing `jobs_dir` saves the current job list to the new directory.
- `cmd/pysentry` starts the desktop app. - `cmd/pysentry` starts the desktop app.
- `src/gui` contains the GUI. - `src/gui` contains the GUI.
- `src/core` contains YAML storage, command execution, scheduling, and log cleanup. - `src/core` contains YAML storage, command execution, scheduling, and log cleanup.
- `assets` contains app icons. - `assets` contains app icons that are embedded into the application binary.
- `scripts` contains build helpers. - `scripts` contains build helpers.
Build outputs are written to `dist/`. The old local `bin/` directory is not used. Build outputs are written to `dist/`. The old local `bin/` directory is not used.
+14
View File
@@ -0,0 +1,14 @@
package assets
import (
_ "embed"
"fyne.io/fyne/v2"
)
//go:embed pysentry-icon.png
var iconBytes []byte
func Icon() fyne.Resource {
return fyne.NewStaticResource("pysentry-icon.png", iconBytes)
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 13 KiB

+3 -2
View File
@@ -3,6 +3,7 @@
<path d="M128 32 204 64v58c0 50-29 82-76 104-47-22-76-54-76-104V64z" fill="none" stroke="#ffffff" stroke-width="20" stroke-linejoin="round"/> <path d="M128 32 204 64v58c0 50-29 82-76 104-47-22-76-54-76-104V64z" fill="none" stroke="#ffffff" stroke-width="20" stroke-linejoin="round"/>
<path d="M128 76v55l42-32" fill="none" stroke="#ffffff" stroke-width="20" stroke-linecap="round" stroke-linejoin="round"/> <path d="M128 76v55l42-32" fill="none" stroke="#ffffff" stroke-width="20" stroke-linecap="round" stroke-linejoin="round"/>
<circle cx="128" cy="132" r="14" fill="#ffffff"/> <circle cx="128" cy="132" r="14" fill="#ffffff"/>
<path d="M77 154l26 22-26 22" fill="none" stroke="#ffb31a" stroke-width="18" stroke-linecap="round" stroke-linejoin="round"/> <rect x="48" y="142" width="160" height="70" rx="16" fill="#00343c"/>
<path d="M125 198h36" fill="none" stroke="#ffb31a" stroke-width="18" stroke-linecap="round"/> <path d="M74 160l38 17-38 17" fill="none" stroke="#ffb31a" stroke-width="18" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M132 195h48" fill="none" stroke="#ffb31a" stroke-width="18" stroke-linecap="round"/>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 673 B

After

Width:  |  Height:  |  Size: 745 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 32 KiB

-2
View File
@@ -8,7 +8,5 @@ container_id="$(docker create pysentry-linux-builder)"
mkdir -p "$(dirname "$output")" mkdir -p "$(dirname "$output")"
docker cp "${container_id}:/out/pysentry" "$output" docker cp "${container_id}:/out/pysentry" "$output"
docker rm "$container_id" >/dev/null docker rm "$container_id" >/dev/null
rm -rf "$(dirname "$output")/assets"
cp -R assets "$(dirname "$output")/assets"
echo "Built $output" echo "Built $output"
-2
View File
@@ -9,7 +9,5 @@ export GOOS=linux
export GOARCH=amd64 export GOARCH=amd64
go build -trimpath -ldflags "-s -w" -o "$output" ./cmd/pysentry go build -trimpath -ldflags "-s -w" -o "$output" ./cmd/pysentry
rm -rf "$(dirname "$output")/assets"
cp -R assets "$(dirname "$output")/assets"
echo "Built $output" echo "Built $output"
+1 -3
View File
@@ -21,9 +21,7 @@ if %ERRORLEVEL%==0 (
windres.exe -O coff -o cmd\pysentry\rsrc_windows_amd64.syso packaging\windows\pysentry.rc windres.exe -O coff -o cmd\pysentry\rsrc_windows_amd64.syso packaging\windows\pysentry.rc
) )
"%GOEXE%" build -trimpath -ldflags "-s -w" -o "%OUTPUT%" .\cmd\pysentry "%GOEXE%" build -trimpath -ldflags "-s -w -H=windowsgui" -o "%OUTPUT%" .\cmd\pysentry
if errorlevel 1 exit /b 1 if errorlevel 1 exit /b 1
xcopy /E /I /Y assets "%OUTDIR%assets" >nul
echo Built %OUTPUT% echo Built %OUTPUT%
+3 -18
View File
@@ -2,12 +2,11 @@ package gui
import ( import (
"fmt" "fmt"
"os"
"path/filepath"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"github.com/pysentry/pysentry/assets"
"github.com/pysentry/pysentry/src/core" "github.com/pysentry/pysentry/src/core"
"fyne.io/fyne/v2" "fyne.io/fyne/v2"
@@ -39,19 +38,7 @@ func Run() {
} }
func loadAppIcon() fyne.Resource { func loadAppIcon() fyne.Resource {
candidates := []string{} return assets.Icon()
if executable, err := os.Executable(); err == nil {
candidates = append(candidates, filepath.Join(filepath.Dir(executable), "assets", "pysentry-icon.png"))
}
if workingDir, err := os.Getwd(); err == nil {
candidates = append(candidates, filepath.Join(workingDir, "assets", "pysentry-icon.png"))
}
for _, path := range candidates {
if resource, err := fyne.LoadResourceFromPath(path); err == nil {
return resource
}
}
return theme.ComputerIcon()
} }
func configureSystemTray(a fyne.App, w fyne.Window) { func configureSystemTray(a fyne.App, w fyne.Window) {
@@ -558,7 +545,6 @@ func newHistoryView(events *[]event) *fyne.Container {
} }
func settingsView(w fyne.Window, store *core.Store, jobs *[]job) fyne.CanvasObject { func settingsView(w fyne.Window, store *core.Store, jobs *[]job) fyne.CanvasObject {
runOnStartup := widget.NewCheck("Start PySentry when I sign in", nil)
minimizeToTray := widget.NewCheck("Keep running in the system tray", nil) minimizeToTray := widget.NewCheck("Keep running in the system tray", nil)
minimizeToTray.SetChecked(store.Config.KeepRunningInTray) minimizeToTray.SetChecked(store.Config.KeepRunningInTray)
notifications := widget.NewCheck("Show desktop notifications for failed jobs", nil) notifications := widget.NewCheck("Show desktop notifications for failed jobs", nil)
@@ -621,7 +607,6 @@ func settingsView(w fyne.Window, store *core.Store, jobs *[]job) fyne.CanvasObje
return container.NewPadded(container.NewVBox( return container.NewPadded(container.NewVBox(
widget.NewLabelWithStyle("Application", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}), widget.NewLabelWithStyle("Application", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}),
runOnStartup,
minimizeToTray, minimizeToTray,
notifications, notifications,
widget.NewSeparator(), widget.NewSeparator(),
@@ -635,7 +620,7 @@ func settingsView(w fyne.Window, store *core.Store, jobs *[]job) fyne.CanvasObje
settingsStatus, settingsStatus,
widget.NewSeparator(), widget.NewSeparator(),
widget.NewLabelWithStyle("Scheduler", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}), widget.NewLabelWithStyle("Scheduler", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}),
widget.NewLabel("Current core supports @every schedules. Cron expressions come next."), widget.NewLabel("Current core supports @every schedules and standard 5-field cron expressions."),
)) ))
} }