mirror of
https://github.com/void-linux/void-packages.git
synced 2025-06-07 07:33:48 +02:00
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
|
# NOTE: This is a 2.6-centric script. If you use 2.4.x, you'll have to
|
||||||
# modify it to not use /sys
|
# modify it to not use /sys
|
||||||
|
|
||||||
minspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq`
|
# $1 should be + or - to step up or down the brightness.
|
||||||
maxspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`
|
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"
|
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
|
case "$1" in
|
||||||
button/power)
|
button/power)
|
||||||
#echo "PowerButton pressed!">/dev/tty5
|
|
||||||
case "$2" in
|
case "$2" in
|
||||||
PBTN|PWRF)
|
PBTN|PWRF)
|
||||||
logger "PowerButton pressed: $2, shutting down..."
|
logger "PowerButton pressed: $2, shutting down..."
|
||||||
shutdown -P now
|
shutdown -P now
|
||||||
;;
|
;;
|
||||||
*) logger "ACPI action undefined: $2" ;;
|
*) logger "ACPI action undefined: $2" ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
button/sleep)
|
button/sleep)
|
||||||
case "$2" in
|
case "$2" in
|
||||||
SBTN|SLPB)
|
SBTN|SLPB)
|
||||||
# suspend-to-ram
|
# suspend-to-ram
|
||||||
logger "Sleep Button pressed: $2, suspending..."
|
logger "Sleep Button pressed: $2, suspending..."
|
||||||
zzz
|
zzz
|
||||||
;;
|
;;
|
||||||
*) logger "ACPI action undefined: $2" ;;
|
*) logger "ACPI action undefined: $2" ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
ac_adapter)
|
ac_adapter)
|
||||||
|
@ -47,11 +43,11 @@ case "$1" in
|
||||||
AC|ACAD|ADP0)
|
AC|ACAD|ADP0)
|
||||||
case "$4" in
|
case "$4" in
|
||||||
00000000)
|
00000000)
|
||||||
echo -n $minspeed >$setspeed
|
printf '%s' "$minspeed" >"$setspeed"
|
||||||
#/etc/laptop-mode/laptop-mode start
|
#/etc/laptop-mode/laptop-mode start
|
||||||
;;
|
;;
|
||||||
00000001)
|
00000001)
|
||||||
echo -n $maxspeed >$setspeed
|
printf '%s' "$maxspeed" >"$setspeed"
|
||||||
#/etc/laptop-mode/laptop-mode stop
|
#/etc/laptop-mode/laptop-mode stop
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -75,16 +71,24 @@ case "$1" in
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
button/lid)
|
button/lid)
|
||||||
case "$3" in
|
case "$3" in
|
||||||
close)
|
close)
|
||||||
# suspend-to-ram
|
# suspend-to-ram
|
||||||
logger "LID closed, suspending..."
|
logger "LID closed, suspending..."
|
||||||
zzz
|
zzz
|
||||||
;;
|
;;
|
||||||
open) logger "LID opened" ;;
|
open)
|
||||||
*) logger "ACPI action undefined (LID): $2";;
|
logger "LID opened"
|
||||||
esac
|
;;
|
||||||
;;
|
*) logger "ACPI action undefined (LID): $2";;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
video/brightnessdown)
|
||||||
|
step_backlight -
|
||||||
|
;;
|
||||||
|
video/brightnessup)
|
||||||
|
step_backlight +
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
logger "ACPI group/action undefined: $1 / $2"
|
logger "ACPI group/action undefined: $1 / $2"
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Template file for 'acpid'
|
# Template file for 'acpid'
|
||||||
pkgname=acpid
|
pkgname=acpid
|
||||||
version=2.0.32
|
version=2.0.32
|
||||||
revision=1
|
revision=2
|
||||||
build_style=gnu-configure
|
build_style=gnu-configure
|
||||||
short_desc="The ACPI Daemon (acpid) With Netlink Support"
|
short_desc="The ACPI Daemon (acpid) With Netlink Support"
|
||||||
maintainer="Enno Boland <gottox@voidlinux.org>"
|
maintainer="Enno Boland <gottox@voidlinux.org>"
|
||||||
|
|
Loading…
Add table
Reference in a new issue