Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[client] Allow freebsd to build netbird-ui #3212

Merged
merged 3 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/golang-test-freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
copyback: false
release: "14.1"
prepare: |
pkg install -y go
pkg install -y go pkgconf xorg

# -x - to print all executed commands
# -e - to faile on first error
Expand Down
4 changes: 2 additions & 2 deletions client/ui/client_ui.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !(linux && 386) && !freebsd
//go:build !(linux && 386)

package main

Expand Down Expand Up @@ -876,7 +876,7 @@ func openURL(url string) error {
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
case "darwin":
err = exec.Command("open", url).Start()
case "linux":
case "linux", "freebsd":
err = exec.Command("xdg-open", url).Start()
default:
err = fmt.Errorf("unsupported platform")
Expand Down
24 changes: 14 additions & 10 deletions client/ui/font_bsd.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build darwin
//go:build freebsd || openbsd || netbsd || dragonfly

package main

Expand All @@ -9,18 +9,22 @@ import (
log "github.com/sirupsen/logrus"
)

const defaultFontPath = "/Library/Fonts/Arial Unicode.ttf"

func (s *serviceClient) setDefaultFonts() {
// TODO: add other bsd paths
if runtime.GOOS != "darwin" {
return
paths := []string{
"/usr/local/share/fonts/TTF/DejaVuSans.ttf",
"/usr/local/share/fonts/dejavu/DejaVuSans.ttf",
"/usr/local/share/noto/NotoSans-Regular.ttf",
"/usr/local/share/fonts/noto/NotoSans-Regular.ttf",
"/usr/local/share/fonts/liberation-fonts-ttf/LiberationSans-Regular.ttf",
}

if _, err := os.Stat(defaultFontPath); err != nil {
log.Errorf("Failed to find default font file: %v", err)
return
for _, fontPath := range paths {
if _, err := os.Stat(fontPath); err == nil {
os.Setenv("FYNE_FONT", fontPath)
log.Debugf("Using font: %s", fontPath)
return
}
}

os.Setenv("FYNE_FONT", defaultFontPath)
log.Errorf("Failed to find any suitable font files for %s", runtime.GOOS)
}
18 changes: 18 additions & 0 deletions client/ui/font_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
"os"

log "github.com/sirupsen/logrus"
)

const defaultFontPath = "/Library/Fonts/Arial Unicode.ttf"

func (s *serviceClient) setDefaultFonts() {
if _, err := os.Stat(defaultFontPath); err != nil {
log.Errorf("Failed to find default font file: %v", err)
return
}

os.Setenv("FYNE_FONT", defaultFontPath)
}
2 changes: 1 addition & 1 deletion client/ui/network.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !(linux && 386) && !freebsd
//go:build !(linux && 386)

package main

Expand Down
Loading