Registered Member
|
Hi.
It's been a while since I used this but I used to put the PC to sleep at a set time and used sudo pm-suspend command in Task Scheduler. Now I notice it doesn't work because it needs the root password. So I'm guessing you can't add anything to "sudo pm-suspend" command in TS and have to alter the sudoers file in /etc/sudoers? I've read an Arch wiki page on it but the page is out of date and opensuse might be different. What is the correct way to do this? Thanks |
Administrator
|
You'll need to adjust the /etc/sudoers file manually i'm afraid in order for Task Scheduler to be able to work. If Task Scheduler is running commands from your session you might also want to consider a command such as the following instead, which does not require root access (but does require a running KDE session):
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered Member
|
Thanks, ok so I modified the command to :
and ran it from TS and it returned:
I don't mind editing sudoer if I have to but if it can be done from TS all the better. |
Registered Member
|
The correct command should be:
Or just use "systemctl suspend" instead of "pm-suspend", this should work as user as well. |
Registered Member
|
Much obliged, first one does indeed now work (not tried second one yet), thanks.
For future reference does the same command apply for suspending to disk? Like..
And does this sudoers method still apply? https://wiki.archlinux.org/index.php/pm ... ion_method Thanks again |
Registered Member
|
Yes, exactly. Or "systemctl hibernate".
Yes, except that there's no "power" group on openSUSE AFAICS. But pm-utils is deprecated, better use the systemctl method I'd say. PS: You could also have a look at kshutdown: http://kshutdown.sourceforge.net/ |
|
alternative command (in case you need this outside KDE or don't want to run powerdevil on a desktop box)
resp.
|
Registered Member
|
Humm, so things take a turn for the weird.
The commands that will run from Task Scheduler work when clicking the Run Now button but left to work at the selected time do not, the command isn't executed or something. I don't see anything untoward, any ideas? |
Registered Member
|
Well, the commands are run by cron (a system daemon), not KDE. So probably they don't find the (user's) DBUS session then. Have you tried the system bus method luebking posted? "systemctl xxx" should work as well I suppose, but I'm not sure whether it would have the required permissions when run as user by cron (normally only a user logged in at the active console is allowed to suspend/hibernate). You could of course also add your command (i.e. either "systemctl suspend" or "pm-suspend") to root's crontab, by launching systemsettings as root:
Or try kshutdown, that seems to offer exactly what you want to achieve. Packages for openSUSE are available in the KDE:Extra repo: http://software.opensuse.org/package/kshutdown |
Registered Member
|
Things is I've got VLC to close using pkill vlc one minute before the suspend is supposed to happen, and that works fine, so just assumed..
When I run (Run Now) qdbus --system org.freedesktop.login1 /org/freedesktop/login1 Suspend false it returns..
I'll give try crontab in a bit, but does that error message indicate a larger problem? |
Registered Member
|
I think that's because when cron runs the command on behalf as your user, the session is not registered with logind, therefore the command has no permissions to call that method. So I guess the only options then are to run either "systemctl suspend" or "pm-suspend" as root by using "sudo" or adding the command to the system cron (you have to run the Task Scheduler as root for this, as mentioned in my previous post). You can of course kill vlc as root as well. |
Registered Member
|
Ok, I think we've got this covered now. Just to confirm that the little KShutdown program works well, as does systemctl suspend as root (kdesu kcmshell4 cron). Hopefully someone else finds this thread helpful in future. Thanks for all the help, very informative!
|
Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]