mirror of
https://github.com/archr-linux/Arch-R.git
synced 2026-03-31 14:41:55 -07:00
rocknix: remove X86 power saving options
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
|
||||
# Minimal OS variable loading for performance
|
||||
. /etc/profile.d/001-functions
|
||||
. /etc/profile.d/030-powerfunctions
|
||||
. /etc/profile.d/099-freqfunctions
|
||||
|
||||
tocon "Setting performance mode..."
|
||||
|
||||
@@ -182,13 +182,7 @@ system.battery.warning_threshold=25
|
||||
system.hostname=@DEVICENAME@
|
||||
system.language=en_US
|
||||
system.loglevel=none
|
||||
system.power.audio=1
|
||||
system.merged.storage=0
|
||||
system.power.cpu=1
|
||||
system.power.pcie=0
|
||||
system.power.rtpm=0
|
||||
system.powersave=0
|
||||
system.power.wifi=0
|
||||
system.shutdown_delay=0
|
||||
system.shutdown_delay_running_game=900
|
||||
system.timezone=America/New_York
|
||||
|
||||
@@ -119,3 +119,21 @@ powersave() {
|
||||
set_cpu_gov powersave
|
||||
set_dmc_gov powersave
|
||||
}
|
||||
|
||||
get_gpu_performance_level() {
|
||||
get_setting system.gpuperf
|
||||
}
|
||||
|
||||
gpu_performance_level() {
|
||||
case ${1} in
|
||||
profile_peak)
|
||||
set_gpu_gov performance
|
||||
;;
|
||||
auto|profile_standard)
|
||||
set_gpu_gov ondemand
|
||||
;;
|
||||
low)
|
||||
set_gpu_gov powersave
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
|
||||
|
||||
. /etc/profile
|
||||
|
||||
if [ ! "${HW_ARCH}" = "x86_64" ]
|
||||
then
|
||||
echo "This platform is not currently supported."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
HOSTNAME=$(hostname)
|
||||
|
||||
if [ -z "${1}" ]
|
||||
then
|
||||
BENCHLOG="${1}"
|
||||
else
|
||||
BENCHLOG="benchmark.log"
|
||||
fi
|
||||
|
||||
LOG="${HOME}/${BENCHLOG}.log"
|
||||
|
||||
SYSTEM_TDP=$(get_setting system.overclock)
|
||||
SYSTEM_GOV=$(get_setting system.cpugovernor)
|
||||
SYSTEM_EPP=$(get_setting system.power.epp)
|
||||
SYSTEM_GPU=$(get_setting system.gpuperf)
|
||||
SYSTEM_THREADS=$(get_setting system.threads)
|
||||
SYSTEM_POWERSAVE=$(get_setting system.powersave)
|
||||
SYSTEM_COOLING=$(get_setting cooling.profile)
|
||||
|
||||
case ${1} in
|
||||
performance)
|
||||
onlinethreads all
|
||||
performance
|
||||
gpu_performance_level profile_peak
|
||||
cpu_perftune performance
|
||||
set_setting system.powersave 0
|
||||
systemctl restart powerstate
|
||||
set_setting cooling.profile auto
|
||||
systemctl restart fancontrol
|
||||
;;
|
||||
balanced_performance)
|
||||
onlinethreads all
|
||||
schedutil
|
||||
gpu_performance_level auto
|
||||
cpu_perftune balance_performance
|
||||
set_setting system.powersave 0
|
||||
systemctl restart powerstate
|
||||
set_setting cooling.profile auto
|
||||
systemctl restart fancontrol
|
||||
;;
|
||||
balanced_powersave)
|
||||
onlinethreads 4
|
||||
powersave
|
||||
gpu_performance_level low
|
||||
cpu_perftune balance_power
|
||||
set_setting system.powersave 1
|
||||
systemctl restart powerstate
|
||||
set_setting cooling.profile quiet
|
||||
systemctl restart fancontrol
|
||||
;;
|
||||
powersave)
|
||||
onlinethreads 4
|
||||
powersave
|
||||
gpu_performance_level low
|
||||
cpu_perftune power
|
||||
set_setting system.powersave 1
|
||||
systemctl restart powerstate
|
||||
set_setting cooling.profile quiet
|
||||
systemctl restart fancontrol
|
||||
;;
|
||||
*)
|
||||
# Default Settings
|
||||
onlinethreads all
|
||||
schedutil
|
||||
gpu_performance_level auto
|
||||
cpu_perftune balance_performance
|
||||
set_setting system.powersave 0
|
||||
systemctl restart powerstate
|
||||
set_setting cooling.profile auto
|
||||
systemctl restart fancontrol
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -e "${LOG}" ]
|
||||
then
|
||||
rm -f ${LOG}
|
||||
fi
|
||||
|
||||
echo "${HOSTNAME} - ${1}"
|
||||
|
||||
for TDP in 4.5w 6w 9w 15w 18w 24w 28w
|
||||
do
|
||||
overclock ${TDP} >/dev/null 2>&1
|
||||
echo "Testing @ ${TDP}" 2>&1 | tee -a ${LOG}
|
||||
echo "----" 2>&1 | tee -a ${LOG}
|
||||
glmark2-es2-wayland --fullscreen --annotate 2>&1 | awk '/glmark2 Score:/ {print "GLMark: "$3}' | tee -a ${LOG}
|
||||
cd /usr/bin
|
||||
./7z b 2>&1 | awk '/^Tot:/ {print "7z: "$4}' | tee -a ${LOG}
|
||||
echo "----" 2>&1 | tee -a ${LOG}
|
||||
done
|
||||
|
||||
overclock ${SYSTEM_TDP}
|
||||
onlinethreads ${SYSTEM_THREADS}
|
||||
${SYSTEM_GOV}
|
||||
gpu_performance_level ${SYSTEM_GPU}
|
||||
cpu_perftune ${SYSTEM_EPP}
|
||||
set_setting system.powersave ${SYSTEM_POWERSAVE}
|
||||
systemctl restart powerstate
|
||||
set_setting cooling.profile ${SYSTEM_COOLING}
|
||||
systemctl restart fancontrol
|
||||
@@ -320,31 +320,6 @@ esac
|
||||
### We need the original system cooling profile later so get it now!
|
||||
COOLINGPROFILE=$(get_setting cooling.profile)
|
||||
|
||||
### Set CPU TDP and EPP
|
||||
CPU_VENDOR=$(cpu_vendor)
|
||||
case ${CPU_VENDOR} in
|
||||
AuthenticAMD)
|
||||
### Set the overclock mode
|
||||
OVERCLOCK=$(get_setting "overclock" "${PLATFORM}" "${ROMNAME##*/}")
|
||||
if [ ! -z "${OVERCLOCK}" ]
|
||||
then
|
||||
${VERBOSE} && log $0 "Set TDP to (${OVERCLOCK})"
|
||||
/usr/bin/overclock ${OVERCLOCK}
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
### Apply energy performance preference
|
||||
if [ -e "/usr/bin/set_epp" ]
|
||||
then
|
||||
EPP=$(get_setting "power.epp" "${PLATFORM}" "${ROMNAME##*/}")
|
||||
if [ ! -z ${EPP} ]
|
||||
then
|
||||
${VERBOSE} && log $0 "Set EPP to (${EPP})"
|
||||
/usr/bin/set_epp ${EPP}
|
||||
fi
|
||||
fi
|
||||
|
||||
### Configure GPU performance mode
|
||||
GPUPERF=$(get_setting "gpuperf" "${PLATFORM}" "${ROMNAME##*/}")
|
||||
if [ ! -z ${GPUPERF} ]
|
||||
@@ -452,22 +427,6 @@ else
|
||||
fi
|
||||
rm -f /tmp/.gpu_performance_level 2>/dev/null
|
||||
|
||||
### Restore system EPP
|
||||
EPP=$(get_setting "system.power.epp")
|
||||
if [ ! -z ${EPP} ]
|
||||
then
|
||||
${VERBOSE} && log $0 "Restore system EPP (${EPP})"
|
||||
/usr/bin/set_epp ${EPP} &
|
||||
fi
|
||||
|
||||
### Restore system TDP
|
||||
OVERCLOCK=$(get_setting "system.overclock")
|
||||
if [ ! -z "${OVERCLOCK}" ]
|
||||
then
|
||||
${VERBOSE} && log $0 "Restore system TDP (${OVERCLOCK})"
|
||||
/usr/bin/overclock ${OVERCLOCK} &
|
||||
fi
|
||||
|
||||
### Reset the number of cores to use.
|
||||
NUMTHREADS=$(get_setting "system.threads")
|
||||
${VERBOSE} && log $0 "Restore active threads (${NUMTHREADS})"
|
||||
|
||||
@@ -64,25 +64,12 @@ list_wifi() {
|
||||
/usr/bin/iwd_get-networks
|
||||
}
|
||||
|
||||
set_powersave() {
|
||||
ENABLED=$(get_setting system.power.wifi)
|
||||
if [ "${ENABLED}" = "1" ]; then
|
||||
log $0 "Enabling WIFI power saving."
|
||||
iw ${WIFI_DEV} set power_save on 2>/dev/null
|
||||
else
|
||||
log $0 "Disabling WIFI power saving."
|
||||
iw ${WIFI_DEV} set power_save off 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
connect_wifi() {
|
||||
wait_for_wifi
|
||||
|
||||
iwctl device ${WIFI_DEV} set-property Mode station
|
||||
# Connect to the network.
|
||||
iwctl --passphrase "${PSK}" station ${WIFI_DEV} connect "${SSID}" 2>/dev/null
|
||||
|
||||
set_powersave 2>/dev/null
|
||||
}
|
||||
|
||||
create_adhoc() {
|
||||
@@ -165,7 +152,4 @@ case "${1}" in
|
||||
iwctl station ${WIFI_DEV} scan 2>/dev/null
|
||||
list_wifi
|
||||
;;
|
||||
setpowersave)
|
||||
set_powersave
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -1,192 +0,0 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
|
||||
|
||||
get_gpu_power_profile() {
|
||||
cat /sys/class/drm/card0/device/power_dpm_state 2>/dev/null
|
||||
}
|
||||
|
||||
gpu_power_profile() {
|
||||
for card in /sys/class/drm/card*/device/power_dpm_state
|
||||
do
|
||||
if [ -e "${card}" ]
|
||||
then
|
||||
echo ${1} >${card} 2>/dev/null
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
get_gpu_performance_level() {
|
||||
case ${HW_ARCH} in
|
||||
x86_64)
|
||||
cat /sys/class/drm/card0/device/power_dpm_force_performance_level 2>/dev/null
|
||||
;;
|
||||
aarch64)
|
||||
get_setting system.gpuperf
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
gpu_performance_level() {
|
||||
case ${HW_ARCH} in
|
||||
x86_64)
|
||||
for card in /sys/class/drm/card*/device/power_dpm_force_performance_level
|
||||
do
|
||||
if [ -e "${card}" ]
|
||||
then
|
||||
echo ${1} >${card} 2>/dev/null
|
||||
fi
|
||||
done
|
||||
;;
|
||||
aarch64)
|
||||
case ${1} in
|
||||
profile_peak)
|
||||
set_gpu_gov performance
|
||||
;;
|
||||
auto|profile_standard)
|
||||
set_gpu_gov ondemand
|
||||
;;
|
||||
low)
|
||||
set_gpu_gov powersave
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
pcie_aspm_policy() {
|
||||
PCIEPOWERSAVE=$(get_setting system.power.pcie)
|
||||
POWERSAVEENABLED=$(get_setting system.powersave)
|
||||
if [ "${PCIEPOWERSAVE}" = "1" ] &&
|
||||
[ "${POWERSAVEENABLED}" = "1" ]
|
||||
then
|
||||
if [ -e "/sys/module/pcie_aspm/parameters/policy" ]
|
||||
then
|
||||
echo ${1} >/sys/module/pcie_aspm/parameters/policy 2>/dev/null
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
cpu_perftune() {
|
||||
if [ -n "${1}" ]
|
||||
then
|
||||
DESIRED_EPP=${1}
|
||||
fi
|
||||
CPUPOWERSAVE=$(get_setting system.power.cpu)
|
||||
POWERSAVEENABLED=$(get_setting system.powersave)
|
||||
CPU="$(awk '/vendor_id/ {print $3;exit}' /proc/cpuinfo)"
|
||||
|
||||
if [ "${CPUPOWERSAVE}" = "1" ] && \
|
||||
[ "${POWERSAVEENABLED}" = "1" ]
|
||||
then
|
||||
case ${CPU} in
|
||||
AuthenticAMD)
|
||||
if [ "${1}" = "battery" ]
|
||||
then
|
||||
ryzenadj --power-saving >/dev/null 2>&1
|
||||
else
|
||||
ryzenadj --max-performance >/dev/null 2>&1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case ${CPU} in
|
||||
AuthenticAMD)
|
||||
PSTATE="amd_pstate"
|
||||
STATUS="active"
|
||||
WARM="passive"
|
||||
;;
|
||||
GenuineIntel)
|
||||
PSTATE="intel_pstate"
|
||||
STATUS="passive"
|
||||
WARM="active"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -f "/sys/devices/system/cpu/${PSTATE}/status" ]
|
||||
then
|
||||
if [ -n "${WARM}" ]
|
||||
then
|
||||
# Some devices need to switch before the handles are writeable (AYANEO).
|
||||
echo ${WARM} >/sys/devices/system/cpu/${PSTATE}/status
|
||||
fi
|
||||
echo ${STATUS} >/sys/devices/system/cpu/${PSTATE}/status
|
||||
while [ ! -f /sys/devices/system/cpu/cpufreq/policy0/energy_performance_preference ]
|
||||
do
|
||||
sleep .25
|
||||
done
|
||||
for policy in $(find /sys/devices/system/cpu/cpufreq/policy*/ -name energy_performance_preference)
|
||||
do
|
||||
EPP=$(get_setting system.power.epp)
|
||||
if [ -z "${EPP}" ]
|
||||
then
|
||||
EPP="balance_performance"
|
||||
set_setting system.power.epp ${EPP}
|
||||
fi
|
||||
if [ -n "${DESIRED_EPP}" ]
|
||||
then
|
||||
EPP="${DESIRED_EPP}"
|
||||
fi
|
||||
echo ${EPP} >${policy} 2>/dev/null
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
audio_powersave() {
|
||||
POWERSAVEENABLED=$(get_setting system.powersave)
|
||||
AUDIOPOWERSAVE=$(get_setting system.power.audio)
|
||||
if [ "${AUDIOPOWERSAVE}" = "1" ] &&
|
||||
[ "${POWERSAVEENABLED}" = "1" ]
|
||||
then
|
||||
for MODULE in snd_hda_intel snd_ac97_codec
|
||||
do
|
||||
if [ -e "/sys/module/${MODULE}/parameters/power_save" ]
|
||||
then
|
||||
echo ${1} >/sys/module/${MODULE}/parameters/power_save 2>/dev/null
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
runtime_power_management() {
|
||||
POWERSAVEENABLED=$(get_setting system.powersave)
|
||||
RTPM=$(get_setting system.power.rtpm)
|
||||
if [ "${RTPM}" = "1" ] &&
|
||||
[ "${POWERSAVEENABLED}" = "1" ]
|
||||
then
|
||||
find /sys/devices/{platform,pci*} -type f -name control -print0 2>/dev/null | \
|
||||
while read -r -d '' DEVICE
|
||||
do
|
||||
echo ${1} >"${DEVICE}" 2>/dev/null
|
||||
echo ${2} >"${DEVICE/control/autosuspend_delay_ms}" 2>/dev/null
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
scsi_link_power_management() {
|
||||
POWERSAVEENABLED=$(get_setting system.powersave)
|
||||
RTPM=$(get_setting system.power.rtpm)
|
||||
if [ "${RTPM}" = "1" ] &&
|
||||
[ "${POWERSAVEENABLED}" = "1" ]
|
||||
then
|
||||
find /sys/class/scsi_host/host*/ -type f -name link_power_management_policy -print0 2>/dev/null | \
|
||||
while read -r -d '' DEVICE
|
||||
do
|
||||
echo "${1}" >"${DEVICE}" 2>/dev/null
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
wake_events() {
|
||||
POWERSAVEENABLED=$(get_setting system.powersave)
|
||||
WAKEEVENTS=$(get_setting system.power.wakeevents)
|
||||
if [ "${WAKEEVENTS}" = "1" ] && \
|
||||
[ "${POWERSAVEENABLED}" = "1" ]
|
||||
then
|
||||
for device in $(find /sys/devices/{platform,pci*} -type f -name wakeup 2>/dev/null)
|
||||
do
|
||||
echo ${1} >${device} 2>/dev/null
|
||||
done
|
||||
fi
|
||||
}
|
||||
@@ -15,53 +15,29 @@ unset CURRENT_MODE
|
||||
unset AC_STATUS
|
||||
ledcontrol $(get_setting led.color)
|
||||
|
||||
while true
|
||||
do
|
||||
while true; do
|
||||
AC_STATUS="$(cat /sys/class/power_supply/[bB][aA][tT]*/status 2>/dev/null)"
|
||||
if [[ ! "${CURRENT_MODE}" =~ ${AC_STATUS} ]]
|
||||
then
|
||||
if [[ ! "${CURRENT_MODE}" =~ ${AC_STATUS} ]]; then
|
||||
case ${AC_STATUS} in
|
||||
Disch*)
|
||||
if [ "$(get_setting system.powersave)" = 1 ]
|
||||
then
|
||||
log $0 "Switching to battery mode."
|
||||
if [ -e "/tmp/.gpu_performance_level" ]
|
||||
then
|
||||
GPUPROFILE=$(cat /tmp/.gpu_performance_level)
|
||||
else
|
||||
GPUPROFILE=$(get_setting system.gpuperf)
|
||||
fi
|
||||
if [ -z "${GPUPROFILE}" ]
|
||||
then
|
||||
GPUPROFILE="auto"
|
||||
fi
|
||||
audio_powersave 1
|
||||
cpu_perftune battery
|
||||
gpu_performance_level ${GPUPROFILE}
|
||||
pcie_aspm_policy powersave
|
||||
wake_events enabled
|
||||
runtime_power_management auto 5
|
||||
scsi_link_power_management med_power_with_dipm
|
||||
log $0 "Switching to battery mode."
|
||||
if [ -e "/tmp/.gpu_performance_level" ]; then
|
||||
GPUPROFILE=$(cat /tmp/.gpu_performance_level)
|
||||
else
|
||||
GPUPROFILE=$(get_setting system.gpuperf)
|
||||
fi
|
||||
if [ "${DEVICE_LED_CHARGING}" = "true" ]
|
||||
then
|
||||
if [ -z "${GPUPROFILE}" ]; then
|
||||
GPUPROFILE="auto"
|
||||
fi
|
||||
gpu_performance_level ${GPUPROFILE}
|
||||
if [ "${DEVICE_LED_CHARGING}" = "true" ]; then
|
||||
ledcontrol discharging
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if [ "$(get_setting system.powersave)" = 1 ]
|
||||
then
|
||||
log $0 "Switching to performance mode."
|
||||
audio_powersave 0
|
||||
cpu_perftune performance
|
||||
gpu_performance_level auto
|
||||
pcie_aspm_policy default
|
||||
wake_events disabled
|
||||
runtime_power_management on 0
|
||||
scsi_link_power_management ""
|
||||
fi
|
||||
if [ "${DEVICE_LED_CHARGING}" = "true" ]
|
||||
then
|
||||
log $0 "Switching to performance mode."
|
||||
gpu_performance_level auto
|
||||
if [ "${DEVICE_LED_CHARGING}" = "true" ]; then
|
||||
ledcontrol charging
|
||||
fi
|
||||
;;
|
||||
@@ -71,30 +47,23 @@ do
|
||||
fi
|
||||
### Until we have an overlay. :rofl:
|
||||
BATLEFT=$(battery_percent)
|
||||
if (( "${BATCNT}" >= "20" )) &&
|
||||
[[ "${AC_STATUS}" =~ Disch ]]
|
||||
then
|
||||
if (( "${BATCNT}" >= "20" )) && [[ "${AC_STATUS}" =~ Disch ]]; then
|
||||
AUDIBLEALERT=$(get_setting system.battery.warning)
|
||||
AUDIBLEALERT_THRESHOLD=$(get_setting system.battery.warning_threshold)
|
||||
[[ -z $AUDIBLEALERT_THRESHOLD ]] && AUDIBLEALERT_THRESHOLD=25
|
||||
|
||||
if [[ ${BATLEFT} -le ${AUDIBLEALERT_THRESHOLD} ]]
|
||||
then
|
||||
if [ "${DEVICE_LED_CONTROL}" = "true" ] && [ ! "${DEVICE_BATTERY_LED_STATUS}" = "true" ]
|
||||
then
|
||||
if [[ ${BATLEFT} -le ${AUDIBLEALERT_THRESHOLD} ]]; then
|
||||
if [ "${DEVICE_LED_CONTROL}" = "true" ] && [ ! "${DEVICE_BATTERY_LED_STATUS}" = "true" ]; then
|
||||
# Flash the RGB or power LED if available.
|
||||
led_flash
|
||||
BATCNT=0
|
||||
elif [ "${AUDIBLEALERT}" = "1" ]
|
||||
then
|
||||
elif [ "${AUDIBLEALERT}" = "1" ]; then
|
||||
say "BATTERY AT ${BATLEFT}%"
|
||||
BATCNT=0
|
||||
fi
|
||||
fi
|
||||
elif (( "${BATLEFT}" > "97" ))
|
||||
then
|
||||
if [ "${DEVICE_LED_CHARGING}" = "true" ]
|
||||
then
|
||||
elif (( "${BATLEFT}" > "97" )); then
|
||||
if [ "${DEVICE_LED_CHARGING}" = "true" ]; then
|
||||
# Reset the LED as if the battery was full.
|
||||
ledcontrol discharging
|
||||
fi
|
||||
|
||||
@@ -4,39 +4,32 @@
|
||||
|
||||
. /etc/profile
|
||||
|
||||
if [ -e "/sys/firmware/devicetree/base/model" ]
|
||||
then
|
||||
if [ -e "/sys/firmware/devicetree/base/model" ]; then
|
||||
QUIRK_DEVICE=$(tr -d '\0' </sys/firmware/devicetree/base/model 2>/dev/null)
|
||||
else
|
||||
QUIRK_DEVICE="$(tr -d '\0' </sys/class/dmi/id/sys_vendor 2>/dev/null) $(tr -d '\0' </sys/class/dmi/id/product_name 2>/dev/null)"
|
||||
fi
|
||||
QUIRK_DEVICE="$(echo ${QUIRK_DEVICE} | sed -e "s#[/]#-#g")"
|
||||
|
||||
EVENTLOG="/var/log/sleep.log"
|
||||
|
||||
headphones() {
|
||||
if [ "${DEVICE_FAKE_JACKSENSE}" == "true" ]
|
||||
then
|
||||
if [ "${DEVICE_FAKE_JACKSENSE}" == "true" ]; then
|
||||
log $0 "Headphone sense: ${1}"
|
||||
systemctl ${1} headphones >${EVENTLOG} 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
inputsense() {
|
||||
log $0 "Input sense: ${1}"
|
||||
systemctl ${1} input >${EVENTLOG} 2>&1
|
||||
log $0 "Input sense: ${1}"
|
||||
systemctl ${1} input >${EVENTLOG} 2>&1
|
||||
}
|
||||
|
||||
powerstate() {
|
||||
if [ "$(get_setting system.powersave)" = 1 ]
|
||||
then
|
||||
systemctl ${1} powerstate >${EVENTLOG} 2>&1
|
||||
fi
|
||||
log $0 "Power state: ${1}"
|
||||
systemctl ${1} powerstate >${EVENTLOG} 2>&1
|
||||
}
|
||||
|
||||
bluetooth() {
|
||||
if [ "$(get_setting controllers.bluetooth.enabled)" == "1" ]
|
||||
then
|
||||
if [ "$(get_setting controllers.bluetooth.enabled)" == "1" ]; then
|
||||
log $0 "Bluetooth: ${1}"
|
||||
systemctl ${1} bluetooth >${EVENTLOG} 2>&1
|
||||
fi
|
||||
@@ -46,33 +39,25 @@ modules() {
|
||||
log $0 "Modules: ${1}"
|
||||
case ${1} in
|
||||
stop)
|
||||
if [ -e "/usr/config/modules.bad" ]
|
||||
then
|
||||
for module in $(cat /usr/config/modules.bad)
|
||||
do
|
||||
if [ -e "/usr/config/modules.bad" ]; then
|
||||
for module in $(cat /usr/config/modules.bad); do
|
||||
EXISTS=$(lsmod | grep ${module})
|
||||
if [ $? = 0 ]
|
||||
then
|
||||
if [ $? = 0 ]; then
|
||||
echo ${module} >>/tmp/modules.load
|
||||
modprobe -r ${module} >${EVENTLOG} 2>&1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
;;
|
||||
;;
|
||||
start)
|
||||
if [ -e "/tmp/modules.load" ]
|
||||
then
|
||||
for module in $(cat /tmp/modules.load)
|
||||
do
|
||||
if [ -e "/tmp/modules.load" ]; then
|
||||
for module in $(cat /tmp/modules.load); do
|
||||
MODCNT=0
|
||||
MODATTEMPTS=10
|
||||
while true
|
||||
do
|
||||
if (( "${MODCNT}" < "${MODATTEMPTS}" ))
|
||||
then
|
||||
while true; do
|
||||
if (( "${MODCNT}" < "${MODATTEMPTS}" )); then
|
||||
modprobe ${module%% *} >${EVENTLOG} 2>&1
|
||||
if [ $? = 0 ]
|
||||
then
|
||||
if [ $? = 0 ]; then
|
||||
break
|
||||
fi
|
||||
else
|
||||
@@ -84,14 +69,13 @@ modules() {
|
||||
done
|
||||
rm -f /tmp/modules.load
|
||||
fi
|
||||
;;
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
quirks() {
|
||||
for QUIRK in /usr/lib/autostart/quirks/platforms/"${HW_DEVICE}"/sleep.d/${1}/* \
|
||||
/usr/lib/autostart/quirks/devices/"${QUIRK_DEVICE}"/sleep.d/${1}/*
|
||||
do
|
||||
/usr/lib/autostart/quirks/devices/"${QUIRK_DEVICE}"/sleep.d/${1}/*; do
|
||||
"${QUIRK}" >${EVENTLOG} 2>&1
|
||||
done
|
||||
}
|
||||
@@ -101,13 +85,11 @@ case $1 in
|
||||
headphones stop
|
||||
inputsense stop
|
||||
bluetooth stop
|
||||
runtime_power_management on
|
||||
wake_events disabled
|
||||
powerstate stop
|
||||
modules stop
|
||||
modules stop
|
||||
quirks pre
|
||||
touch /run/.last_sleep_time
|
||||
;;
|
||||
;;
|
||||
post)
|
||||
ledcontrol
|
||||
modules start
|
||||
@@ -116,8 +98,7 @@ case $1 in
|
||||
inputsense start
|
||||
bluetooth start
|
||||
|
||||
if [ "$(get_setting wifi.enabled)" == "1" ]
|
||||
then
|
||||
if [ "$(get_setting wifi.enabled)" == "1" ]; then
|
||||
log $0 "Connecting WIFI."
|
||||
nohup wifictl enable >${EVENTLOG} 2>&1
|
||||
fi
|
||||
@@ -130,5 +111,5 @@ case $1 in
|
||||
log $0 "Restoring brightness to ${BRIGHTNESS}."
|
||||
brightness set ${BRIGHTNESS} >${EVENTLOG} 2>&1
|
||||
quirks post
|
||||
;;
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user