55 lines
1.4 KiB
Go
55 lines
1.4 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/sashakoshka/goparse"
|
|
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"
|
|
|
|
func RegisterBackend () error {
|
|
tomo.Register(1, x.New)
|
|
return nil
|
|
}
|
|
|
|
func SetTheme () error {
|
|
// TODO eventually get rid of this when we make a file format for
|
|
// storing visual styles
|
|
styleSheetName := os.Getenv("TOMO_STYLE_SHEET")
|
|
if styleSheetName != "" {
|
|
styl, _, err := tss.LoadFile(styleSheetName)
|
|
if err == nil {
|
|
tomo.SetStyle(styl)
|
|
return nil
|
|
} else {
|
|
log.Printf (
|
|
"nasin: could not load style sheet '%s'\n%v",
|
|
styleSheetName, parse.Format(err))
|
|
}
|
|
}
|
|
|
|
styl, _ := fallbackStyle.New()
|
|
tomo.SetStyle(styl)
|
|
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
|
|
}
|