From 64813f5a9c4ed159f13709fd4fd90aaf7554049b Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Thu, 6 Jun 2024 13:11:21 -0500 Subject: [PATCH] formatting --- cmd/mako.go | 1 + internal/eww.go | 2 +- internal/mako.go | 29 +++++++++++++++++++++++++---- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/cmd/mako.go b/cmd/mako.go index aaccd63..1f7a7b5 100644 --- a/cmd/mako.go +++ b/cmd/mako.go @@ -13,6 +13,7 @@ var makoCmd = &cobra.Command{ }, } + var ( number int ) diff --git a/internal/eww.go b/internal/eww.go index 0a3855f..e1b64fa 100644 --- a/internal/eww.go +++ b/internal/eww.go @@ -73,7 +73,7 @@ func (hm *Hyprman) generateEwwClasses() { } func ewwBar1(cmd string) { - time.Sleep(2 * time.Second) + time.Sleep(3 * time.Second) if err := exec.Command("eww", cmd, "bar1").Run(); err != nil { log.Fatal(err) } diff --git a/internal/mako.go b/internal/mako.go index 25d5b6e..b5c7cef 100644 --- a/internal/mako.go +++ b/internal/mako.go @@ -5,6 +5,8 @@ import ( "fmt" "log" "os/exec" + + "github.com/charmbracelet/lipgloss" ) type MakoHistory struct { @@ -29,6 +31,12 @@ type MakoNotificationData struct { Data string `json:"data"` } +// type Notifcation + +// type History struct { +// notifications []Notifcation +// } + func getHistory() MakoHistory { var history MakoHistory makoOutput, err := exec.Command("makoctl", "history").CombinedOutput() @@ -39,19 +47,32 @@ func getHistory() MakoHistory { return history } +// TODO: replace with simple Render function func displayNotification(n MakoNotification) { - fmt.Println("- ", n.AppName.Data) + 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(n.Summary.Data) + fmt.Println(textStyle. + BorderForeground(lipgloss.Color("14")). + Render(n.Summary.Data)) } if len(n.Body.Data) > 0 { - fmt.Println(n.Body.Data) + fmt.Println(textStyle. + BorderForeground(lipgloss.Color("2")). + Render(n.Body.Data)) } } + func ListNotifications(number int) { history := getHistory() - // TODO: align output ? by app-name for i, notification := range history.Data[0] { displayNotification(notification) if i > number-1 {