Carry the power draw to the bar over the bus, not through a file (hq ADR 0260)
Modules talk over the bus. The power module's bundle puts each fresh reading of its own sampler in its state draw, keyed by the machine; the bar's block shows that state, which the bar's bundle watches under the read the mesh grants it. A new catalogue check refuses a module naming another module's path under /run or /var/lib.
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
# i3status-value <state> <key> (module i3status-rust, novox/hq ADR 0260): one value another module keeps
|
||||
# on the bus, for a block it contributed.
|
||||
#
|
||||
# This module's own tools bundle watches the state on the bus (the mesh grants it the read) and leaves
|
||||
# the value's text in this module's own directory; this prints it. A value not refreshed for thirty
|
||||
# seconds is one its module stopped giving, and prints nothing, so the block hides rather than show an
|
||||
# old number as if it were now.
|
||||
dir="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/i3status-rust/values"
|
||||
f="$dir/$1@$2"
|
||||
if [ -r "$f" ] && [ $(( $(date +%s) - $(stat -c %Y "$f") )) -le 30 ]; then
|
||||
head -n 1 "$f"
|
||||
fi
|
||||
@@ -1,5 +1,5 @@
|
||||
{{- /* A block other modules contribute, in i3status-rust's grammar (novox/hq ADR 0255). The controller
|
||||
renders one piece at a time: its fields (bar, place, order, shows, options) and module. */ -}}
|
||||
renders one piece at a time: its fields (bar, place, order, shows, options), module and machine. */ -}}
|
||||
{{- if eq .shows "battery" -}}
|
||||
[[block]]
|
||||
block = "battery"
|
||||
@@ -16,5 +16,11 @@ missing_format = ""
|
||||
block = "custom"
|
||||
command = {{quote .options.command}}
|
||||
interval = {{.options.interval}}
|
||||
{{- else if eq .shows "state" -}}
|
||||
[[block]]
|
||||
block = "custom"
|
||||
command = {{quote (printf "~/.local/bin/i3status-value %s %s" .options.state (or .options.key .machine))}}
|
||||
interval = 5
|
||||
hide_when_empty = true
|
||||
{{- end}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user