Power Management, SystemD, etc.

Trever L. Adams trever at middleearth.sapphiresunday.org
Wed May 28 07:13:26 UTC 2014


On 05/27/2014 02:54 PM, V.99 wrote:
> 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.
Thank you. I believe I can make work with this for making mine systemd,
right now it is cron. I use rtcwake instead of sleep. As I need it to
wake up for specific timed events (backups, that is what the machine
does). I also have it set to wake-on-lan so that I can do restores if
needed.

The problem I need to figure out is how to have it sleep when the system
is idle. I have others that this would work well for, if I could do
that. Gnome, etc. does this. I haven't found a command line/systemd
setup that will do this.

Say 10 minutes of being idle.

Thank you for your help!

Again, I now see clearly some systemd things I didn't before.

Trever

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 884 bytes
Desc: OpenPGP digital signature
URL: <http://lists.fedoraproject.org/pipermail/users/attachments/20140528/952ea0e1/attachment.sig>


More information about the users mailing list