omnisiah-blessings/main.go

62 lines
1.4 KiB
Go

package main
import (
"bytes"
_ "embed"
"fmt"
"io"
"time"
"github.com/faiface/beep/mp3"
"github.com/faiface/beep/speaker"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)
//go:embed blessing.txt
var blessingBytes []byte
//go:embed chant.mp3
var chantBytes []byte
func playChant() {
streamer, format, err := mp3.Decode(io.NopCloser(bytes.NewReader(chantBytes)))
if err != nil {
fmt.Printf("ERROR: Unable to decode chant: %v\n", err)
return
}
speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/10))
speaker.Play(streamer)
}
func main() {
// Convert blessing text to string and preserve line breaks
blessing := string(blessingBytes)
// Start the chant in the background
go playChant()
// Create the app
a := app.NewWithID("com.omnissiah.blessing")
a.Settings().SetTheme(theme.DarkTheme())
w := a.NewWindow("🔧 Rite of Activation")
// Create a Label with correct formatting (line breaks preserved)
label := widget.NewLabel(blessing)
label.Alignment = fyne.TextAlignCenter
label.Wrapping = fyne.TextWrapWord // This will ensure text stays within bounds
// Scrollable container to hold the label
scroll := container.NewScroll(label)
scroll.SetMinSize(fyne.NewSize(640, 720))
// Set window content
w.SetContent(scroll)
w.Resize(fyne.NewSize(660, 740))
w.ShowAndRun()
}