diff --git a/application.go b/application.go index 5d1e5aa..3c62c81 100644 --- a/application.go +++ b/application.go @@ -133,6 +133,7 @@ func RunApplication (application Application) { if err != nil { log.Fatalln("nasin: could not register backend:", err) } err = tomo.Run(func () { err := registrar.SetTheme() + err := registrar.SetIconSet() if err != nil { log.Fatalln("nasin: could not set theme:", err) } err = application.Init() if err != nil { log.Fatalln("nasin: could not run application:", err) } diff --git a/internal/registrar/registrar_unix.go b/internal/registrar/registrar_unix.go index e3adceb..be01bfd 100644 --- a/internal/registrar/registrar_unix.go +++ b/internal/registrar/registrar_unix.go @@ -6,9 +6,9 @@ import "log" import "git.tebibyte.media/tomo/tomo" import "git.tebibyte.media/tomo/backend/x" import "git.tebibyte.media/tomo/nasin/internal/icons/xdg" +import "git.tebibyte.media/tomo/nasin/internal/style/tss" 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) @@ -16,28 +16,35 @@ func RegisterBackend () error { } func SetTheme () error { - var styl *tomo.Style // TODO eventually get rid of this when we make a file format for // storing visual styles - // TODO migrate aluminum - // 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) + styleSheetName := os.Getenv("TOMO_STYLE_SHEET") + if styleSheetName != "" { + styl, _, err := tss.LoadFile(styleSheetName) if err == nil { - icons = xdgIconTheme + tomo.SetStyle(styl) } else { - log.Printf("nasin: could not load icon theme '%s': %v", iconThemeName, err) + log.Printf("nasin: could not load style sheet '%s': %v", styleSheetName, err) } } + styl, _ := fallbackStyle.New() tomo.SetStyle(styl) - tomo.SetIconSet(icons) - return nil + return nil +} + +func SetIconSet () error { + iconSet := fallbackIcons.New() + iconSetName := os.Getenv("TOMO_XDG_ICON_THEME") + if iconSetName != "" { + xdgIconSet, err := xdgIcons.FindThemeWarn(iconSetName, iconSet) + if err == nil { + iconSet = xdgIconSet + } else { + log.Printf("nasin: could not load icon theme '%s': %v", iconSetName, err) + } + } + + tomo.SetIconSet(iconSet) + return nil }