Skip to content

Commit

Permalink
feat: support different icons on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Falk Nielsen committed Dec 18, 2023
1 parent e74b8c7 commit d368c0c
Show file tree
Hide file tree
Showing 22 changed files with 85 additions and 30 deletions.
21 changes: 21 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package config
import (
"flag"
"fmt"
"net/url"
"os"
"os/user"
"path/filepath"
Expand Down Expand Up @@ -57,6 +58,13 @@ func NewConfig(configPath string) (*Config, error) {
config.PeriodicSyncInterval = &defaultTime
}

// validate the netbox url, and allows us to strip http/https etc
url, err := parseRawURL(config.NetboxUrl)
if err != nil {
return nil, err
}

config.NetboxUrl = url.Host
config.configPath = configPath
return config, nil
}
Expand Down Expand Up @@ -119,3 +127,16 @@ func ParseFlags() (string, error) {
// Return the configuration path
return configPath, nil
}

func parseRawURL(rawurl string) (u *url.URL, err error) {
u, err = url.ParseRequestURI(rawurl)
if err != nil || u.Host == "" {
u, repErr := url.ParseRequestURI("https://" + rawurl)
if repErr != nil {
return nil, err
}
return u, nil
}

return u, nil
}
30 changes: 0 additions & 30 deletions internal/tray/assets/assets.go

This file was deleted.

32 changes: 32 additions & 0 deletions internal/tray/assets/assets_osx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//go:build darwin

package assets

import _ "embed"

//go:embed osx/green-circle-icon.png
var StatusIconGreen []byte

//go:embed osx/red-circle-icon.png
var StatusIconRed []byte

//go:embed osx/icon.png
var Icon []byte

//go:embed osx/icon-1.png
var AnimateIcon1 []byte

//go:embed osx/icon-2.png
var AnimateIcon2 []byte

//go:embed osx/icon-3.png
var AnimateIcon3 []byte

//go:embed osx/icon-4.png
var AnimateIcon4 []byte

//go:embed osx/icon-5.png
var AnimateIcon5 []byte

//go:embed osx/icon-6.png
var AnimateIcon6 []byte
32 changes: 32 additions & 0 deletions internal/tray/assets/assets_win.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//go:build windows

package assets

import _ "embed"

//go:embed win/green-circle-icon.ico
var StatusIconGreen []byte

//go:embed win/red-circle-icon.ico
var StatusIconRed []byte

//go:embed win/icon.ico
var Icon []byte

//go:embed win/icon-1.ico
var AnimateIcon1 []byte

//go:embed win/icon-2.ico
var AnimateIcon2 []byte

//go:embed win/icon-3.ico
var AnimateIcon3 []byte

//go:embed win/icon-4.ico
var AnimateIcon4 []byte

//go:embed win/icon-5.ico
var AnimateIcon5 []byte

//go:embed win/icon-6.ico
var AnimateIcon6 []byte
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added internal/tray/assets/win/green-circle-icon.ico
Binary file not shown.
Binary file added internal/tray/assets/win/icon-1.ico
Binary file not shown.
Binary file added internal/tray/assets/win/icon-2.ico
Binary file not shown.
Binary file added internal/tray/assets/win/icon-3.ico
Binary file not shown.
Binary file added internal/tray/assets/win/icon-4.ico
Binary file not shown.
Binary file added internal/tray/assets/win/icon-5.ico
Binary file not shown.
Binary file added internal/tray/assets/win/icon-6.ico
Binary file not shown.
Binary file added internal/tray/assets/win/icon.ico
Binary file not shown.
Binary file added internal/tray/assets/win/red-circle-icon.ico
Binary file not shown.

0 comments on commit d368c0c

Please sign in to comment.