#!/bin/bash . /etc/profile REQUESTED_MODE="${*}" SUSPEND_MODE=$(get_setting system.suspendmode) if [ ! "${REQUESTED_MODE}" = "${SUSPEND_MODE}" ] then cat </storage/.config/sleep.conf.d/sleep.conf [Sleep] EOF case ${REQUESTED_MODE} in off) cat <>/storage/.config/sleep.conf.d/sleep.conf AllowSuspend=no EOF ;; freeze) cat <>/storage/.config/sleep.conf.d/sleep.conf AllowSuspend=yes SuspendState=freeze standby mem EOF ;; standby) cat <>/storage/.config/sleep.conf.d/sleep.conf AllowSuspend=yes SuspendState=standby mem freeze EOF ;; mem) cat <>/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 <>/storage/.config/sleep.conf.d/sleep.conf AllowSuspend=yes SuspendState=${REQUESTED_MODE} EOF ;; esac set_setting system.suspendmode ${1} systemctl restart systemd-logind fi