2022-02-05 14:23:32 +00:00
|
|
|
#!/bin/bash
|
2022-07-30 02:19:47 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
2023-10-23 22:46:49 +00:00
|
|
|
# Copyright (C) 2023-present - The JELOS Project (https://github.com/JustEnoughLinuxOS) (https://github.com/fewtarius)
|
2022-07-30 02:19:47 +00:00
|
|
|
|
2022-03-26 16:15:38 +00:00
|
|
|
. /etc/profile
|
2022-02-05 14:23:32 +00:00
|
|
|
|
2023-04-26 16:16:39 +00:00
|
|
|
if [ -e "/sys/firmware/devicetree/base/model" ]
|
|
|
|
then
|
2023-08-10 10:53:18 +00:00
|
|
|
QUIRK_DEVICE=$(tr -d '\0' </sys/firmware/devicetree/base/model 2>/dev/null)
|
2023-04-26 16:16:39 +00:00
|
|
|
else
|
2023-08-10 10:53:18 +00:00
|
|
|
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)"
|
2023-04-26 16:16:39 +00:00
|
|
|
fi
|
|
|
|
QUIRK_DEVICE="$(echo ${QUIRK_DEVICE} | sed -e "s#[/]#-#g")"
|
|
|
|
|
2023-01-20 02:30:33 +00:00
|
|
|
headphones() {
|
|
|
|
if [ "${DEVICE_FAKE_JACKSENSE}" == "true" ]
|
|
|
|
then
|
|
|
|
log $0 "Headphone sense: ${1}"
|
|
|
|
systemctl ${1} headphones >/dev/null 2>&1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
volumectl() {
|
|
|
|
if [ "${DEVICE_VOLUMECTL}" == "true" ]
|
|
|
|
then
|
|
|
|
log $0 "Volume control: ${1}"
|
|
|
|
systemctl ${1} volume >/dev/null 2>&1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-10-23 20:15:39 +00:00
|
|
|
jslisten() {
|
|
|
|
if [ "$(systemctl is-active jslisten)" = "active" ]
|
|
|
|
then
|
|
|
|
systemctl ${1} jslisten
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-01-20 02:30:33 +00:00
|
|
|
powerstate() {
|
|
|
|
if [ "$(get_setting system.powersave)" = 1 ]
|
|
|
|
then
|
|
|
|
systemctl ${1} powerstate >/dev/null 2>&1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
bluetooth() {
|
|
|
|
if [ "$(get_setting bluetooth.enabled)" == "1" ]
|
|
|
|
then
|
|
|
|
log $0 "Bluetooth: ${1}"
|
|
|
|
systemctl ${1} bluetooth >/dev/null 2>&1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
EXISTS=$(lsmod | grep ${module})
|
|
|
|
if [ $? = 0 ]
|
|
|
|
then
|
|
|
|
echo ${module} >>/tmp/modules.load
|
|
|
|
modprobe -r ${module}
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
start)
|
|
|
|
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
|
|
|
|
modprobe ${module%% *}
|
|
|
|
if [ $? = 0 ]
|
|
|
|
then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
MODCNT=$((${MODCNT} + 1))
|
|
|
|
sleep .5
|
|
|
|
done
|
|
|
|
done
|
|
|
|
rm -f /tmp/modules.load
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2023-04-26 16:16:39 +00:00
|
|
|
quirks() {
|
2023-07-27 01:25:33 +00:00
|
|
|
for QUIRK in /usr/lib/autostart/quirks/platforms/"${HW_DEVICE}"/sleep.d/${1}/* \
|
2023-07-25 21:06:19 +00:00
|
|
|
/usr/lib/autostart/quirks/devices/"${QUIRK_DEVICE}"/sleep.d/${1}/*
|
2023-04-26 16:16:39 +00:00
|
|
|
do
|
|
|
|
"${QUIRK}" >/dev/null 2>&1
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-02-05 14:23:32 +00:00
|
|
|
case $1 in
|
2022-03-26 16:15:38 +00:00
|
|
|
pre)
|
2023-01-20 02:30:33 +00:00
|
|
|
headphones stop
|
|
|
|
volumectl stop
|
2023-10-23 20:15:39 +00:00
|
|
|
jslisten stop
|
2023-01-20 02:30:33 +00:00
|
|
|
bluetooth stop
|
2023-06-28 11:41:10 +00:00
|
|
|
runtime_power_management on
|
|
|
|
wake_events disabled
|
2023-01-20 02:30:33 +00:00
|
|
|
powerstate stop
|
|
|
|
modules stop
|
2023-04-26 16:16:39 +00:00
|
|
|
quirks pre
|
2022-02-05 14:23:32 +00:00
|
|
|
touch /run/.last_sleep_time
|
2022-03-26 16:15:38 +00:00
|
|
|
;;
|
|
|
|
post)
|
2023-02-06 17:16:00 +00:00
|
|
|
ledcontrol
|
2023-01-20 02:30:33 +00:00
|
|
|
modules start
|
|
|
|
powerstate start
|
|
|
|
headphones start
|
|
|
|
volumectl start
|
2023-10-23 20:15:39 +00:00
|
|
|
jslisten start
|
2023-01-20 02:30:33 +00:00
|
|
|
bluetooth start
|
2022-08-28 23:53:29 +00:00
|
|
|
|
2023-02-16 22:40:39 +00:00
|
|
|
if [ "$(get_setting network.enabled)" == "1" ]
|
2022-10-28 22:33:07 +00:00
|
|
|
then
|
2023-01-20 02:30:33 +00:00
|
|
|
log $0 "Connecting WIFI."
|
|
|
|
nohup wifictl enable >/dev/null 2>&1
|
2022-10-28 22:33:07 +00:00
|
|
|
fi
|
2022-10-01 14:03:01 +00:00
|
|
|
|
2022-07-30 02:19:47 +00:00
|
|
|
DEVICE_VOLUME=$(get_setting "audio.volume" 2>/dev/null)
|
2023-01-20 02:30:33 +00:00
|
|
|
log $0 "Restoring volume to ${DEVICE_VOLUME}%."
|
2023-08-16 00:08:48 +00:00
|
|
|
amixer -c 0 -M set "${DEVICE_AUDIO_MIXER}" ${DEVICE_VOLUME}%
|
2022-07-30 02:19:47 +00:00
|
|
|
|
2022-09-25 19:22:56 +00:00
|
|
|
BRIGHTNESS=$(get_setting system.brightness)
|
2023-01-20 02:30:33 +00:00
|
|
|
log $0 "Restoring brightness to ${BRIGHTNESS}."
|
2023-08-05 18:21:23 +00:00
|
|
|
brightness set ${BRIGHTNESS}
|
2023-04-26 16:16:39 +00:00
|
|
|
quirks post
|
2022-03-26 16:15:38 +00:00
|
|
|
;;
|
2022-02-05 14:23:32 +00:00
|
|
|
esac
|