From 48ca75555522716f0f686dcae3dd6cf3d8ad714d Mon Sep 17 00:00:00 2001 From: davidovski Date: Tue, 31 May 2022 11:05:19 +0100 Subject: removed idea of repos --- repo/acpid/acpid.confd | 7 +++++++ repo/acpid/acpid.initd | 28 ++++++++++++++++++++++++++++ repo/acpid/acpid.xibuild | 37 +++++++++++++++++++++++++++++++++++++ repo/acpid/anything | 3 +++ repo/acpid/handler.sh | 36 ++++++++++++++++++++++++++++++++++++ repo/acpid/lid-closed | 21 +++++++++++++++++++++ repo/acpid/power-supply-ac | 25 +++++++++++++++++++++++++ 7 files changed, 157 insertions(+) create mode 100644 repo/acpid/acpid.confd create mode 100644 repo/acpid/acpid.initd create mode 100644 repo/acpid/acpid.xibuild create mode 100644 repo/acpid/anything create mode 100644 repo/acpid/handler.sh create mode 100644 repo/acpid/lid-closed create mode 100644 repo/acpid/power-supply-ac (limited to 'repo/acpid') diff --git a/repo/acpid/acpid.confd b/repo/acpid/acpid.confd new file mode 100644 index 0000000..2b3d304 --- /dev/null +++ b/repo/acpid/acpid.confd @@ -0,0 +1,7 @@ +# Configuration file for /etc/init.d/acpid (from acpid package) + +# Additional arguments to pass to acpid. +command_args="--logevents" + +# Uncomment to use process supervisor. +#supervisor="supervise-daemon" diff --git a/repo/acpid/acpid.initd b/repo/acpid/acpid.initd new file mode 100644 index 0000000..c2d60f9 --- /dev/null +++ b/repo/acpid/acpid.initd @@ -0,0 +1,28 @@ +#!/sbin/openrc-run + +description="The ACPI Daemon" + +extra_started_commands="reload" +description_reload="Reload configuration" + +command="/sbin/acpid" +command_args="--foreground ${command_args:-}" +command_background="yes" +pidfile="/run/$RC_SVCNAME.pid" + +depend() { + need dev localmount + after hwdrivers modules + provide acpid + keyword -vserver -lxc +} + +reload() { + ebegin "Reloading $RC_SVCNAME configuration" + if [ "$supervisor" ]; then + $supervisor "$RC_SVCNAME" --signal HUP + else + start-stop-daemon --pidfile "$pidfile" --signal HUP + fi + eend $? +} diff --git a/repo/acpid/acpid.xibuild b/repo/acpid/acpid.xibuild new file mode 100644 index 0000000..f960ac0 --- /dev/null +++ b/repo/acpid/acpid.xibuild @@ -0,0 +1,37 @@ +#!/bin/sh + +MAKEDEPS="make" +DEPS="musl" + +PKG_VER=2.0.33 +SOURCE=https://downloads.sourceforge.net/acpid2/acpid-$PKG_VER.tar.xz +DESC="Daemon for battery, power, and thermal readings" + +ADDITIONAL=" + acpid.confd + acpid.initd + anything + handler.sh + lid-closed + power-supply-ac +" +build () { + ./configure --prefix=/usr \ + --docdir=/usr/share/doc/acpid-$PKG_VER && + make +} + +package () { + make DESTDIR=$PKG_DEST install + install -m755 -d $PKG_DEST/etc/acpi/events && + cp -r samples $PKG_DEST/usr/share/doc/acpid-$PKG_VER + + install -D -m 755 handler.sh etc/acpi/handler.sh + install -D -m 644 anything etc/acpi/events/anything + install -D -m 755 power-supply-ac usr/share/acpid/ + install -D -m 755 lid-closed usr/share/acpid/ + + install -D -m 755 acpid.initd etc/init.d/acpid + install -D -m 644 acpid.confd etc/conf.d/acpid + +} diff --git a/repo/acpid/anything b/repo/acpid/anything new file mode 100644 index 0000000..d182898 --- /dev/null +++ b/repo/acpid/anything @@ -0,0 +1,3 @@ +# Pass all events to our one handler script +event=.* +action=/etc/acpi/handler.sh %e diff --git a/repo/acpid/handler.sh b/repo/acpid/handler.sh new file mode 100644 index 0000000..412ac02 --- /dev/null +++ b/repo/acpid/handler.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# vim: set ts=4: +# +# This is the default ACPI handler script that is configured in +# /etc/acpi/events/anything to be called for every ACPI event. +# You can edit it and add your own actions; treat it as a configuration file. +# +PATH="/usr/share/acpid:$PATH" +alias log='logger -t acpid' + +# ::: +case "$1:$2:$3:$4" in + +button/power:PWRF:*) + log 'Power button pressed' + # Shutdown the system unless it has a lid (notebook). + [ -e /proc/acpi/button/lid/LID ] || poweroff +;; +button/sleep:SLPB:*) + log 'Sleep button pressed' + # Suspend to RAM. + zzz +;; +button/lid:*:close:*) + log 'Lid closed' + # Suspend to RAM if AC adapter is not connected. + power-supply-ac || zzz +;; +ac_adapter:*:*:*0) + log 'AC adapter unplugged' + # Suspend to RAM if notebook's lid is closed. + lid-closed && zzz +;; +esac + +exit 0 diff --git a/repo/acpid/lid-closed b/repo/acpid/lid-closed new file mode 100644 index 0000000..57ffb71 --- /dev/null +++ b/repo/acpid/lid-closed @@ -0,0 +1,21 @@ +#!/bin/sh +# This script exits with status 0 if the latop's lid is closed, 1 if opened, +# 10 if /proc/acpi/button/lid/LID/state does not exist or is not readable. +set -u + +STATE_FILE='/proc/acpi/button/lid/LID/state' + +verbose=false +[ "${1:-}" = '-v' ] && verbose=true + +if ! [ -r "$STATE_FILE" ]; then + $verbose && echo "$STATE_FILE does not exist or is not readable!" >&2 + exit 10 +fi + +read -r _ state < "$STATE_FILE" || exit 10 + +[ "$state" = 'closed' ]; rc=$? + +$verbose && echo $rc +exit $rc diff --git a/repo/acpid/power-supply-ac b/repo/acpid/power-supply-ac new file mode 100644 index 0000000..337aae2 --- /dev/null +++ b/repo/acpid/power-supply-ac @@ -0,0 +1,25 @@ +#!/bin/sh +# This script exits with status 0 when the computer is on AC power (or no AC +# power supply found), 1 otherwise (i.e. running on battery). +set -u + +verbose=false +[ "${1:-}" = '-v' ] && verbose=true + +# If we do not have any power supplies, assume we are on AC. +rc=0 + +# Iterate through power supplies sysfs knows about. +for ps in /sys/class/power_supply/*; do + [ -r $ps/online ] || continue + # We know we have an AC adaptor, our default return changes to failed. + rc=1 + + if [ "$(cat $ps/online)" -eq 1 ]; then + rc=0 + break + fi +done + +$verbose && echo $rc +exit $rc -- cgit v1.2.1