summaryrefslogtreecommitdiff
path: root/bspc
diff options
context:
space:
mode:
authorhhvn <dev@hhvn.uk>2024-04-14 13:48:13 +0100
committerhhvn <dev@hhvn.uk>2024-04-14 13:48:13 +0100
commit75a34eb4b035963970c8415316c2b2bd6a81eea6 (patch)
treee648fc1c0df1cf8410a44d22094abceaea67ee4e /bspc
parent6154256e9ad6fcac5360755372612315374fdc21 (diff)
Use config.Urg for desktops with urgent window
Diffstat (limited to 'bspc')
-rw-r--r--bspc/bspc.go43
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")