2024-05-03 10:46:09 -06:00
|
|
|
//go:build unix && (!darwin)
|
2024-05-06 21:25:25 -06:00
|
|
|
package registrar
|
2024-04-29 14:21:53 -06:00
|
|
|
|
2024-05-28 19:56:52 -06:00
|
|
|
import "os"
|
|
|
|
import "log"
|
2024-04-29 14:21:53 -06:00
|
|
|
import "git.tebibyte.media/tomo/tomo"
|
2024-06-11 22:19:12 -06:00
|
|
|
import "git.tebibyte.media/tomo/backend/x"
|
2024-07-29 13:13:02 -06:00
|
|
|
import "git.tebibyte.media/sashakoshka/goparse"
|
2024-06-11 22:19:12 -06:00
|
|
|
import "git.tebibyte.media/tomo/nasin/internal/icons/xdg"
|
2024-07-28 00:36:28 -06:00
|
|
|
import "git.tebibyte.media/tomo/nasin/internal/style/tss"
|
2024-06-11 22:19:12 -06:00
|
|
|
import "git.tebibyte.media/tomo/nasin/internal/icons/fallback"
|
|
|
|
import "git.tebibyte.media/tomo/nasin/internal/style/fallback"
|
2024-04-29 14:21:53 -06:00
|
|
|
|
2024-06-11 22:27:34 -06:00
|
|
|
func RegisterBackend () error {
|
|
|
|
tomo.Register(1, x.New)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func SetTheme () error {
|
2024-06-03 01:48:13 -06:00
|
|
|
// TODO eventually get rid of this when we make a file format for
|
|
|
|
// storing visual styles
|
2024-07-28 00:36:28 -06:00
|
|
|
styleSheetName := os.Getenv("TOMO_STYLE_SHEET")
|
|
|
|
if styleSheetName != "" {
|
|
|
|
styl, _, err := tss.LoadFile(styleSheetName)
|
2024-05-28 19:56:52 -06:00
|
|
|
if err == nil {
|
2024-07-28 00:36:28 -06:00
|
|
|
tomo.SetStyle(styl)
|
2024-07-29 13:13:02 -06:00
|
|
|
return nil
|
2024-05-28 19:56:52 -06:00
|
|
|
} else {
|
2024-07-29 13:13:02 -06:00
|
|
|
log.Printf (
|
|
|
|
"nasin: could not load style sheet '%s'\n%v",
|
|
|
|
styleSheetName, parse.Format(err))
|
2024-05-28 19:56:52 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-28 00:36:28 -06:00
|
|
|
styl, _ := fallbackStyle.New()
|
2024-06-11 22:19:12 -06:00
|
|
|
tomo.SetStyle(styl)
|
2024-07-28 00:36:28 -06:00
|
|
|
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
|
2024-04-29 14:21:53 -06:00
|
|
|
}
|