Take the catalogue's composition rules into the node-engine
ADR 0593 §7: the composer with its refusals leaves mesh-sdk, so mesh-sdk carries no composition rule. The catalogue functions only the node-engine's composition reaches (Resolve, Resolution's Compose, Declaration, DataItems, LeftOut, Rules and the rest, the settings, placeholder and template refusals, the rendering helpers) are copied with their tests into internal/compose/resolution; a method of a mesh-sdk shape becomes a function taking it first. The composition calls its own copies, and the captured catalogue its tests read lives here now, shared by mesh-compose's tests. Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
This commit is contained in:
+90
@@ -0,0 +1,90 @@
|
||||
#!/bin/sh
|
||||
# power-moment MOMENT [--force] — run every module's code for one power moment (novox/hq ADR 0211).
|
||||
# Shipped by the mesh's power module; edit the catalogue.
|
||||
#
|
||||
# MOMENT is after-boot, before-sleep, after-wake, before-shutdown, on-mains or on-battery, or
|
||||
# `supply`, which reads the machine's power source and runs on-mains or on-battery once per change.
|
||||
#
|
||||
# The moment's file holds what the controller placed: each module's code under a line `# <module>`.
|
||||
# Each module's piece runs on its own, with sh, as root, bounded by MESH_POWER_BOUND seconds
|
||||
# (default 30) and killed 5 s after that, so one module that hangs cannot hold the machine awake or
|
||||
# stop the next module. Every outcome goes to the journal under the tag mesh-power.
|
||||
set -u
|
||||
|
||||
moment=${1:-}
|
||||
force=${2:-}
|
||||
moments=/etc/mesh-power/moments
|
||||
bound=${MESH_POWER_BOUND:-30}
|
||||
runtime=/run/mesh-power
|
||||
|
||||
say() { logger -t mesh-power -- "$*" 2>/dev/null || true; printf '%s\n' "$*"; }
|
||||
|
||||
# The power source as the kernel says it: on mains when any Mains supply is online. A machine with
|
||||
# no Mains supply (a desktop, a server, a USB-C source only) has no source to change.
|
||||
source_now() {
|
||||
found=no
|
||||
for s in /sys/class/power_supply/*; do
|
||||
[ "$(cat "$s/type" 2>/dev/null)" = Mains ] || continue
|
||||
found=yes
|
||||
[ "$(cat "$s/online" 2>/dev/null)" = 1 ] && { echo on-mains; return; }
|
||||
done
|
||||
[ "$found" = yes ] && echo on-battery || echo none
|
||||
}
|
||||
|
||||
case "$moment" in
|
||||
supply)
|
||||
now=$(source_now)
|
||||
[ "$now" = none ] && exit 0
|
||||
mkdir -p "$runtime"
|
||||
last=$(cat "$runtime/source" 2>/dev/null || true)
|
||||
[ "$now" = "$last" ] && [ "$force" != --force ] && exit 0
|
||||
echo "$now" >"$runtime/source"
|
||||
moment=$now
|
||||
;;
|
||||
after-boot | before-sleep | after-wake | on-mains | on-battery) ;;
|
||||
before-shutdown)
|
||||
# Run only while the machine is really going down. The unit that runs it is stopped at shutdown,
|
||||
# and also when the module is taken off the machine; the second must not run anyone's shutdown code.
|
||||
state=$(systemctl is-system-running 2>/dev/null || true)
|
||||
if [ "$state" != stopping ] && [ "$force" != --force ]; then
|
||||
say "moment=before-shutdown skipped: the system is $state, not stopping"
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "power-moment: no moment $moment (after-boot, before-sleep, after-wake, before-shutdown, on-mains, on-battery, supply)" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
file="$moments/$moment"
|
||||
[ -r "$file" ] || { say "moment=$moment: nothing placed"; exit 0; }
|
||||
|
||||
work=$(mktemp -d) || exit 1
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
|
||||
# One file per module piece, in the order the controller placed them. A line that is exactly
|
||||
# "# <module name>" opens a piece; lines before the first are the holder's own header.
|
||||
awk -v dir="$work" '
|
||||
/^# [a-z0-9][a-z0-9-]*$/ { n++; name = substr($0, 3); out = sprintf("%s/%03d-%s", dir, n, name); next }
|
||||
n > 0 { print > out }
|
||||
' "$file"
|
||||
|
||||
ran=0 failed=0
|
||||
for piece in "$work"/*; do
|
||||
[ -e "$piece" ] || continue
|
||||
module=${piece##*/}
|
||||
module=${module#*-}
|
||||
start=$(date +%s)
|
||||
timeout --kill-after=5 "$bound" sh "$piece" </dev/null >"$piece.out" 2>&1
|
||||
rc=$?
|
||||
took=$(($(date +%s) - start))
|
||||
ran=$((ran + 1))
|
||||
case $rc in
|
||||
0) say "moment=$moment module=$module ok in ${took}s" ;;
|
||||
124 | 137) failed=$((failed + 1)); say "moment=$moment module=$module ended after ${bound}s: it did not finish" ;;
|
||||
*) failed=$((failed + 1)); say "moment=$moment module=$module exited $rc: $(tail -n 3 "$piece.out" | tr '\n' ' ')" ;;
|
||||
esac
|
||||
done
|
||||
say "moment=$moment: $ran piece(s), $failed failed"
|
||||
exit 0
|
||||
@@ -0,0 +1,408 @@
|
||||
{
|
||||
"module": "power",
|
||||
"version": "1",
|
||||
"moved": true,
|
||||
"templates": "templates",
|
||||
"capabilities": [
|
||||
"package-manager",
|
||||
"service-manager"
|
||||
],
|
||||
"claims": [
|
||||
{
|
||||
"name": "node-power",
|
||||
"scope": "node"
|
||||
}
|
||||
],
|
||||
"emits": [
|
||||
"booted",
|
||||
"sleeping",
|
||||
"woke",
|
||||
"shutting-down",
|
||||
"on-mains",
|
||||
"on-battery",
|
||||
"battery-low"
|
||||
],
|
||||
"state": [
|
||||
{
|
||||
"name": "draw",
|
||||
"ttl-seconds": 30,
|
||||
"per-machine": true
|
||||
}
|
||||
],
|
||||
"tools": [
|
||||
"power_state",
|
||||
"power_hooks",
|
||||
"power_history",
|
||||
"power_run",
|
||||
"power_check"
|
||||
],
|
||||
"config": {
|
||||
"handle-power-key": {
|
||||
"type": "string",
|
||||
"description": "What logind does when the power key is pressed: one of logind's actions, such as suspend, ignore or poweroff (logind.conf(5)); the operator's choice for this machine, with no default.",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"poweroff",
|
||||
"reboot",
|
||||
"halt",
|
||||
"kexec",
|
||||
"suspend",
|
||||
"hibernate",
|
||||
"hybrid-sleep",
|
||||
"suspend-then-hibernate",
|
||||
"lock",
|
||||
"factory-reset",
|
||||
"sleep"
|
||||
],
|
||||
"trusted": true,
|
||||
"required": true
|
||||
},
|
||||
"handle-lid-switch": {
|
||||
"type": "string",
|
||||
"description": "What logind does when the lid is closed on battery: one of logind's actions, such as suspend, ignore or poweroff (logind.conf(5)); the operator's choice for this machine, with no default.",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"poweroff",
|
||||
"reboot",
|
||||
"halt",
|
||||
"kexec",
|
||||
"suspend",
|
||||
"hibernate",
|
||||
"hybrid-sleep",
|
||||
"suspend-then-hibernate",
|
||||
"lock",
|
||||
"factory-reset",
|
||||
"sleep"
|
||||
],
|
||||
"trusted": true,
|
||||
"required": true
|
||||
},
|
||||
"handle-lid-switch-external-power": {
|
||||
"type": "string",
|
||||
"description": "What logind does when the lid is closed on external power: one of logind's actions, such as suspend, ignore or poweroff (logind.conf(5)); the operator's choice for this machine, with no default.",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"poweroff",
|
||||
"reboot",
|
||||
"halt",
|
||||
"kexec",
|
||||
"suspend",
|
||||
"hibernate",
|
||||
"hybrid-sleep",
|
||||
"suspend-then-hibernate",
|
||||
"lock",
|
||||
"factory-reset",
|
||||
"sleep"
|
||||
],
|
||||
"trusted": true,
|
||||
"required": true
|
||||
},
|
||||
"handle-lid-switch-docked": {
|
||||
"type": "string",
|
||||
"description": "What logind does when the lid is closed while docked or with another screen attached: one of logind's actions, such as suspend, ignore or poweroff (logind.conf(5)); the operator's choice for this machine, with no default.",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"poweroff",
|
||||
"reboot",
|
||||
"halt",
|
||||
"kexec",
|
||||
"suspend",
|
||||
"hibernate",
|
||||
"hybrid-sleep",
|
||||
"suspend-then-hibernate",
|
||||
"lock",
|
||||
"factory-reset",
|
||||
"sleep"
|
||||
],
|
||||
"trusted": true,
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"id": "polkit",
|
||||
"type": "package",
|
||||
"package": "polkit"
|
||||
},
|
||||
{
|
||||
"id": "scripts",
|
||||
"type": "archive",
|
||||
"path": "/usr/local/lib/mesh-power",
|
||||
"artifact": "scripts",
|
||||
"unknown": "program"
|
||||
},
|
||||
{
|
||||
"id": "config-dir",
|
||||
"type": "directory",
|
||||
"path": "/etc/mesh-power",
|
||||
"mode": "0755",
|
||||
"unknown": "program"
|
||||
},
|
||||
{
|
||||
"id": "moments-dir",
|
||||
"type": "directory",
|
||||
"path": "/etc/mesh-power/moments",
|
||||
"mode": "0755",
|
||||
"unknown": "program"
|
||||
},
|
||||
{
|
||||
"id": "moment-after-boot",
|
||||
"type": "file",
|
||||
"path": "/etc/mesh-power/moments/after-boot",
|
||||
"mode": "0644",
|
||||
"template": "templates/mesh-power/moments/after-boot"
|
||||
},
|
||||
{
|
||||
"id": "moment-before-sleep",
|
||||
"type": "file",
|
||||
"path": "/etc/mesh-power/moments/before-sleep",
|
||||
"mode": "0644",
|
||||
"template": "templates/mesh-power/moments/before-sleep"
|
||||
},
|
||||
{
|
||||
"id": "moment-after-wake",
|
||||
"type": "file",
|
||||
"path": "/etc/mesh-power/moments/after-wake",
|
||||
"mode": "0644",
|
||||
"template": "templates/mesh-power/moments/after-wake"
|
||||
},
|
||||
{
|
||||
"id": "moment-before-shutdown",
|
||||
"type": "file",
|
||||
"path": "/etc/mesh-power/moments/before-shutdown",
|
||||
"mode": "0644",
|
||||
"template": "templates/mesh-power/moments/before-shutdown"
|
||||
},
|
||||
{
|
||||
"id": "moment-on-mains",
|
||||
"type": "file",
|
||||
"path": "/etc/mesh-power/moments/on-mains",
|
||||
"mode": "0644",
|
||||
"template": "templates/mesh-power/moments/on-mains"
|
||||
},
|
||||
{
|
||||
"id": "moment-on-battery",
|
||||
"type": "file",
|
||||
"path": "/etc/mesh-power/moments/on-battery",
|
||||
"mode": "0644",
|
||||
"template": "templates/mesh-power/moments/on-battery"
|
||||
},
|
||||
{
|
||||
"id": "logind-drop-ins",
|
||||
"type": "directory",
|
||||
"path": "/etc/systemd/logind.conf.d",
|
||||
"mode": "0755",
|
||||
"unknown": "program"
|
||||
},
|
||||
{
|
||||
"id": "logind-power",
|
||||
"type": "file",
|
||||
"path": "/etc/systemd/logind.conf.d/power.conf",
|
||||
"mode": "0644",
|
||||
"template": "templates/systemd/logind.conf.d/power.conf"
|
||||
},
|
||||
{
|
||||
"id": "logind",
|
||||
"type": "service",
|
||||
"unit": "systemd-logind.service",
|
||||
"reload-on": [
|
||||
"logind-power"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "after-boot-unit",
|
||||
"type": "file",
|
||||
"path": "/etc/systemd/system/mesh-power-after-boot.service",
|
||||
"mode": "0644",
|
||||
"template": "templates/systemd/system/mesh-power-after-boot.service"
|
||||
},
|
||||
{
|
||||
"id": "before-shutdown-unit",
|
||||
"type": "file",
|
||||
"path": "/etc/systemd/system/mesh-power-before-shutdown.service",
|
||||
"mode": "0644",
|
||||
"template": "templates/systemd/system/mesh-power-before-shutdown.service"
|
||||
},
|
||||
{
|
||||
"id": "before-sleep-unit",
|
||||
"type": "file",
|
||||
"path": "/etc/systemd/system/mesh-power-before-sleep.service",
|
||||
"mode": "0644",
|
||||
"template": "templates/systemd/system/mesh-power-before-sleep.service"
|
||||
},
|
||||
{
|
||||
"id": "after-wake-unit",
|
||||
"type": "file",
|
||||
"path": "/etc/systemd/system/mesh-power-after-wake.service",
|
||||
"mode": "0644",
|
||||
"template": "templates/systemd/system/mesh-power-after-wake.service"
|
||||
},
|
||||
{
|
||||
"id": "supply-unit",
|
||||
"type": "file",
|
||||
"path": "/etc/systemd/system/mesh-power-supply.service",
|
||||
"mode": "0644",
|
||||
"template": "templates/systemd/system/mesh-power-supply.service"
|
||||
},
|
||||
{
|
||||
"id": "sleep-drop-ins",
|
||||
"type": "directory",
|
||||
"path": "/etc/systemd/system/sleep.target.d",
|
||||
"mode": "0755",
|
||||
"unknown": "program"
|
||||
},
|
||||
{
|
||||
"id": "sleep-wants",
|
||||
"type": "file",
|
||||
"path": "/etc/systemd/system/sleep.target.d/mesh-power.conf",
|
||||
"mode": "0644",
|
||||
"template": "templates/systemd/system/sleep.target.d/mesh-power.conf"
|
||||
},
|
||||
{
|
||||
"id": "suspend-drop-ins",
|
||||
"type": "directory",
|
||||
"path": "/etc/systemd/system/suspend.target.d",
|
||||
"mode": "0755",
|
||||
"unknown": "program"
|
||||
},
|
||||
{
|
||||
"id": "suspend-wants",
|
||||
"type": "file",
|
||||
"path": "/etc/systemd/system/suspend.target.d/mesh-power.conf",
|
||||
"mode": "0644",
|
||||
"template": "templates/systemd/system/suspend.target.d/mesh-power.conf"
|
||||
},
|
||||
{
|
||||
"id": "hibernate-drop-ins",
|
||||
"type": "directory",
|
||||
"path": "/etc/systemd/system/hibernate.target.d",
|
||||
"mode": "0755",
|
||||
"unknown": "program"
|
||||
},
|
||||
{
|
||||
"id": "hibernate-wants",
|
||||
"type": "file",
|
||||
"path": "/etc/systemd/system/hibernate.target.d/mesh-power.conf",
|
||||
"mode": "0644",
|
||||
"template": "templates/systemd/system/hibernate.target.d/mesh-power.conf"
|
||||
},
|
||||
{
|
||||
"id": "hybrid-sleep-drop-ins",
|
||||
"type": "directory",
|
||||
"path": "/etc/systemd/system/hybrid-sleep.target.d",
|
||||
"mode": "0755",
|
||||
"unknown": "program"
|
||||
},
|
||||
{
|
||||
"id": "hybrid-sleep-wants",
|
||||
"type": "file",
|
||||
"path": "/etc/systemd/system/hybrid-sleep.target.d/mesh-power.conf",
|
||||
"mode": "0644",
|
||||
"template": "templates/systemd/system/hybrid-sleep.target.d/mesh-power.conf"
|
||||
},
|
||||
{
|
||||
"id": "suspend-then-hibernate-drop-ins",
|
||||
"type": "directory",
|
||||
"path": "/etc/systemd/system/suspend-then-hibernate.target.d",
|
||||
"mode": "0755",
|
||||
"unknown": "program"
|
||||
},
|
||||
{
|
||||
"id": "suspend-then-hibernate-wants",
|
||||
"type": "file",
|
||||
"path": "/etc/systemd/system/suspend-then-hibernate.target.d/mesh-power.conf",
|
||||
"mode": "0644",
|
||||
"template": "templates/systemd/system/suspend-then-hibernate.target.d/mesh-power.conf"
|
||||
},
|
||||
{
|
||||
"id": "udev-rule",
|
||||
"type": "file",
|
||||
"path": "/etc/udev/rules.d/90-mesh-power.rules",
|
||||
"mode": "0644",
|
||||
"template": "templates/udev/rules.d/90-mesh-power.rules"
|
||||
},
|
||||
{
|
||||
"id": "after-boot",
|
||||
"type": "service",
|
||||
"unit": "mesh-power-after-boot.service",
|
||||
"state": "running",
|
||||
"boot": "enabled"
|
||||
},
|
||||
{
|
||||
"id": "before-shutdown",
|
||||
"type": "service",
|
||||
"unit": "mesh-power-before-shutdown.service",
|
||||
"state": "running",
|
||||
"boot": "enabled"
|
||||
},
|
||||
{
|
||||
"id": "draw-dir",
|
||||
"type": "directory",
|
||||
"path": "/run/mesh-power",
|
||||
"mode": "0755",
|
||||
"unknown": "program"
|
||||
},
|
||||
{
|
||||
"id": "draw",
|
||||
"type": "process",
|
||||
"name": "mesh-power-draw",
|
||||
"artifact": "tools-go",
|
||||
"run": [
|
||||
"./power",
|
||||
"draw"
|
||||
],
|
||||
"health": {
|
||||
"kind": "unit"
|
||||
}
|
||||
}
|
||||
],
|
||||
"build": {
|
||||
"artifacts": [
|
||||
{
|
||||
"name": "tools-go",
|
||||
"kind": "bundle",
|
||||
"language": "go",
|
||||
"system": "arch",
|
||||
"from": "cmd/power",
|
||||
"binary": "power",
|
||||
"loads": [
|
||||
"power"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "scripts",
|
||||
"kind": "archive",
|
||||
"from": "files"
|
||||
},
|
||||
{
|
||||
"name": "templates",
|
||||
"kind": "archive",
|
||||
"from": "templates"
|
||||
}
|
||||
]
|
||||
},
|
||||
"items": [
|
||||
{
|
||||
"collection": "contribution:node-bar:block",
|
||||
"name": "battery",
|
||||
"if-capability": "battery",
|
||||
"attributes": {
|
||||
"bar": "bottom",
|
||||
"place": "status",
|
||||
"order": "40"
|
||||
},
|
||||
"template": "templates/bar-battery"
|
||||
},
|
||||
{
|
||||
"collection": "contribution:node-bar:block",
|
||||
"name": "power-draw",
|
||||
"if-capability": "power-meter",
|
||||
"attributes": {
|
||||
"bar": "bottom",
|
||||
"place": "status",
|
||||
"order": "45"
|
||||
},
|
||||
"template": "templates/bar-power-draw"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
[[block]]
|
||||
block = "battery"
|
||||
format = "$icon $percentage{ $time|}"
|
||||
charging_format = "$icon $percentage{ $time|}"
|
||||
not_charging_format = "$icon $percentage"
|
||||
full_format = "$icon $percentage"
|
||||
empty_format = "$icon $percentage"
|
||||
missing_format = ""
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
[[block]]
|
||||
block = "custom"
|
||||
command = "~/.local/bin/i3status-value power.draw ${machine:name}"
|
||||
interval = 5
|
||||
hide_when_empty = true
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
# What every module on this machine runs at the moment after-boot, as the mesh placed it (module power,
|
||||
# novox/hq ADR 0211). Replaced on every push: code is added by the module it belongs to, as a
|
||||
# contribution for this moment. Each module's piece runs on its own, as root, bounded in time.
|
||||
${shell:after-boot:first}${shell:after-boot:normal}${shell:after-boot:last}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
# What every module on this machine runs at the moment after-wake, as the mesh placed it (module power,
|
||||
# novox/hq ADR 0211). Replaced on every push: code is added by the module it belongs to, as a
|
||||
# contribution for this moment. Each module's piece runs on its own, as root, bounded in time.
|
||||
${shell:after-wake:first}${shell:after-wake:normal}${shell:after-wake:last}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
# What every module on this machine runs at the moment before-shutdown, as the mesh placed it (module power,
|
||||
# novox/hq ADR 0211). Replaced on every push: code is added by the module it belongs to, as a
|
||||
# contribution for this moment. Each module's piece runs on its own, as root, bounded in time.
|
||||
${shell:before-shutdown:first}${shell:before-shutdown:normal}${shell:before-shutdown:last}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
# What every module on this machine runs at the moment before-sleep, as the mesh placed it (module power,
|
||||
# novox/hq ADR 0211). Replaced on every push: code is added by the module it belongs to, as a
|
||||
# contribution for this moment. Each module's piece runs on its own, as root, bounded in time.
|
||||
${shell:before-sleep:first}${shell:before-sleep:normal}${shell:before-sleep:last}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
# What every module on this machine runs at the moment on-battery, as the mesh placed it (module power,
|
||||
# novox/hq ADR 0211). Replaced on every push: code is added by the module it belongs to, as a
|
||||
# contribution for this moment. Each module's piece runs on its own, as root, bounded in time.
|
||||
${shell:on-battery:first}${shell:on-battery:normal}${shell:on-battery:last}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
# What every module on this machine runs at the moment on-mains, as the mesh placed it (module power,
|
||||
# novox/hq ADR 0211). Replaced on every push: code is added by the module it belongs to, as a
|
||||
# contribution for this moment. Each module's piece runs on its own, as root, bounded in time.
|
||||
${shell:on-mains:first}${shell:on-mains:normal}${shell:on-mains:last}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
# Written by the mesh (module power, novox/hq ADR 0211). Replaced on every push.
|
||||
#
|
||||
# The power key and the lid, from this module's settings: the mesh's, then this machine's.
|
||||
[Login]
|
||||
HandlePowerKey=${config:handle-power-key}
|
||||
HandleLidSwitch=${config:handle-lid-switch}
|
||||
HandleLidSwitchExternalPower=${config:handle-lid-switch-external-power}
|
||||
HandleLidSwitchDocked=${config:handle-lid-switch-docked}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
# Written by the mesh (module power, novox/hq ADR 0211). Replaced on every push.
|
||||
[Unit]
|
||||
Wants=mesh-power-after-wake.service
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
# Written by the mesh (module power, novox/hq ADR 0211). Replaced on every push.
|
||||
[Unit]
|
||||
Wants=mesh-power-after-wake.service
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
# Written by the mesh (module power, novox/hq ADR 0211). Replaced on every push.
|
||||
[Unit]
|
||||
Description=Every module's code after boot (mesh power)
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/local/lib/mesh-power/bin/power-moment after-boot
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
# Written by the mesh (module power, novox/hq ADR 0211). Replaced on every push.
|
||||
#
|
||||
# Pulled in by the four sleep targets through this module's drop-ins on them, and ordered after
|
||||
# them, so it runs once the machine is awake again. Never enabled.
|
||||
[Unit]
|
||||
Description=Every module's code after waking (mesh power)
|
||||
After=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/lib/mesh-power/bin/power-moment after-wake
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
# Written by the mesh (module power, novox/hq ADR 0211). Replaced on every push.
|
||||
#
|
||||
# Started at boot and left active; stopping it is the shutdown. Ordered after the network, so at
|
||||
# shutdown it stops, and runs every module's code, while the network is still up.
|
||||
[Unit]
|
||||
Description=Every module's code before shutdown (mesh power)
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/bin/true
|
||||
ExecStop=/usr/local/lib/mesh-power/bin/power-moment before-shutdown
|
||||
TimeoutStopSec=120
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
# Written by the mesh (module power, novox/hq ADR 0211). Replaced on every push.
|
||||
#
|
||||
# Pulled in by sleep.target through this module's drop-in on it, never enabled: a one-shot waiting
|
||||
# for a sleep is not a service whose state the mesh can declare.
|
||||
[Unit]
|
||||
Description=Every module's code before sleep (mesh power)
|
||||
Before=sleep.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/lib/mesh-power/bin/power-moment before-sleep
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
# Written by the mesh (module power, novox/hq ADR 0211). Replaced on every push.
|
||||
#
|
||||
# Started by the module's udev rule when a power supply changes; runs on-mains or on-battery once per
|
||||
# change of source.
|
||||
[Unit]
|
||||
Description=Every module's code for the power source (mesh power)
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/lib/mesh-power/bin/power-moment supply
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
# Written by the mesh (module power, novox/hq ADR 0211). Replaced on every push.
|
||||
[Unit]
|
||||
Wants=mesh-power-before-sleep.service
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
# Written by the mesh (module power, novox/hq ADR 0211). Replaced on every push.
|
||||
[Unit]
|
||||
Wants=mesh-power-after-wake.service
|
||||
testdata/beside/mesh-catalog/modules/power/templates/systemd/system/suspend.target.d/mesh-power.conf
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
# Written by the mesh (module power, novox/hq ADR 0211). Replaced on every push.
|
||||
[Unit]
|
||||
Wants=mesh-power-after-wake.service
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
# Written by the mesh (module power, novox/hq ADR 0211). Replaced on every push.
|
||||
# Only the charger's change can switch the machine between mains and battery. A battery reports its
|
||||
# level many times a minute, and USB-C supplies come and go; matching them started the supply unit
|
||||
# every second or two on the laptop.
|
||||
SUBSYSTEM=="power_supply", ACTION=="change", ATTR{type}=="Mains", RUN+="/usr/bin/systemctl --no-block start mesh-power-supply.service"
|
||||
Reference in New Issue
Block a user