diff options
| author | hhvn <dev@hhvn.uk> | 2024-04-14 13:48:13 +0100 |
|---|---|---|
| committer | hhvn <dev@hhvn.uk> | 2024-04-14 13:48:13 +0100 |
| commit | 75a34eb4b035963970c8415316c2b2bd6a81eea6 (patch) | |
| tree | e648fc1c0df1cf8410a44d22094abceaea67ee4e /bspc/bspc.go | |
| parent | 6154256e9ad6fcac5360755372612315374fdc21 (diff) | |
Use config.Urg for desktops with urgent window
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") |