distribution/packages/jelos/sources/scripts/suspendmode

55 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
. /etc/profile
REQUESTED_MODE="${*}"
SUSPEND_MODE=$(get_setting system.suspendmode)
if [ ! "${REQUESTED_MODE}" = "${SUSPEND_MODE}" ]
then
cat <<EOF >/storage/.config/sleep.conf.d/sleep.conf
[Sleep]
EOF
case ${REQUESTED_MODE} in
off)
cat <<EOF >>/storage/.config/sleep.conf.d/sleep.conf
AllowSuspend=no
EOF
;;
freeze)
cat <<EOF >>/storage/.config/sleep.conf.d/sleep.conf
AllowSuspend=yes
SuspendState=freeze standby mem
EOF
;;
standby)
cat <<EOF >>/storage/.config/sleep.conf.d/sleep.conf
AllowSuspend=yes
SuspendState=standby mem freeze
EOF
;;
mem)
cat <<EOF >>/storage/.config/sleep.conf.d/sleep.conf
AllowSuspend=yes
SuspendState=mem standby freeze
EOF
;;
default)
del_setting system.suspendmode
if [ -e "/usr/lib/autostart/quirks/platforms/${HW_DEVICE}/030-suspend_mode" ]
then
"/usr/lib/autostart/quirks/devices/${QUIRK_DEVICE}/030-suspend_mode"
elif [ -e "/usr/lib/autostart/quirks/devices/${QUIRK_DEVICE}/030-suspend_mode" ]
then
"/usr/lib/autostart/quirks/platforms/${HW_DEVICE}/030-suspend_mode"
fi
;;
*)
cat <<EOF >>/storage/.config/sleep.conf.d/sleep.conf
AllowSuspend=yes
SuspendState=${REQUESTED_MODE}
EOF
;;
esac
set_setting system.suspendmode ${1}
systemctl restart systemd-logind
fi