commit 75a34eb4b035963970c8415316c2b2bd6a81eea6
parent 6154256e9ad6fcac5360755372612315374fdc21
Author: hhvn <dev@hhvn.uk>
Date: Sun, 14 Apr 2024 13:48:13 +0100
Use config.Urg for desktops with urgent window
Diffstat:
2 files changed, 40 insertions(+), 11 deletions(-)
diff --git a/bar.go b/bar.go
@@ -114,10 +114,10 @@ func (b bar) draw(state *bspc.State, blocks []*status.Block) error {
cx += 5
- if d.Focused {
- bg = config.Sel
- } else {
- bg = config.FgDark
+ switch {
+ case d.Urgent(): bg = config.Urg
+ case d.Focused: bg = config.Sel
+ default: bg = config.FgDark
}
filled = d.Root != nil
diff --git 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")