diff --git a/.github/workflows/aur.yml b/.github/workflows/aur.yml index ad0bcf9..3d31b6e 100644 --- a/.github/workflows/aur.yml +++ b/.github/workflows/aur.yml @@ -1,4 +1,4 @@ -name: aur +name: AUR run-name: ${{ github.ref_name }} - Publishing to AUR on: release: diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index afc5b4e..05e322c 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -1,4 +1,4 @@ -name: container +name: Container run-name: ${{ github.ref_name }} - Publishing Container on: release: diff --git a/README.md b/README.md index 1d3fa22..2a41c52 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ ## Status -![release](https://github.com/ad-on-is/resticity/actions/workflows/build.yml/badge.svg) -![aur](https://github.com/ad-on-is/resticity/actions/workflows/aur.yml/badge.svg) -![container](https://github.com/ad-on-is/resticity/actions/workflows/container.yml/badge.svg) +![release](https://github.com/ad-on-is/resticity/actions/workflows/build.yml/badge.svg?branch=) +![aur](https://github.com/ad-on-is/resticity/actions/workflows/aur.yml/badge.svg?branch=) +![container](https://github.com/ad-on-is/resticity/actions/workflows/container.yml/badge.svg?branch=) > [!IMPORTANT] > I'm still working on the Windows and macOS version. They're not ready yet. diff --git a/app.go b/app.go index 0d28f42..6e28798 100644 --- a/app.go +++ b/app.go @@ -4,9 +4,11 @@ import ( "context" "embed" "os" + "path/filepath" "time" "github.com/ad-on-is/resticity/internal" + "github.com/adrg/xdg" "github.com/charmbracelet/log" "github.com/energye/systray" @@ -35,12 +37,20 @@ func NewApp( return &App{restic: restic, scheduler: scheduler, settings: settings} } +func (a *App) SaveIcon(icon []byte, file string) { + path := filepath.Join(xdg.CacheHome, "resticity") + os.WriteFile(filepath.Join(path, file), icon, 0644) +} + func (a *App) toggleSysTrayIcon() { default_icon, err := assets.ReadFile( "frontend/.output/public/appicon.png", ) if err != nil { log.Error(err) + } else { + a.SaveIcon(default_icon, "appicon.png") + } active_icon, err := assets.ReadFile( "frontend/.output/public/appicon_active.png", @@ -48,6 +58,9 @@ func (a *App) toggleSysTrayIcon() { if err != nil { log.Error(err) + } else { + a.SaveIcon(active_icon, "appicon_active.png") + } _, err = a.scheduler.Gocron.NewJob( diff --git a/frontend/wailsjs/go/main/App.d.ts b/frontend/wailsjs/go/main/App.d.ts index 6a54b7f..efbf41b 100755 --- a/frontend/wailsjs/go/main/App.d.ts +++ b/frontend/wailsjs/go/main/App.d.ts @@ -5,6 +5,8 @@ import {uuid} from '../models'; export function FakeCreateForModels():Promise; +export function SaveIcon(arg1:Array,arg2:string):Promise; + export function SelectDirectory(arg1:string):Promise; export function SelectFile(arg1:string):Promise; diff --git a/frontend/wailsjs/go/main/App.js b/frontend/wailsjs/go/main/App.js index bafd47b..8370678 100755 --- a/frontend/wailsjs/go/main/App.js +++ b/frontend/wailsjs/go/main/App.js @@ -6,6 +6,10 @@ export function FakeCreateForModels() { return window['go']['main']['App']['FakeCreateForModels'](); } +export function SaveIcon(arg1, arg2) { + return window['go']['main']['App']['SaveIcon'](arg1, arg2); +} + export function SelectDirectory(arg1) { return window['go']['main']['App']['SelectDirectory'](arg1); } diff --git a/internal/filelogger.go b/internal/filelogger.go index 99f4c2f..92e976f 100644 --- a/internal/filelogger.go +++ b/internal/filelogger.go @@ -54,14 +54,6 @@ func getFile(t string) string { func appendToFile(f string, m ChanMsg) { - if _, err := os.Stat(f); os.IsNotExist(err) { - _, err := os.Create(f) - if err != nil { - log.Error("filelogger: create "+f, "error", err) - return - } - } - d, err := json.Marshal(m) if err != nil { log.Error("filelogger: marshal "+f, "error", err) @@ -75,6 +67,12 @@ func appendToFile(f string, m ChanMsg) { } func WriteFile(name string, data []byte) error { + if _, err := os.Stat(name); os.IsNotExist(err) { + _, err := os.Create(name) + if err != nil { + return err + } + } f, err := os.OpenFile(name, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600) if err != nil { return err diff --git a/internal/init.go b/internal/init.go index 85715db..77a47a9 100644 --- a/internal/init.go +++ b/internal/init.go @@ -26,7 +26,6 @@ type Resticity struct { func NewResticity() (Resticity, error) { flagArgs := ParseFlags() - outputChan := make(chan ChanMsg) errorChan := make(chan ChanMsg) go NewFileLogger(&outputChan, &errorChan) diff --git a/internal/scheduler.go b/internal/scheduler.go index 135288d..f2a72af 100644 --- a/internal/scheduler.go +++ b/internal/scheduler.go @@ -7,6 +7,7 @@ import ( "sync" "time" + "github.com/adrg/xdg" "github.com/charmbracelet/log" "github.com/gen2brain/beeep" "github.com/go-co-op/gocron/v2" @@ -179,7 +180,7 @@ func (s *Scheduler) Notifiy(schedule Schedule, finished bool, hasError bool) { if hasError { title += " with error" } - beeep.Notify(title, description, "") + beeep.Notify(title, description, xdg.CacheHome+"/resticity/appicon_active.png") } func (s *Scheduler) RescheduleBackups() {