diff options
Diffstat (limited to 'bspc/bspc.go')
| -rw-r--r-- | bspc/bspc.go | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/bspc/bspc.go b/bspc/bspc.go index 03e2400..5976a68 100644 --- a/bspc/bspc.go +++ b/bspc/bspc.go @@ -52,12 +52,6 @@ type Rect struct { Height uint } -type Node struct { - ID int - FirstChild *Node - SecondChild *Node -} - type Desktop struct { Focused bool Name string @@ -66,6 +60,39 @@ type Desktop struct { Root *Node } +type Node struct { + ID int + FirstChild *Node + SecondChild *Node + Client *Client +} + +type Client struct { + Urgent bool +} + +func urgentWalk(n *Node) bool { + switch { + case n == nil: + return false + case n.Client != nil && n.Client.Urgent: + return true + } + + if urgentWalk(n.FirstChild) { + return true + } + if urgentWalk(n.SecondChild) { + return true + } + + return false +} + +func (d *Desktop) Urgent() bool { + return urgentWalk(d.Root) +} + var reloadEvents = []string{ "monitor_rename", "monitor_swap", @@ -83,7 +110,9 @@ var reloadEvents = []string{ "node_add", "node_remove", "node_swap", - "node_transfer" } + "node_transfer", + "node_flag", // for urgency +} func getState() (*State, error) { cmd := exec.Command("bspc", "wm", "-d") |