omnisiah-blessings/main.go
2025-04-24 17:25:31 -07:00

63 lines
1.4 KiB
Go

package main
import (
"fmt"
"os"
"path/filepath"
"io/ioutil"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)
func getBlessingPath() (string, error) {
// Get path to running executable
exePath, err := os.Executable()
if err != nil {
return "", fmt.Errorf("unable to get executable path: %w", err)
}
// Extract drive letter (e.g., "C:")
drive := filepath.VolumeName(exePath)
if drive == "" {
return "", fmt.Errorf("could not determine drive letter")
}
// Construct full path to blessing file
blessingPath := filepath.Join(drive+"\\", ".content", "blessing.txt")
return blessingPath, nil
}
func main() {
blessingPath, err := getBlessingPath()
if err != nil {
fmt.Printf("ERROR: %v\n", err)
os.Exit(1)
}
// Read the blessing file
blessingBytes, err := ioutil.ReadFile(blessingPath)
if err != nil {
fmt.Printf("ERROR: Could not read blessing from %s: %v\n", blessingPath, err)
os.Exit(1)
}
blessing := string(blessingBytes)
// Initialize app
a := app.NewWithID("com.omnissiah.blessing")
a.Settings().SetTheme(theme.DarkTheme())
w := a.NewWindow("🔧 Rite of Activation")
// Render markdown
md := widget.NewRichTextFromMarkdown(blessing)
scroll := container.NewScroll(md)
scroll.SetMinSize(fyne.NewSize(600, 700))
w.SetContent(scroll)
w.Resize(fyne.NewSize(640, 720))
w.ShowAndRun()
}