From fe6a2f45f0ff01e47edba9439b488a6f09dbd428 Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Fri, 5 Aug 2016 20:28:32 -0400 Subject: [PATCH] Add missing ACPI volume and brightness scripts --- stage2/misc/acpi/brightness.sh | 35 +++++++++++++++++++++++++++ stage2/misc/acpi/events/brightness-dn | 2 ++ stage2/misc/acpi/events/brightness-up | 2 ++ stage2/misc/acpi/vol.sh | 12 +++++++++ stage2/pkg/acpid | 3 +-- 5 files changed, 52 insertions(+), 2 deletions(-) create mode 100755 stage2/misc/acpi/brightness.sh create mode 100644 stage2/misc/acpi/events/brightness-dn create mode 100644 stage2/misc/acpi/events/brightness-up create mode 100755 stage2/misc/acpi/vol.sh diff --git a/stage2/misc/acpi/brightness.sh b/stage2/misc/acpi/brightness.sh new file mode 100755 index 0000000..5e884dc --- /dev/null +++ b/stage2/misc/acpi/brightness.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +basedir=/sys/class/backlight + +# In percent +min=10 +step=10 + +dir=$(find ${basedir} -type l) + +read max_raw < ${dir}/max_brightness +read cur_raw < ${dir}/brightness + +min_raw=$(echo "scale=0; (${min} * ${max_raw}) / 100" | bc) +step_raw=$(echo "scale=0; (${step} * ${max_raw}) / 100" | bc) + +case $1 in + -) + new=`expr ${cur_raw} - ${step_raw}` + if [ ${new} -le ${min_raw} ]; then + new=${min_raw} + fi + ;; + +) + new=`expr ${cur_raw} + ${step_raw}` + if [ ${new} -ge ${max_raw} ]; then + new=${max_raw} + fi + ;; + *) + exit 1 + ;; +esac + +echo ${new} > ${dir}/brightness diff --git a/stage2/misc/acpi/events/brightness-dn b/stage2/misc/acpi/events/brightness-dn new file mode 100644 index 0000000..e2a5d09 --- /dev/null +++ b/stage2/misc/acpi/events/brightness-dn @@ -0,0 +1,2 @@ +event=video/brightnessdown +action=/etc/acpi/brightness.sh - diff --git a/stage2/misc/acpi/events/brightness-up b/stage2/misc/acpi/events/brightness-up new file mode 100644 index 0000000..e2c049e --- /dev/null +++ b/stage2/misc/acpi/events/brightness-up @@ -0,0 +1,2 @@ +event=video/brightnessup +action=/etc/acpi/brightness.sh + diff --git a/stage2/misc/acpi/vol.sh b/stage2/misc/acpi/vol.sh new file mode 100755 index 0000000..caf4972 --- /dev/null +++ b/stage2/misc/acpi/vol.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +step=5 + +case $1 in + -) + amixer set Master $step- + ;; + +) + amixer set Master $step+ + ;; +esac diff --git a/stage2/pkg/acpid b/stage2/pkg/acpid index f9156b9..50684d7 100644 --- a/stage2/pkg/acpid +++ b/stage2/pkg/acpid @@ -6,8 +6,7 @@ hvbuild_post() install -v -m644 ${SCRDIR}/misc/acpi/events/* /etc/acpi/events - install -v -m755 ${SCRDIR}/misc/acpi/suspend2ram.sh /etc/acpi - install -v -m755 ${SCRDIR}/misc/acpi/shutdown.sh /etc/acpi + install -v -m755 ${SCRDIR}/misc/acpi/*.sh /etc/acpi install -v -m740 ${SCRDIR}/bootscripts/acpid /etc/rc.d/init.d bootscript_add_rcsysinit acpid 65 90 -- 2.20.1