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.
This commit is contained in:
2026-10-30 18:19:59 +01:00
parent 0e6ca453be
commit ca8d6f33a5
2 changed files with 11 additions and 6 deletions
+8 -5
View File
@@ -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))
+3 -1
View File
@@ -442,7 +442,9 @@
"attributes": {
"bar": "bottom",
"place": "status",
"order": "45"
"order": "45",
"shows": "state",
"state": "power.draw"
},
"template": "templates/bar-power-draw"
}