From 2d999ec50679772aa9617366e010885fb58c4dfe Mon Sep 17 00:00:00 2001 From: Zev Weiss Date: Tue, 20 Feb 2024 21:00:04 -0800 Subject: [PATCH] acpid: Only read cpuinfo_{min,max}_freq when needed Previously handler.sh would unconditionally fork/exec 'cat' twice to read these files on any invocation, though their values are only used for ac_adapter events. Tidy it up to only read them when handling that case. --- srcpkgs/acpid/files/handler.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/srcpkgs/acpid/files/handler.sh b/srcpkgs/acpid/files/handler.sh index 1ff368bc1ebe05..1b55e09fe2b852 100644 --- a/srcpkgs/acpid/files/handler.sh +++ b/srcpkgs/acpid/files/handler.sh @@ -14,8 +14,8 @@ step_backlight() { done } -minspeed=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq) -maxspeed=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq) +minspeed="/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq" +maxspeed="/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq" setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed" @@ -44,11 +44,11 @@ case "$1" in AC|ACAD|ADP0) case "$4" in 00000000) - printf '%s' "$minspeed" >"$setspeed" + cat "$minspeed" >"$setspeed" #/etc/laptop-mode/laptop-mode start ;; 00000001) - printf '%s' "$maxspeed" >"$setspeed" + cat "$maxspeed" >"$setspeed" #/etc/laptop-mode/laptop-mode stop ;; esac