2022-02-05 14:23:32 +00:00
|
|
|
#!/bin/bash
|
2022-07-30 02:19:47 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
|
|
|
|
|
2022-03-26 16:15:38 +00:00
|
|
|
. /etc/profile
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
case $1 in
|
2022-03-26 16:15:38 +00:00
|
|
|
pre)
|
2022-07-30 02:19:47 +00:00
|
|
|
|
|
|
|
if [ "${DEVICE_FAKE_JACKSENSE}" == "true" ]
|
|
|
|
then
|
2022-09-29 20:44:45 +00:00
|
|
|
nohup systemctl stop headphones & >/dev/null 2>&1
|
2022-07-30 02:19:47 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${DEVICE_VOLUMECTL}" == "true" ]
|
|
|
|
then
|
2022-09-29 20:44:45 +00:00
|
|
|
nohup systemctl stop volume & >/dev/null 2>&1
|
2022-07-30 02:19:47 +00:00
|
|
|
fi
|
2022-03-26 16:15:38 +00:00
|
|
|
|
2022-09-29 20:44:45 +00:00
|
|
|
nohup alsactl store -f /storage/.config/asound.state >/dev/null 2>&1
|
2022-07-30 02:19:47 +00:00
|
|
|
|
2022-12-19 01:18:28 +00:00
|
|
|
if [ "$(get_setting bluetooth.enabled)" == "1" ]
|
|
|
|
then
|
|
|
|
nohup systemctl stop bluetooth >/dev/null 2>&1
|
|
|
|
fi
|
|
|
|
|
2022-12-19 22:14:32 +00:00
|
|
|
if [ -e "/usr/config/modules.bad" ]
|
2022-12-19 01:18:28 +00:00
|
|
|
then
|
2022-12-19 22:14:32 +00:00
|
|
|
for module in $(cat /usr/config/modules.bad)
|
|
|
|
do
|
|
|
|
echo ${module} >>/tmp/modules.load
|
|
|
|
modprobe -r ${module}
|
|
|
|
done
|
2022-12-19 01:18:28 +00:00
|
|
|
fi
|
2022-10-28 22:33:07 +00:00
|
|
|
|
2022-09-29 20:44:45 +00:00
|
|
|
wait
|
2022-02-05 14:23:32 +00:00
|
|
|
touch /run/.last_sleep_time
|
|
|
|
|
2022-03-26 16:15:38 +00:00
|
|
|
;;
|
|
|
|
post)
|
2022-08-26 10:16:05 +00:00
|
|
|
alsactl restore -f /storage/.config/asound.state
|
|
|
|
|
2022-12-19 22:14:32 +00:00
|
|
|
if [ -e "/tmp/modules.load" ]
|
2022-08-26 10:16:05 +00:00
|
|
|
then
|
2022-12-19 22:14:32 +00:00
|
|
|
for module in $(cat /tmp/modules.load)
|
|
|
|
do
|
|
|
|
modprobe ${module}
|
|
|
|
done
|
|
|
|
rm -f /tmp/modules.load
|
2022-08-26 10:16:05 +00:00
|
|
|
fi
|
2022-07-30 02:19:47 +00:00
|
|
|
|
|
|
|
if [ "${DEVICE_FAKE_JACKSENSE}" == "true" ]
|
|
|
|
then
|
2022-09-29 20:44:45 +00:00
|
|
|
nohup systemctl start headphones & >/dev/null 2>&1
|
2022-07-30 02:19:47 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${DEVICE_VOLUMECTL}" == "true" ]
|
|
|
|
then
|
2022-09-29 20:44:45 +00:00
|
|
|
nohup systemctl start volume & >/dev/null 2>&1
|
2022-08-28 23:53:29 +00:00
|
|
|
fi
|
|
|
|
|
2022-10-01 14:03:01 +00:00
|
|
|
if [ "$(get_setting wifi.enabled)" == "1" ]
|
2022-10-28 22:33:07 +00:00
|
|
|
then
|
|
|
|
nohup wifictl reconnect & >/dev/null 2>&1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$(get_setting bluetooth.enabled)" == "1" ]
|
|
|
|
then
|
|
|
|
nohup systemctl start bluetooth & >/dev/null 2>&1
|
|
|
|
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)
|
2022-09-29 20:44:45 +00:00
|
|
|
nohup amixer -M set "${DEVICE_AUDIO_MIXER}" ${DEVICE_VOLUME}% & >/dev/null 2>&1
|
2022-07-30 02:19:47 +00:00
|
|
|
|
2022-09-25 19:22:56 +00:00
|
|
|
BRIGHTNESS=$(get_setting system.brightness)
|
2022-10-02 00:22:43 +00:00
|
|
|
echo ${BRIGHTNESS} >/sys/class/backlight/$(brightness device)/brightness
|
2022-09-29 20:44:45 +00:00
|
|
|
|
|
|
|
wait
|
2022-03-26 16:15:38 +00:00
|
|
|
;;
|
2022-02-05 14:23:32 +00:00
|
|
|
esac
|