Migrate notifier from portmaster-ui to cmds/notifier, remove some duplicated code, move assets to assets/data and add a small go package in assets to allow embedding icons
This commit is contained in:
25
cmds/notifier/icons.go
Normal file
25
cmds/notifier/icons.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
icons "github.com/safing/portmaster/assets"
|
||||
)
|
||||
|
||||
var (
|
||||
appIconEnsureOnce sync.Once
|
||||
appIconPath string
|
||||
)
|
||||
|
||||
func ensureAppIcon() (location string, err error) {
|
||||
appIconEnsureOnce.Do(func() {
|
||||
if appIconPath == "" {
|
||||
appIconPath = filepath.Join(dataDir, "exec", "portmaster.png")
|
||||
}
|
||||
err = os.WriteFile(appIconPath, icons.PNG, 0o0644)
|
||||
})
|
||||
|
||||
return appIconPath, err
|
||||
}
|
||||
Reference in New Issue
Block a user