From: phy1729 <phy1729@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] Update acpid handler
Date: Fri, 30 Oct 2020 04:05:18 +0100 [thread overview]
Message-ID: <20201030030518.95HUjR9MfENjJ8EoUOy63hSJEejxaFoSuw2w9EQBb5Y@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-25909@inbox.vuxu.org>
[-- Attachment #1: Type: text/plain, Size: 669 bytes --]
There is an updated pull request by phy1729 against master on the void-packages repository
https://github.com/phy1729/void-packages acpi-handler
https://github.com/void-linux/void-packages/pull/25909
Update acpid handler
The first 5 commits are various cleanups that should have no functional change. The last commit adds support for increasing and decreasing the backlight brightness. If preferred I can rebase that out and keep it as a local modification. (I have another local modification for the volume keys that I don't think can be made generic and upstreamed anyway.)
A patch file from https://github.com/void-linux/void-packages/pull/25909.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-acpi-handler-25909.patch --]
[-- Type: text/x-diff, Size: 9175 bytes --]
From adbd5ef2eaba73e17eb5b3cc269bd2bd24bf8d4a Mon Sep 17 00:00:00 2001
From: Matthew Martin <phy1729@gmail.com>
Date: Sat, 19 Sep 2020 08:46:47 -0500
Subject: [PATCH 1/6] acpid: Use $( rather than `
---
srcpkgs/acpid/files/handler.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/srcpkgs/acpid/files/handler.sh b/srcpkgs/acpid/files/handler.sh
index c2a12be13b1..5535b8bb38f 100644
--- a/srcpkgs/acpid/files/handler.sh
+++ b/srcpkgs/acpid/files/handler.sh
@@ -4,8 +4,8 @@
# 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`
+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 $*
@@ -15,7 +15,7 @@ export USER=$(ps -o user --no-headers $PID)
USERHOME=$(getent passwd $USER | cut -d: -f6)
export XAUTHORITY="$USERHOME/.Xauthority"
for x in /tmp/.X11-unix/*; do
- displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
+ displaynum=$(echo $x | sed s#/tmp/.X11-unix/X##)
if [ x"$XAUTHORITY" != x"" ]; then
export DISPLAY=":$displaynum"
fi
From 5046a9c4126699f204c3c1974c63383eebbd982a Mon Sep 17 00:00:00 2001
From: Matthew Martin <phy1729@gmail.com>
Date: Sat, 19 Sep 2020 08:51:12 -0500
Subject: [PATCH 2/6] acpid: Use spaces consistently
---
srcpkgs/acpid/files/handler.sh | 40 ++++++++++++++++++----------------
1 file changed, 21 insertions(+), 19 deletions(-)
diff --git a/srcpkgs/acpid/files/handler.sh b/srcpkgs/acpid/files/handler.sh
index 5535b8bb38f..0da0d5a094a 100644
--- a/srcpkgs/acpid/files/handler.sh
+++ b/srcpkgs/acpid/files/handler.sh
@@ -26,20 +26,20 @@ case "$1" in
#echo "PowerButton pressed!">/dev/tty5
case "$2" in
PBTN|PWRF)
- logger "PowerButton pressed: $2, shutting down..."
- shutdown -P now
- ;;
- *) logger "ACPI action undefined: $2" ;;
+ logger "PowerButton pressed: $2, shutting down..."
+ shutdown -P now
+ ;;
+ *) logger "ACPI action undefined: $2" ;;
esac
;;
button/sleep)
case "$2" in
SBTN|SLPB)
- # suspend-to-ram
- logger "Sleep Button pressed: $2, suspending..."
- zzz
- ;;
- *) logger "ACPI action undefined: $2" ;;
+ # suspend-to-ram
+ logger "Sleep Button pressed: $2, suspending..."
+ zzz
+ ;;
+ *) logger "ACPI action undefined: $2" ;;
esac
;;
ac_adapter)
@@ -75,16 +75,18 @@ case "$1" in
esac
;;
button/lid)
- case "$3" in
- close)
- # suspend-to-ram
- logger "LID closed, suspending..."
- zzz
- ;;
- open) logger "LID opened" ;;
- *) logger "ACPI action undefined (LID): $2";;
- esac
- ;;
+ case "$3" in
+ close)
+ # suspend-to-ram
+ logger "LID closed, suspending..."
+ zzz
+ ;;
+ open)
+ logger "LID opened"
+ ;;
+ *) logger "ACPI action undefined (LID): $2";;
+ esac
+ ;;
*)
logger "ACPI group/action undefined: $1 / $2"
;;
From 9b9486d1309285c552d6dc1f5cc305b5b1632d11 Mon Sep 17 00:00:00 2001
From: Matthew Martin <phy1729@gmail.com>
Date: Sat, 19 Sep 2020 08:54:27 -0500
Subject: [PATCH 3/6] acpid: Quote all parameter expansions
---
srcpkgs/acpid/files/handler.sh | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/srcpkgs/acpid/files/handler.sh b/srcpkgs/acpid/files/handler.sh
index 0da0d5a094a..700ec46ffad 100644
--- a/srcpkgs/acpid/files/handler.sh
+++ b/srcpkgs/acpid/files/handler.sh
@@ -11,11 +11,11 @@ setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"
set $*
PID=$(pgrep dbus-launch)
-export USER=$(ps -o user --no-headers $PID)
-USERHOME=$(getent passwd $USER | cut -d: -f6)
+export USER=$(ps -o user --no-headers "$PID")
+USERHOME=$(getent passwd "$USER" | cut -d: -f6)
export XAUTHORITY="$USERHOME/.Xauthority"
for x in /tmp/.X11-unix/*; do
- displaynum=$(echo $x | sed s#/tmp/.X11-unix/X##)
+ displaynum=$(echo "$x" | sed s#/tmp/.X11-unix/X##)
if [ x"$XAUTHORITY" != x"" ]; then
export DISPLAY=":$displaynum"
fi
@@ -47,11 +47,11 @@ case "$1" in
AC|ACAD|ADP0)
case "$4" in
00000000)
- echo -n $minspeed >$setspeed
+ echo -n "$minspeed" >"$setspeed"
#/etc/laptop-mode/laptop-mode start
;;
00000001)
- echo -n $maxspeed >$setspeed
+ echo -n "$maxspeed" >"$setspeed"
#/etc/laptop-mode/laptop-mode stop
;;
esac
From 8501a8c44544cc098f45b7fb7cf9b3676086f221 Mon Sep 17 00:00:00 2001
From: Matthew Martin <phy1729@gmail.com>
Date: Sat, 19 Sep 2020 08:55:56 -0500
Subject: [PATCH 4/6] acpid: Use a parameter expansion rather than sed
---
srcpkgs/acpid/files/handler.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/srcpkgs/acpid/files/handler.sh b/srcpkgs/acpid/files/handler.sh
index 700ec46ffad..fb90b501a58 100644
--- a/srcpkgs/acpid/files/handler.sh
+++ b/srcpkgs/acpid/files/handler.sh
@@ -15,7 +15,7 @@ export USER=$(ps -o user --no-headers "$PID")
USERHOME=$(getent passwd "$USER" | cut -d: -f6)
export XAUTHORITY="$USERHOME/.Xauthority"
for x in /tmp/.X11-unix/*; do
- displaynum=$(echo "$x" | sed s#/tmp/.X11-unix/X##)
+ displaynum=${x#/tmp/.X11-unix/X}
if [ x"$XAUTHORITY" != x"" ]; then
export DISPLAY=":$displaynum"
fi
From 37e95a80e0d2fd966904adbf4c1c3aeda7e6207c Mon Sep 17 00:00:00 2001
From: Matthew Martin <phy1729@gmail.com>
Date: Sat, 19 Sep 2020 08:56:19 -0500
Subject: [PATCH 5/6] acpid: Use printf instead of echo
echo with arguments is not well defined by POSIX. Additionally if the
variable starts with -, the results are further undefined. Use printf to
avoid all issues.
---
srcpkgs/acpid/files/handler.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/srcpkgs/acpid/files/handler.sh b/srcpkgs/acpid/files/handler.sh
index fb90b501a58..dd5aa6e03f8 100644
--- a/srcpkgs/acpid/files/handler.sh
+++ b/srcpkgs/acpid/files/handler.sh
@@ -47,11 +47,11 @@ case "$1" in
AC|ACAD|ADP0)
case "$4" in
00000000)
- echo -n "$minspeed" >"$setspeed"
+ printf '%s' "$minspeed" >"$setspeed"
#/etc/laptop-mode/laptop-mode start
;;
00000001)
- echo -n "$maxspeed" >"$setspeed"
+ printf '%s' "$maxspeed" >"$setspeed"
#/etc/laptop-mode/laptop-mode stop
;;
esac
From aa3066bf879c3eeb4c8a0502fedf936afebeb8cd Mon Sep 17 00:00:00 2001
From: Matthew Martin <phy1729@gmail.com>
Date: Sun, 25 Oct 2020 22:33:12 -0500
Subject: [PATCH 6/6] acpid: Add screen brightness controls
---
srcpkgs/acpid/files/handler.sh | 15 +++++++++++++++
srcpkgs/acpid/template | 2 +-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/srcpkgs/acpid/files/handler.sh b/srcpkgs/acpid/files/handler.sh
index dd5aa6e03f8..7c23e3b94ed 100644
--- a/srcpkgs/acpid/files/handler.sh
+++ b/srcpkgs/acpid/files/handler.sh
@@ -4,6 +4,15 @@
# NOTE: This is a 2.6-centric script. If you use 2.4.x, you'll have to
# modify it to not use /sys
+# $1 should be + or - to step up or down the brightness.
+step_backlight() {
+ for backlight in /sys/class/backlight/*/; do
+ [ -d "$backlight" ] || continue
+ step=$(( $(cat "$backlight/max_brightness") / 20 ))
+ printf '%s' "$(( $(cat "$backlight/brightness") $1 step ))" >"$backlight/brightness"
+ done
+}
+
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"
@@ -87,6 +96,12 @@ case "$1" in
*) logger "ACPI action undefined (LID): $2";;
esac
;;
+ video/brightnessdown)
+ step_backlight -
+ ;;
+ video/brightnessup)
+ step_backlight +
+ ;;
*)
logger "ACPI group/action undefined: $1 / $2"
;;
diff --git a/srcpkgs/acpid/template b/srcpkgs/acpid/template
index 8312d0e4e15..a45294f1c57 100644
--- a/srcpkgs/acpid/template
+++ b/srcpkgs/acpid/template
@@ -1,7 +1,7 @@
# Template file for 'acpid'
pkgname=acpid
version=2.0.32
-revision=1
+revision=2
build_style=gnu-configure
short_desc="The ACPI Daemon (acpid) With Netlink Support"
maintainer="Enno Boland <gottox@voidlinux.org>"
next prev parent reply other threads:[~2020-10-30 3:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-27 3:26 [PR PATCH] " phy1729
2020-10-27 3:31 ` fosslinux
2020-10-27 3:49 ` phy1729
2020-10-30 1:09 ` ericonr
2020-10-30 3:05 ` phy1729 [this message]
2020-10-30 3:20 ` phy1729
2021-10-17 22:05 ` [PR PATCH] [Closed]: " Piraty
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201030030518.95HUjR9MfENjJ8EoUOy63hSJEejxaFoSuw2w9EQBb5Y@z \
--to=phy1729@users.noreply.github.com \
--cc=ml@inbox.vuxu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).