From ec83d2780491159c4425ee1a5816c2bd4d6e6245 Mon Sep 17 00:00:00 2001 From: hhvn Date: Sat, 30 Dec 2023 14:16:56 +0000 Subject: Make bar run state.GetMon itself --- bspc/bspc.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bspc') diff --git a/bspc/bspc.go b/bspc/bspc.go index eb0ea01..a089595 100644 --- a/bspc/bspc.go +++ b/bspc/bspc.go @@ -5,6 +5,7 @@ import ( "fmt" "time" "bufio" + "errors" "strings" "os/exec" "encoding/json" @@ -12,19 +13,21 @@ import ( "hhvn.uk/hbspbar/common" ) +var ErrMonNotFound = errors.New("monitor not found") + type State struct { Monitors []*Monitor FocusedMonitorID int } -func (s *State) GetMon(id int) (*Monitor) { +func (s *State) GetMon(id int) (*Monitor, error) { for _, m := range s.Monitors { if m.ID == id { - return m + return m, nil } } - return nil + return nil, ErrMonNotFound } type Monitor struct { -- cgit v1.2.3