Add missing ACPI volume and brightness scripts latest
authorHugo Villeneuve <hugo@hugovil.com>
Sat, 6 Aug 2016 00:28:32 +0000 (20:28 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Sat, 6 Aug 2016 05:33:22 +0000 (01:33 -0400)
stage2/misc/acpi/brightness.sh [new file with mode: 0755]
stage2/misc/acpi/events/brightness-dn [new file with mode: 0644]
stage2/misc/acpi/events/brightness-up [new file with mode: 0644]
stage2/misc/acpi/vol.sh [new file with mode: 0755]
stage2/pkg/acpid

diff --git a/stage2/misc/acpi/brightness.sh b/stage2/misc/acpi/brightness.sh
new file mode 100755 (executable)
index 0000000..5e884dc
--- /dev/null
@@ -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 (file)
index 0000000..e2a5d09
--- /dev/null
@@ -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 (file)
index 0000000..e2c049e
--- /dev/null
@@ -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 (executable)
index 0000000..caf4972
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+step=5
+
+case $1 in
+    -)
+        amixer set Master $step-
+        ;;
+    +)
+        amixer set Master $step+
+        ;;
+esac
index f9156b9..50684d7 100644 (file)
@@ -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