View previous topic :: View next topic |
Author |
Message |
ONEEYEMAN Advocate
Joined: 01 Mar 2005 Posts: 3610
|
Posted: Fri Oct 19, 2018 3:12 am Post subject: ACPID configuration |
|
|
Hi, ALL,
On the page there is an example on how one can configure the acpid.
However, I think that the configuration file is incomplete as there is no code for power.bat and all other additional files being used.
Does anybody have a guide on how to set up the acpid?
Thank you. |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Fri Oct 19, 2018 2:51 pm Post subject: Re: ACPID configuration |
|
|
ONEEYEMAN wrote: | On the page there is an example on how one can configure the acpid. However, I think that the configuration file is incomplete as there is no code for power.bat and all other additional files being used. |
ONEEYEMAN ... well, yes, it's an example, and so fine tuning is left as an excercise for the reader/user. Not every machine/install is the same, so there is no one size fits all solution.
So, for example, that /etc/acpid/default.sh is using sys-apps/hprofile (which, incidentally, provides the 'power.bat' profile) but you needn't (and I don't ... as I've written my own scripts for such things).
ONEEYEMAN wrote: | Does anybody have a guide on how to set up the acpid? |
'default.sh' is just a shell script that is run on every 'event' (as /etc/acpid/events/default calls it). As it's shell you can have it run a command based on what 'acpid-listen' recieves, those parameters are passed to the script, which then checks if 'group=button', and 'action=power' (for example) and runs whatever that 'case' is set to run. Once you understand that it's not to difficult to have it do whatever you need it to do ... that's all there is to it.
Having said that perhaps what you're looking for is further examples ... and so:
/etc/acpid/default.sh: | #!/bin/sh
# /etc/acpi/default.sh
# Default acpi script that takes an entry for all actions
set $*
group=${1%%/*}
action=${1#*/}
device=$2
id=$3
value=$4
log_unhandled() {
logger "ACPI event unhandled: $*"
}
case "$group" in
button)
case "$action" in
power) /etc/acpi/actions/powerbtn.sh ;;
mute) /usr/bin/amixer -q set Master toggle ;;
volumeup) /usr/bin/amixer -q set Master 2dB+ unmute ;;
volumedown) /usr/bin/amixer -q set Master 2dB- unmute ;;
switchmode) /etc/acpi/actions/xrandr.sh ;;
lid)
case "$id" in
close) /etc/acpi/actions/hibernate.sh ;;
*) log_unhandled $* ;;
esac ;;
*) log_unhandled $* ;;
esac ;;
video)
case "$action" in
brightnessup) /etc/acpi/actions/backlight.sh up ;;
brightnessdown) /etc/acpi/actions/backlight.sh down ;;
*) log_unhandled $* ;;
esac ;;
ac_adapter)
case "$value" in
*0) /etc/acpid/actions/cpufreq.sh powersave ;;
*1) /etc/acpid/actions/cpufreq.sh ondemand ;;
*) log_unhandled $* ;;
esac
;;
*) log_unhandled $* ;;
esac
# vim:fenc=utf-8:ft=sh:ci:pi:sts=0: |
/etc/acpi/actions/hibernate.sh: | #!/bin/sh
set -e
xpid="$(pgrep -n X)"
xuser="$(ps -o user --no-headers $xpid)"
display="$(egrep -aoz ':[0-9](.[0-9])?' /proc/$xpid/cmdline)"
export XAUTHORITY="/home/$xuser/.Xauthority"
export DISPLAY="$display"
/usr/sbin/hibernate |
/etc/acpid/actions/backlight.sh: | #!/bin/sh
set -e
backlight_sys_dir="/sys/class/backlight/intel_backlight"
read -r max_brightness < "${backlight_sys_dir}/max_brightness"
read -r curr_brightness < "${backlight_sys_dir}/brightness"
case "$1" in
up) increment="+ 10" ;;
down) increment="- 10" ;;
*) exit 1 ;;
esac
new_brightness=$(($curr_brightness $increment))
#if $((new_brightness < 1)) || $((new_brightness > $max_brightness)); then
if [ $new_brightness -lt 1 ] || [ $new_brightness -gt $max_brightness ]; then
exit 1
else
echo "$new_brightness" > ${backlight_sys_dir}/brightness
fi |
/etc/acpi/actions/xrandr.sh: | #!/bin/sh
set -e
if [ -n $(xrandr -q | grep '^VGA connected' >/dev/null) ] ; then
# "VGA connected"
xrandr --output VGA --above LVDS --auto
xrandr --output LVDS --auto
else
# "VGA not connected"
xrandr --auto
fi |
/etc/acpi/actions/cpufreq.sh: | #!/bin/sh
set -e
if [ -t 1 ] && [ -d /lib/rc/bin ] ; then
PATH="$PATH:/lib/rc/bin"
else
alias ebegin="echo"
alias eerror="echo"
alias eend="return"
fi
sys_path="/sys/devices/system/cpu"
freq_gvnrs="${sys_path}/cpu0/cpufreq/scaling_available_governors"
cores="$(getconf _NPROCESSORS_ONLN)"
if [ -n "$1" ] ; then
governer="$1"
else
filename="$(basename -- $0 .${0##*.})"
governer="${filename#*-}"
fi
ebegin "Setting cpufreq scaling governer to $governer"
[ "$cores" -gt 0 ] || exit 1
# in case the required governer happens to be a built as a module.
modprobe -q cpufreq_"$governer" || exit $?
if [ -e "$freq_gvnrs" ] && (grep -q "$governer" "$freq_gvnrs") ; then
i=0
while [ "$i" -lt "$cores" ] ; do
echo "$governer" > "${sys_path}/cpu${i}/cpufreq/scaling_governor"
i=$((i + 1))
done
unset i
# for information on tuneables see:
# https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt
case "$governer" in
ondemand)
echo 45 > "${sys_path}/cpufreq/ondemand/up_threshold"
echo 10 > "${sys_path}/cpufreq/ondemand/sampling_down_factor"
echo 1 > "${sys_path}/cpufreq/ondemand/ignore_nice_load"
echo 1 > "${sys_path}/cpufreq/ondemand/io_is_busy"
;;
conservative)
echo 45 > "${sys_path}/cpufreq/conservative/up_threshold"
echo 20 > "${sys_path}/cpufreq/conservative/down_threshold"
echo 10 > "${sys_path}/cpufreq/conservative/sampling_down_factor"
echo 1 > "${sys_path}/cpufreq/conservative/ignore_nice_load"
echo 10 > "${sys_path}/cpufreq/conservative/freq_step"
;;
performance)
# performace should offer two tuneables (not set):
true
;;
powersave)
# powersave should offer two tuneables (not set):
true
;;
userspace)
# userspace tuneables (not set):
true
;;
esac
else
eerror "cpufreq governer $governer is not available" && return 1
fi
eend $?
# vim:ft=sh:ts=4:sw=4:noexpandtab |
HTH & best ... khay |
|
Back to top |
|
|
ONEEYEMAN Advocate
Joined: 01 Mar 2005 Posts: 3610
|
Posted: Sat Oct 20, 2018 3:06 am Post subject: |
|
|
khay,
One question:
In the backlight.sh script backlight_sys_dir is referenced. I don't have this directory.
Is it OK?
Also my laptop is AMD based with the "radeon" card.
In that directory I have 2 symlinks: radeon_bl0 and acpi_video0. I used the first one.
Thank you for the example scripts. |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Sat Oct 20, 2018 10:29 am Post subject: |
|
|
ONEEYEMAN wrote: | In the backlight.sh script backlight_sys_dir is referenced. I don't have this directory. Is it OK? Also my laptop is AMD based with the "radeon" card. |
ONEEYEMAN ... that is specific to "intel_backlight" (so, intel graphics chipset). If you have radeon look for a similar directory, and adjust the script to reflect the path/files.
ONEEYEMAN wrote: | In that directory I have 2 symlinks: radeon_bl0 and acpi_video0. I used the first one. |
Look to see that one or other contains 'brightness' and 'max_brightness' (or similarly named files). You may need to modify the script to match whatever file names radeon uses.
best ... khay |
|
Back to top |
|
|
ONEEYEMAN Advocate
Joined: 01 Mar 2005 Posts: 3610
|
Posted: Sat Oct 20, 2018 4:51 pm Post subject: |
|
|
khay,
They both do. And so I picked the first one.
Do you have multiple in you dir structure?
Thank you. |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Sat Oct 20, 2018 5:35 pm Post subject: |
|
|
ONEEYEMAN wrote: | Do you have multiple in you dir structure? |
ONEEYEMAN ... no, that may be because I have 'video.use_native_backlight=1' as a kernel parameter.
best ... khay |
|
Back to top |
|
|
|