formatting

This commit is contained in:
Daylin Morgan 2024-06-06 13:11:21 -05:00
parent a32a141867
commit 64813f5a9c
Signed by: daylin
GPG Key ID: 950D13E9719334AD
3 changed files with 27 additions and 5 deletions

View File

@ -13,6 +13,7 @@ var makoCmd = &cobra.Command{
}, },
} }
var ( var (
number int number int
) )

View File

@ -73,7 +73,7 @@ func (hm *Hyprman) generateEwwClasses() {
} }
func ewwBar1(cmd string) { func ewwBar1(cmd string) {
time.Sleep(2 * time.Second) time.Sleep(3 * time.Second)
if err := exec.Command("eww", cmd, "bar1").Run(); err != nil { if err := exec.Command("eww", cmd, "bar1").Run(); err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -5,6 +5,8 @@ import (
"fmt" "fmt"
"log" "log"
"os/exec" "os/exec"
"github.com/charmbracelet/lipgloss"
) )
type MakoHistory struct { type MakoHistory struct {
@ -29,6 +31,12 @@ type MakoNotificationData struct {
Data string `json:"data"` Data string `json:"data"`
} }
// type Notifcation
// type History struct {
// notifications []Notifcation
// }
func getHistory() MakoHistory { func getHistory() MakoHistory {
var history MakoHistory var history MakoHistory
makoOutput, err := exec.Command("makoctl", "history").CombinedOutput() makoOutput, err := exec.Command("makoctl", "history").CombinedOutput()
@ -39,19 +47,32 @@ func getHistory() MakoHistory {
return history return history
} }
// TODO: replace with simple Render function
func displayNotification(n MakoNotification) { 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 { 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 { 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) { func ListNotifications(number int) {
history := getHistory() history := getHistory()
// TODO: align output ? by app-name
for i, notification := range history.Data[0] { for i, notification := range history.Data[0] {
displayNotification(notification) displayNotification(notification)
if i > number-1 { if i > number-1 {