mirror of
https://github.com/UnnoTed/wireguird
synced 2026-07-25 17:24:46 -04:00
only use tempdir for icons when not installed
This commit is contained in:
parent
739caf2339
commit
56ece27102
28
main.go
28
main.go
@ -82,23 +82,27 @@ func createTray(application *gtk.Application) (*appindicator.Indicator, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
icons := []string{"wireguard_off", "wg_connected"}
|
iconsDir := "/usr/share/wireguird/Icon/"
|
||||||
for _, icon := range icons {
|
if _, err := os.Stat(iconsDir); os.IsNotExist(err) {
|
||||||
iconBytes, err := static.ReadFile("./Icon/" + icon + ".png")
|
iconsDir = iconTmpDir
|
||||||
if err != nil {
|
icons := []string{"wireguard_off", "wg_connected"}
|
||||||
log.Error().Err(err).Str("icon", icon).Msg("Error reading embedded icon")
|
for _, icon := range icons {
|
||||||
return nil, err
|
iconBytes, err := static.ReadFile("./Icon/" + icon + ".png")
|
||||||
}
|
if err != nil {
|
||||||
|
log.Error().Err(err).Str("icon", icon).Msg("Error reading embedded icon")
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
iconPath := filepath.Join(iconTmpDir, icon+".png")
|
iconPath := filepath.Join(iconTmpDir, icon+".png")
|
||||||
if err := os.WriteFile(iconPath, iconBytes, 0644); err != nil {
|
if err := os.WriteFile(iconPath, iconBytes, 0644); err != nil {
|
||||||
log.Error().Err(err).Str("icon", icon).Msg("Failed to write temp icon")
|
log.Error().Err(err).Str("icon", icon).Msg("Failed to write temp icon")
|
||||||
return nil, err
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
indicator := appindicator.New(application.GetApplicationID(), "wireguard_off", appindicator.CategoryApplicationStatus)
|
indicator := appindicator.New(application.GetApplicationID(), "wireguard_off", appindicator.CategoryApplicationStatus)
|
||||||
indicator.SetIconThemePath(iconTmpDir)
|
indicator.SetIconThemePath(iconsDir)
|
||||||
indicator.SetTitle("Wireguird")
|
indicator.SetTitle("Wireguird")
|
||||||
// indicator.SetLabel("Wireguird", "")
|
// indicator.SetLabel("Wireguird", "")
|
||||||
indicator.SetStatus(appindicator.StatusActive)
|
indicator.SetStatus(appindicator.StatusActive)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user