On 19.5.2014 12:15, Trever L. Adams wrote:
The problem I am having is figuring out how to set it up so it
automatically goes to sleep after X period of time and stay asleep.

Hi Trever.

I played with systemd a bit and made a script you can be inspired with (I hope).

Create a script /usr/lib/systemd/system-sleep/autosleep.sh and make it runnable:
-----------------------------------------------------
#!/bin/bash

# See: http://www.freedesktop.org/software/systemd/man/systemd-hibernate.service.html

PHASE="$1"
TYPE="$2"
sleep 30

echo "$(/bin/date +%Y%m%d-%H%M%S) P=$PHASE, T=$TYPE" >>/var/log/autosleep.log

if [ "$PHASE" == "post" -a -f /autosleep ] ; then
        RUNTIME=
        . /autosleep
        if [ "$RUNTIME" -gt 0 ] ; then
                case "$TYPE" in
                suspend|hibernate|hybrid-sleep)
                        echo '/sbin/pm-suspend-hybrid' | at now + $RUNTIME 
minutes
echo "$(/bin/date +%Y%m%d-%H%M%S) autosleep in $RUNTIME minutes" >>/var/log/autosleep.log
                        ;;
                *)      ;;
                esac
        fi
fi
-----------------------------------------------------
Then create a control file /autosleep:
-----------------------------------------------------
RUNTIME=10
-----------------------------------------------------
Replace number 10 with value you like, time is in minutes.

To start autosleep just sleep system manually. Next sleeps occurs automatically. To stop autosleep first delete scheduled task by /bin/at -d and then remove /autosleep file.

It seems hooks in /etc/pm/sleep.d doesn't work with systemd.
--

.: Vlado :.
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org

Reply via email to