Add sleep helper.

This commit is contained in:
fewtarius 2022-08-30 21:27:44 -04:00
parent 77d98e3370
commit 7e84b78ca6
No known key found for this signature in database
GPG key ID: F4AE55305D1B8C1A
3 changed files with 93 additions and 0 deletions

View file

@ -0,0 +1,19 @@
PKG_NAME="sleep"
PKG_VERSION=""
PKG_SHA256=""
PKG_ARCH="any"
PKG_LICENSE="OSS"
PKG_DEPENDS_TARGET="systemd"
PKG_SITE=""
PKG_URL=""
PKG_LONGDESC="Sleep configuration"
PKG_TOOLCHAIN="manual"
makeinstall_target() {
mkdir -p $INSTALL/usr/config/sleep.conf.d
cp sleep.conf $INSTALL/usr/config/sleep.conf.d/sleep.conf
mkdir -p $INSTALL/usr/lib/systemd/system-sleep/
cp sleep.sh $INSTALL/usr/lib/systemd/system-sleep/sleep
chmod +x $INSTALL/usr/lib/systemd/system-sleep/sleep
}

View file

@ -0,0 +1,25 @@
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See systemd-sleep.conf(5) for details
[Sleep]
AllowSuspend=yes
#AllowHibernation=yes
#AllowSuspendThenHibernate=yes
#AllowHybridSleep=yes
#SuspendMode=suspend
SuspendState=mem standby freeze
#HibernateMode=platform shutdown
#HibernateState=disk
#HybridSleepMode=suspend platform shutdown
#HybridSleepState=disk
#HibernateDelaySec=180min

View file

@ -0,0 +1,49 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
. /etc/profile
case $1 in
pre)
if [ "${DEVICE_FAKE_JACKSENSE}" == "true" ]
then
nohup systemctl stop headphones &
fi
if [ "${DEVICE_VOLUMECTL}" == "true" ]
then
nohup systemctl stop volume &
fi
alsactl store -f /storage/.config/asound.state
touch /run/.last_sleep_time
;;
post)
alsactl restore -f /storage/.config/asound.state
if [ "${DEVICE_FAKE_JACKSENSE}" == "true" ]
then
nohup systemctl start headphones &
fi
if [ "${DEVICE_VOLUMECTL}" == "true" ]
then
nohup systemctl start volume &
fi
if [ "$(get_setting wifi.enabled)" == "1" ]
then
nohup wifictl reconnect &
fi
DEVICE_VOLUME=$(get_setting "audio.volume" 2>/dev/null)
amixer set "${DEVICE_AUDIO_MIXER}" ${DEVICE_VOLUME}% 2>&1 >/dev/null
### Call the brightness script to set to the last saved value.
/usr/lib/autostart/common/006-brightness
;;
esac