nasin/internal/registrar/registrar_unix.go
2024-06-12 00:27:34 -04:00

44 lines
1.1 KiB
Go

//go:build unix && (!darwin)
package registrar
import "os"
import "log"
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/backend/x"
import "git.tebibyte.media/tomo/nasin/internal/style"
import "git.tebibyte.media/tomo/nasin/internal/icons/xdg"
import "git.tebibyte.media/tomo/nasin/internal/icons/fallback"
import "git.tebibyte.media/tomo/nasin/internal/style/fallback"
import "git.tebibyte.media/tomo/nasin/internal/style/aluminum"
func RegisterBackend () error {
tomo.Register(1, x.New)
return nil
}
func SetTheme () error {
var styl *style.Style
// TODO eventually get rid of this when we make a file format for
// storing visual styles
if os.Getenv("TOMO_USE_ALUMINUM_STYLE") != "" {
styl = aluminumStyle.New()
} else {
styl = fallbackStyle.New()
}
icons := fallbackIcons.New()
iconThemeName := os.Getenv("TOMO_XDG_ICON_THEME")
if iconThemeName != "" {
xdgIconTheme, err := xdgIcons.FindThemeWarn(iconThemeName, icons)
if err == nil {
icons = xdgIconTheme
} else {
log.Printf("nasin: could not load icon theme '%s': %v", iconThemeName, err)
}
}
tomo.SetStyle(styl)
tomo.SetIcons(icons)
return nil
}