summaryrefslogtreecommitdiff
path: root/bspc
diff options
context:
space:
mode:
authorhhvn <dev@hhvn.uk>2023-12-30 14:16:56 +0000
committerhhvn <dev@hhvn.uk>2023-12-30 14:16:56 +0000
commitec83d2780491159c4425ee1a5816c2bd4d6e6245 (patch)
tree503715b0f2ac8372bed50fa7e876c7641bceebf7 /bspc
parent0e385d244de19900df25f1c88f29c3cece6106cb (diff)
Make bar run state.GetMon itself
Diffstat (limited to 'bspc')
-rw-r--r--bspc/bspc.go9
1 files changed, 6 insertions, 3 deletions
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 {