package hyprman import ( "encoding/json" "fmt" "log" "os/exec" "github.com/charmbracelet/lipgloss" ) type MakoHistory struct { Type string `json:"type"` Data [][]MakoNotification `json:"data"` } type MakoNotification struct { AppName MakoNotificationData `json:"app-name"` Summary MakoNotificationData Body MakoNotificationData // AppIcon MakoNotificationData `json:"app-icon"` // Category MakoNotificationData // DesktopEntry MakoNotificationData `json:"desktop-entry"` // Id MakoNotificationData // Urgency MakoNotificationData // Actions MakoNotificationData } type MakoNotificationData struct { Type string `json:"type"` Data string `json:"data"` } // type Notifcation // type History struct { // notifications []Notifcation // } func getHistory() MakoHistory { var history MakoHistory makoOutput, err := exec.Command("makoctl", "history").CombinedOutput() if err != nil { log.Fatal(err) } json.Unmarshal(makoOutput, &history) return history } // TODO: replace with simple Render function func displayNotification(n MakoNotification) { appStyle := lipgloss.NewStyle(). Bold(true). Foreground(lipgloss.Color("3")). PaddingTop(1) textStyle := lipgloss.NewStyle().Width(80).PaddingLeft(2). BorderStyle(lipgloss.ThickBorder()). BorderLeft(true) fmt.Println(appStyle.Render(n.AppName.Data)) if len(n.Summary.Data) > 0 { fmt.Println(textStyle. BorderForeground(lipgloss.Color("14")). Render(n.Summary.Data)) } if len(n.Body.Data) > 0 { fmt.Println(textStyle. BorderForeground(lipgloss.Color("2")). Render(n.Body.Data)) } } func ListNotifications(number int) { history := getHistory() for i, notification := range history.Data[0] { displayNotification(notification) if i > number-1 { break } } }