Results 1 to 5 of 5

Thread: Sleep timer

  1. #1
    Join Date
    Feb 2010
    Location
    Scottsdale, AZ
    Posts
    190

    Default Sleep timer

    I am trying to set up my system so that it will sleep (suspend) at 22:30 every night.

    I have written the follow script:
    Code:
    #!/bin/bash
    
    dbus-send --print-reply \
                --system \
                --dest=org.freedesktop.UPower \
                /org/freedesktop/UPower \
                org.freedesktop.UPower.Suspend
    and saved it as /home/steve/bin/sleep.sh. If I execute this from the command line it works.

    I have written the following crontab:
    Code:
    # DO NOT EDIT THIS FILE - edit the master and reinstall.
    # (/tmp/crontab.XXQM14 installed on Thu Aug 16 21:03:25 2012)
    # (Cronie version 4.2)
    30 22 * * * /home/steve/bin/sleep.sh > /home/steve/cron.txt 2>&1
    When this executes, it leaves the following error message:
    Code:
    Error org.freedesktop.UPower.GeneralError: not authorized
    What am I missing?

    openSUSE 12.1 x86_64 KDE 4.8

  2. #2
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: Sleep timer

    On 2012-08-17 03:16, evetsnameloc wrote:
    >
    > I am trying to set up my system so that it will sleep (suspend) at 22:30
    > every night.
    >
    > I have written the follow script:


    There are two commands to directly suspend/hibernate a machine: pm-hibernate or pm-suspend
    (needs being root), or powersave -U or -u that runs as user if user is allowed.

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 11.4 x86_64 "Celadon" at Telcontar)

  3. #3
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,851

    Default Re: Sleep timer

    You miss authorisation.

    You might think that is a bit stupid to answer, but it is what you asked for.

    Shutting dow the system (all variants of course. including hibernation, etc.) is typicaly a superuser task (what, when all end-users could do that at will?). Now it could be that a (or more) desktop user(s) are allowed to do this via the freedesktop.org mechanism. But when you run a script in the background, there is no desktop at all.
    Henk van Velden

  4. #4
    Join Date
    Feb 2010
    Location
    Scottsdale, AZ
    Posts
    190

    Default Re: Sleep timer

    Quote Originally Posted by robin_listas View Post
    There are two commands to directly suspend/hibernate a machine: pm-hibernate or pm-suspend
    (needs being root), or powersave -U or -u that runs as user if user is allowed.
    Actually, I ended up writing a root-level crontab that uses pm-suspend and this works. I was just trying to find a way to do this without having to be root.

    Quote Originally Posted by hcvv View Post
    You miss authorisation.

    You might think that is a bit stupid to answer, but it is what you asked for.

    Shutting dow the system (all variants of course. including hibernation, etc.) is typicaly a superuser task (what, when all end-users could do that at will?). Now it could be that a (or more) desktop user(s) are allowed to do this via the freedesktop.org mechanism. But when you run a script in the background, there is no desktop at all.
    Not stupid at all, and in fact makes a lot of sense. Thanks.

  5. #5
    Vahis NNTP User

    Default Re: Sleep timer

    evetsnameloc wrote:
    >
    > robin_listas;2480423 Wrote:
    >> There are two commands to directly suspend/hibernate a machine:
    >> pm-hibernate or pm-suspend
    >> (needs being root), or powersave -U or -u that runs as user if user is
    >> allowed.

    >
    > Actually, I ended up writing a root-level crontab that uses pm-suspend
    > and this works. I was just trying to find a way to do this without
    > having to be root.


    You can configure your user to be able to run pm-suspend without
    password in sudoers.

    Better yeet: YaST > Sudoers.


    Vahis
    --
    http://waxborg.servepics.com
    openSUSE 11.4 (x86_64) 2.6.37.6-0.20-default main host
    openSUSE 12.1 (x86_64) 3.4.8-1-desktop Tumbleweed in VirtualBox
    openSUSE 12.1 (i586) 3.1.10-1.16-desktop in EeePC 900

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •