From ca8d6f33a598f4cb388712644fb11793ea485163 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 30 Oct 2026 18:19:59 +0100 Subject: [PATCH] Say on power's draw item which state its bar block reads, so the bar's holder can be granted it (issue 774) i3status-rust on g14 and shanks cannot watch power.draw ("was issued: none", 148 times): its read was granted from the bar contribution's data (shows: state, options.state; catalogue.ReadsGranted), and design 57 L3 moved the block to an item, whose attributes said nothing of it, while ReadsGranted reads contributions alone. Quick fix: `reads: power.draw` on i3status-rust, which grants every machine's draw instead of its own key (ADR 0260). Thorough fix: the item says its read (shows: state, state: power.draw), and mesh-sdk's ReadsGranted grants a held item's read as it grants a contribution's, keyed to the machine. Chose thorough; its mesh-sdk half is another repository's, and until it lands the fault stays. --- modules/power/cmd/power/templates_test.go | 13 ++++++++----- modules/power/module.json | 4 +++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/power/cmd/power/templates_test.go b/modules/power/cmd/power/templates_test.go index 1ba16b8c..71c9b1bd 100644 --- a/modules/power/cmd/power/templates_test.go +++ b/modules/power/cmd/power/templates_test.go @@ -84,7 +84,9 @@ func TestEveryFileTakesItsTextFromATemplateOutsideTheUnpackedFiles(t *testing.T) // The bar's blocks are two items of the collection the bar places (design 57 L3, issue 781): the text i3status-rust's // bars hold for the battery and for the power draw, byte for byte as the bar's own template rendered them before, the -// draw's key being the machine's own name. +// draw's key being the machine's own name. The draw's item says the state its text reads (shows: state, state: +// power.draw), as the bar's contribution said it before, so the bar's holder is granted this machine's key of it (the +// sweep of 2026-10-30, issue 774: moved to an item, it said nothing, and i3status-rust was issued no read). func TestTheBarBlocksAreTwoItemsOfTheBarsCollection(t *testing.T) { raw, err := os.ReadFile("../../module.json") if err != nil { @@ -106,19 +108,20 @@ func TestTheBarBlocksAreTwoItemsOfTheBarsCollection(t *testing.T) { if len(m.Contributions) != 0 || len(m.Items) != 2 { t.Fatalf("%d contributions and %d items", len(m.Contributions), len(m.Items)) } - want := []struct{ name, capability, order, template, text string }{ - {"battery", "battery", "40", "templates/bar-battery", "[[block]]\nblock = \"battery\"\n" + + want := []struct{ name, capability, order, reads, template, text string }{ + {"battery", "battery", "40", "", "templates/bar-battery", "[[block]]\nblock = \"battery\"\n" + "format = \"$icon $percentage{ $time|}\"\ncharging_format = \"$icon $percentage{ $time|}\"\n" + "not_charging_format = \"$icon $percentage\"\nfull_format = \"$icon $percentage\"\n" + "empty_format = \"$icon $percentage\"\nmissing_format = \"\"\n\n"}, - {"power-draw", "power-meter", "45", "templates/bar-power-draw", "[[block]]\nblock = \"custom\"\n" + + {"power-draw", "power-meter", "45", "power.draw", "templates/bar-power-draw", "[[block]]\nblock = \"custom\"\n" + "command = \"~/.local/bin/i3status-value power.draw ${machine:name}\"\ninterval = 5\nhide_when_empty = true\n\n"}, } for i, w := range want { it := m.Items[i] if it.Collection != "contribution:node-bar:block" || it.Name != w.name || it.IfCapability != w.capability || it.Template != w.template || it.Attributes["bar"] != "bottom" || it.Attributes["place"] != "status" || - it.Attributes["order"] != w.order || len(it.Attributes) != 3 { + it.Attributes["order"] != w.order || it.Attributes["state"] != w.reads || + (w.reads != "") != (it.Attributes["shows"] == "state") || len(it.Attributes) != map[bool]int{false: 3, true: 5}[w.reads != ""] { t.Errorf("item %d is %+v", i, it) } text, err := os.ReadFile(filepath.Join("../..", w.template)) diff --git a/modules/power/module.json b/modules/power/module.json index 909499ad..c43e601c 100644 --- a/modules/power/module.json +++ b/modules/power/module.json @@ -442,7 +442,9 @@ "attributes": { "bar": "bottom", "place": "status", - "order": "45" + "order": "45", + "shows": "state", + "state": "power.draw" }, "template": "templates/bar-power-draw" }