Skip to content

Commit

Permalink
chore: workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Adis Durakovic committed Mar 16, 2024
1 parent ffc5492 commit 6cbe605
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/aur.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: aur
name: AUR
run-name: ${{ github.ref_name }} - Publishing to AUR
on:
release:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: container
name: Container
run-name: ${{ github.ref_name }} - Publishing Container
on:
release:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 13 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -35,19 +37,30 @@ 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",
)

if err != nil {
log.Error(err)
} else {
a.SaveIcon(active_icon, "appicon_active.png")

}

_, err = a.scheduler.Gocron.NewJob(
Expand Down
2 changes: 2 additions & 0 deletions frontend/wailsjs/go/main/App.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {uuid} from '../models';

export function FakeCreateForModels():Promise<internal.SnapshotGroup>;

export function SaveIcon(arg1:Array<number>,arg2:string):Promise<void>;

export function SelectDirectory(arg1:string):Promise<string>;

export function SelectFile(arg1:string):Promise<string>;
Expand Down
4 changes: 4 additions & 0 deletions frontend/wailsjs/go/main/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
14 changes: 6 additions & 8 deletions internal/filelogger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion internal/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion internal/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 6cbe605

Please sign in to comment.