View previous topic :: View next topic |
Author |
Message |
The_Document Apprentice
Joined: 03 Feb 2018 Posts: 275
|
Posted: Sat May 26, 2018 8:57 am Post subject: kde powerdevil doesen't run scripts |
|
|
have 2 scripts power corded/on battery scripts witch are nothing more than invoking cpupower to change cpu governor. Power devil DOES execute the scripts because speaker-test is audible after I add it to script. I believe this is a permissions issue but unsure how to solve this. |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Sat May 26, 2018 9:13 am Post subject: |
|
|
The_Document ...
how about showing us the scripts ;)
I stopped using cpupower as mostly what it does I could replicate with the following (perhaps of some use). Also, for a laptop you might want to use 'ondemand', and so avoid having to switch on ac_adapter disconnect/connect.
Code: | #!/bin/sh
# /etc/local.d/cpufreq-<governer>.start
set -e
if [ -d /lib/rc/bin ] ; then
PATH="$PATH:/lib/rc/bin"
export PATH
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 $? |
|
|
Back to top |
|
|
The_Document Apprentice
Joined: 03 Feb 2018 Posts: 275
|
Posted: Sat May 26, 2018 9:17 am Post subject: |
|
|
Its not really a script
for ac
Code: | #!/bin/bash
cpupower frequency-set -g performance |
for battery
Code: | #!/bin/bash
cpupower frequency-set -g powersave |
powersave is like ondemand but better for battery life as it doesn't drain it as much as ondemand. |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Sat May 26, 2018 9:34 am Post subject: |
|
|
The_Document ...
OK, I don't see any issue with those (other than using bash where dash/bosh/busybox would sufice, and be less resource hungry).
Code: | % cat test
#!/bin/busybox sh
echo hello
% chmod u+x test
% ./test
hello |
Anyhow, if you're using acpid you could do the following, and so skip using powerdevil ...
/etc/acpid/default.sh: | case "$group" in
[...]
ac_adapter)
case "$value" in
*0) cpupower -c all frequency-set -g powersave ;;
*1) cpupower -c all frequency-set -g performance ;;
*) log_unhandled $* ;;
esac
;; |
If not, then I don't know what to suggest, I'm unfamiliar with powerdevil.
best ... khay |
|
Back to top |
|
|
|