26 lines
513 B
Bash
Executable File
26 lines
513 B
Bash
Executable File
#!/bin/sh
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
# Copyright 2022 Sxmo Contributors
|
|
|
|
# shellcheck source=scripts/core/sxmo_common.sh
|
|
. sxmo_common.sh
|
|
|
|
upower -m | while read -r line; do
|
|
# swallow first line ("Monitoring activity from the power daemon...")
|
|
if [ -z "$started" ]; then
|
|
started=1
|
|
continue
|
|
fi
|
|
|
|
line="${line#* }"
|
|
event="${line%%:*}"
|
|
object="${line#*:}"
|
|
object="${object#"${object%%[![:space:]]*}"}"
|
|
|
|
if [ -z "$object" ]; then
|
|
continue
|
|
fi
|
|
|
|
sxmo_hook_battery.sh "$object" "$event"
|
|
done
|