Add sleep helper.
This commit is contained in:
parent
77d98e3370
commit
7e84b78ca6
3 changed files with 93 additions and 0 deletions
19
projects/PC/packages/sleep/package.mk
Normal file
19
projects/PC/packages/sleep/package.mk
Normal 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
|
||||||
|
}
|
25
projects/PC/packages/sleep/sources/sleep.conf
Normal file
25
projects/PC/packages/sleep/sources/sleep.conf
Normal 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
|
49
projects/PC/packages/sleep/sources/sleep.sh
Executable file
49
projects/PC/packages/sleep/sources/sleep.sh
Executable 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
|
Loading…
Reference in a new issue