diff --git a/acpid/PKGBUILD b/acpid/PKGBUILD new file mode 100644 index 000000000..8c4eada86 --- /dev/null +++ b/acpid/PKGBUILD @@ -0,0 +1,47 @@ +# +# Apps Packages for Chakra, part of chakra-project.org +# +# Maintainer: Adrián Chaves Fernández (Gallaecio) + +pkgname=acpid +pkgver=2.0.15 +pkgrel=1 +pkgdesc="A daemon for delivering ACPI power management events." +arch=('i686' 'x86_64') +url="http://tedfelix.com/linux/acpid-netlink.html" +license=('GPL2') +depends=('bash') +backup=('etc/acpi/events/anything' + 'etc/acpi/handler.sh' + 'etc/conf.d/acpid') +source=(http://www.tedfelix.com/linux/$pkgname-$pkgver.tar.xz + acpid + acpid.conf.d + anything + handler.sh) +categories=('system') +md5sums=('1b1c8775adab6a994a386c45af6b86dc' + 'd9ca7f71f520238a0448fab105a23fe9' + '91fdb3709c878eed757d192a420251a1' + '2d37b98d6e74bab815604b8b48c6cfd4' + '0e8dd13793b1baa79a745f4034888367') + +build() { + cd $pkgname-$pkgver + ./configure --prefix=/usr + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR="$pkgdir" install + + # Install supplementary scripts. + install -Dm755 ../acpid "$pkgdir/etc/rc.d/acpid" + install -Dm644 ../anything "$pkgdir/etc/acpi/events/anything" + install -Dm755 ../handler.sh "$pkgdir/etc/acpi/handler.sh" + install -Dm644 ../acpid.conf.d "$pkgdir/etc/conf.d/acpid" + + # Set world readable bit on the acpid binary. + chmod 755 "$pkgdir"/usr/sbin/acpid +} diff --git a/acpid/acpid b/acpid/acpid new file mode 100644 index 000000000..9a4ab8ac7 --- /dev/null +++ b/acpid/acpid @@ -0,0 +1,37 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions + +[ -f /etc/conf.d/acpid ] && . /etc/conf.d/acpid + +PID=`pidof -o %PPID /usr/sbin/acpid` +case "$1" in + start) + stat_busy "Starting acpid" + [ -z "$PID" ] && /usr/sbin/acpid $ACPID_ARGS + if [ $? -gt 0 ]; then + stat_fail + else + add_daemon acpid + stat_done + fi + ;; + stop) + stat_busy "Stopping acpid" + [ ! -z "$PID" ] && kill $PID &> /dev/null + if [ $? -gt 0 ]; then + stat_fail + else + rm_daemon acpid + stat_done + fi + ;; + restart) + $0 stop + $0 start + ;; + *) + echo "usage: $0 {start|stop|restart}" +esac +exit 0 diff --git a/acpid/acpid.conf.d b/acpid/acpid.conf.d new file mode 100644 index 000000000..25c9cc1ef --- /dev/null +++ b/acpid/acpid.conf.d @@ -0,0 +1,6 @@ +# +# Arguments to be passed to the acpid daemon +# + +ACPID_ARGS="" + diff --git a/acpid/anything b/acpid/anything new file mode 100644 index 000000000..d1828989b --- /dev/null +++ b/acpid/anything @@ -0,0 +1,3 @@ +# Pass all events to our one handler script +event=.* +action=/etc/acpi/handler.sh %e diff --git a/acpid/handler.sh b/acpid/handler.sh new file mode 100644 index 000000000..ad31d1aa9 --- /dev/null +++ b/acpid/handler.sh @@ -0,0 +1,65 @@ +#!/bin/sh +# Default acpi script that takes an entry for all actions + +# NOTE: This is a 2.6-centric script. If you use 2.4.x, you'll have to +# modify it to not use /sys + +minspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq` +maxspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq` +setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed" + +set $* + +case "$1" in + button/power) + #echo "PowerButton pressed!">/dev/tty5 + case "$2" in + PWRF) logger "PowerButton pressed: $2" ;; + *) logger "ACPI action undefined: $2" ;; + esac + ;; + button/sleep) + case "$2" in + SLPB) echo -n mem >/sys/power/state ;; + *) logger "ACPI action undefined: $2" ;; + esac + ;; + ac_adapter) + case "$2" in + AC) + case "$4" in + 00000000) + echo -n $minspeed >$setspeed + #/etc/laptop-mode/laptop-mode start + ;; + 00000001) + echo -n $maxspeed >$setspeed + #/etc/laptop-mode/laptop-mode stop + ;; + esac + ;; + *) logger "ACPI action undefined: $2" ;; + esac + ;; + battery) + case "$2" in + BAT0) + case "$4" in + 00000000) #echo "offline" >/dev/tty5 + ;; + 00000001) #echo "online" >/dev/tty5 + ;; + esac + ;; + CPU0) + ;; + *) logger "ACPI action undefined: $2" ;; + esac + ;; + button/lid) + #echo "LID switched!">/dev/tty5 + ;; + *) + logger "ACPI group/action undefined: $1 / $2" + ;; +esac