acpid: cleanup handler
* Use $( rather than ` * Use spaces consistently * Quote all parameter expansions * Use a parameter expansion rather than sed * 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. * Add screen brightness controls * drop all dbus/xauth nonsense (by Piraty) Closes: #25909 [via git-merge-pr]
This commit is contained in:
parent
3abe83fe2c
commit
c101203b25
2 changed files with 41 additions and 37 deletions
|
@ -4,42 +4,38 @@
|
|||
# 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`
|
||||
# $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"
|
||||
|
||||
set $*
|
||||
|
||||
PID=$(pgrep dbus-launch)
|
||||
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##`
|
||||
if [ x"$XAUTHORITY" != x"" ]; then
|
||||
export DISPLAY=":$displaynum"
|
||||
fi
|
||||
done
|
||||
|
||||
case "$1" in
|
||||
button/power)
|
||||
#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)
|
||||
|
@ -47,11 +43,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
|
||||
|
@ -75,16 +71,24 @@ 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
|
||||
;;
|
||||
video/brightnessdown)
|
||||
step_backlight -
|
||||
;;
|
||||
video/brightnessup)
|
||||
step_backlight +
|
||||
;;
|
||||
*)
|
||||
logger "ACPI group/action undefined: $1 / $2"
|
||||
;;
|
||||
|
|
|
@ -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>"
|
||||
|
|
Loading…
Reference in a new issue