diff --git a/README.md b/README.md index 366ccf0..f2317cb 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,8 @@ Windows: .\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: ```text @@ -160,7 +162,7 @@ Changing `jobs_dir` saves the current job list to the new directory. - `cmd/pysentry` starts the desktop app. - `src/gui` contains the GUI. - `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. Build outputs are written to `dist/`. The old local `bin/` directory is not used. diff --git a/assets/assets.go b/assets/assets.go new file mode 100644 index 0000000..bb5d135 --- /dev/null +++ b/assets/assets.go @@ -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) +} diff --git a/assets/pysentry-icon.png b/assets/pysentry-icon.png index d636b4e..13e3152 100644 Binary files a/assets/pysentry-icon.png and b/assets/pysentry-icon.png differ diff --git a/assets/pysentry-icon.svg b/assets/pysentry-icon.svg index 7f675d8..eee5293 100644 --- a/assets/pysentry-icon.svg +++ b/assets/pysentry-icon.svg @@ -3,6 +3,7 @@ - - + + + diff --git a/assets/pysentry.ico b/assets/pysentry.ico index 1c5f342..8b47f4f 100644 Binary files a/assets/pysentry.ico and b/assets/pysentry.ico differ diff --git a/scripts/build-linux-docker.sh b/scripts/build-linux-docker.sh index 691e5c8..3f5223e 100644 --- a/scripts/build-linux-docker.sh +++ b/scripts/build-linux-docker.sh @@ -8,7 +8,5 @@ container_id="$(docker create pysentry-linux-builder)" mkdir -p "$(dirname "$output")" docker cp "${container_id}:/out/pysentry" "$output" docker rm "$container_id" >/dev/null -rm -rf "$(dirname "$output")/assets" -cp -R assets "$(dirname "$output")/assets" echo "Built $output" diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh index b3d11a8..b71a8df 100644 --- a/scripts/build-linux.sh +++ b/scripts/build-linux.sh @@ -9,7 +9,5 @@ export GOOS=linux export GOARCH=amd64 go build -trimpath -ldflags "-s -w" -o "$output" ./cmd/pysentry -rm -rf "$(dirname "$output")/assets" -cp -R assets "$(dirname "$output")/assets" echo "Built $output" diff --git a/scripts/build-windows.bat b/scripts/build-windows.bat index 97f4bf5..0e31340 100644 --- a/scripts/build-windows.bat +++ b/scripts/build-windows.bat @@ -21,9 +21,7 @@ if %ERRORLEVEL%==0 ( 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 -xcopy /E /I /Y assets "%OUTDIR%assets" >nul - echo Built %OUTPUT% diff --git a/src/gui/app.go b/src/gui/app.go index 9cd88f4..b4f472f 100644 --- a/src/gui/app.go +++ b/src/gui/app.go @@ -2,12 +2,11 @@ package gui import ( "fmt" - "os" - "path/filepath" "strconv" "strings" "time" + "github.com/pysentry/pysentry/assets" "github.com/pysentry/pysentry/src/core" "fyne.io/fyne/v2" @@ -39,19 +38,7 @@ func Run() { } func loadAppIcon() fyne.Resource { - candidates := []string{} - 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() + return assets.Icon() } 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 { - runOnStartup := widget.NewCheck("Start PySentry when I sign in", nil) minimizeToTray := widget.NewCheck("Keep running in the system tray", nil) minimizeToTray.SetChecked(store.Config.KeepRunningInTray) 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( widget.NewLabelWithStyle("Application", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}), - runOnStartup, minimizeToTray, notifications, widget.NewSeparator(), @@ -635,7 +620,7 @@ func settingsView(w fyne.Window, store *core.Store, jobs *[]job) fyne.CanvasObje settingsStatus, widget.NewSeparator(), 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."), )) }