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-20 21:16:51 +00:00
|
|
|
systemctl stop headphones
|
2022-07-30 02:19:47 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${DEVICE_VOLUMECTL}" == "true" ]
|
|
|
|
then
|
2022-09-20 21:16:51 +00:00
|
|
|
systemctl stop volume
|
2022-07-30 02:19:47 +00:00
|
|
|
fi
|
2022-03-26 16:15:38 +00:00
|
|
|
|
|
|
|
# RG351x devices are notorious for losing USB when they sleep.
|
|
|
|
if [[ "${HW_DEVICE}" =~ RG351 ]]
|
|
|
|
then
|
2022-08-26 10:18:34 +00:00
|
|
|
modprobe -r dwc2
|
2022-03-26 16:15:38 +00:00
|
|
|
fi
|
|
|
|
|
2022-07-30 02:19:47 +00:00
|
|
|
alsactl store -f /storage/.config/asound.state
|
|
|
|
|
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
|
|
|
|
|
|
|
|
if [[ "${HW_DEVICE}" =~ RG351 ]]
|
|
|
|
then
|
2022-08-26 10:18:34 +00:00
|
|
|
modprobe -i dwc2
|
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-20 21:16:51 +00:00
|
|
|
systemctl start headphones
|
2022-07-30 02:19:47 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${DEVICE_VOLUMECTL}" == "true" ]
|
|
|
|
then
|
2022-09-20 21:16:51 +00:00
|
|
|
systemctl start volume
|
2022-07-30 02:19:47 +00:00
|
|
|
fi
|
2022-03-26 16:15:38 +00:00
|
|
|
|
2022-08-28 23:53:29 +00:00
|
|
|
if [ "$(get_setting wifi.enabled)" == "1" ]
|
|
|
|
then
|
2022-09-20 21:16:51 +00:00
|
|
|
wifictl reconnect
|
2022-08-28 23:53:29 +00:00
|
|
|
fi
|
|
|
|
|
2022-07-30 02:19:47 +00:00
|
|
|
DEVICE_VOLUME=$(get_setting "audio.volume" 2>/dev/null)
|
2022-09-22 23:50:28 +00:00
|
|
|
amixer -M set "${DEVICE_AUDIO_MIXER}" ${DEVICE_VOLUME}% 2>&1 >/dev/null
|
2022-07-30 02:19:47 +00:00
|
|
|
|
2022-08-04 21:01:33 +00:00
|
|
|
### Call the brightness script to set to the last saved value.
|
|
|
|
/usr/lib/autostart/common/006-brightness
|
2022-03-26 16:15:38 +00:00
|
|
|
;;
|
2022-02-05 14:23:32 +00:00
|
|
|
esac
|