You are not logged in.
Pages: 1
I am running Arch with LXDE on desktop. I want the system to shutdown (poweroff) after 30 minutes of inactivity. I was searching for options and found following on pm-utils page of the wiki ( https://wiki.archlinux.org/index.php/Pm-utils ):
Suspend on idle/inactivity:
One method relies on xautolock program. Add following: xautolock -time 30 -locker "sudo pm-suspend" & to ~/.xinitrc. This implies that pm-suspend is called after 30 minutes of inactivity.
I thought I can replace the command "sudo pm-suspend" with "sudo poweroff" but my doubt is will this command not ask for password?
Thanks for your help.
Last edited by rnarch (2012-09-02 15:42:36)
Offline
How to post. A sincere effort to use modest and proper language and grammar is a sign of respect toward the community.
Offline
Thanks for your prompt reply.
Offline
It is not working. I added following line to .xinitrc :
xautolock -time 5 -locker "sudo poweroff" &
(only 5 minutes just to test).
Adding following line to .xinitrc also does not make a difference:
alias poweroff="sudo poweroff"
In visudo, I tried following lines (one by one). None of them worked.
abcde myhost=NOPASSWD: /sbin/shutdown -h now,/sbin/halt,/sbin/poweroff,/sbin/reboot
abcde ALL=(ALL) NOPASSWD: /sbin/shutdown -h now,/sbin/halt,/sbin/poweroff,/sbin/reboot
I am running systemd. Does that make a difference.
Last edited by rnarch (2012-09-01 00:38:29)
Offline
Well first test if your sudo entries are working. Run:
sudo -k
sudo poweroff
And see if it prompts for a password.
Offline
"sudo poweroff" command works without asking for password.
Offline
but if you alias poweroff='sudo poweroff' and then you make your locker 'sudo poweroff' then aren't you asking the shell to essentially 'sudo sudo poweroff' ?
Offline
It is not working even when I have removed:
alias poweroff='sudo poweroff'
Offline
I tried putting following command in .xinitrc:
xautolock -time 2 -locker "echo testing | wall" &
Even this is not working.
The command "echo testing | wall" (without quotes) works ok when typed at terminal. The message is displayed on other open terminals.
The full command:
xautolock -time 2 -locker "echo testing | wall"
(with or without terminal '&' to make it background) also works ok when typed in a terminal. Can I put this command in /etc/rc.local ?
Last edited by rnarch (2012-09-01 11:17:42)
Offline
you know I had a similar issue with xautolock being run from xinitrc. I think it may be better to use the autostart script if your window manager or de has one. What is it you are using?
I knid of remember trying to include it in my xinitrc, and then it became a child process or xinit which made it do funny things. At the moment, my window manager of choice is dwm, so what I do is create a script that includes all the things I want to start with dwm, and then it also starts dwm. I call it (creatively) startdwm. so in my xinitrc, I include "exec startdwm" rather than "exec dwm"
Offline
I am running LXDE. The window manager is openbox.
Offline
Make sure ~/.config/openbox/autostart exists and is executable. Then you can put in
xautlock -time 30 -locker 'sudo /sbin/shutdown -h now' &
That should work. I essentially have the same thing but with slimlock instead of shutdown.
Offline
I thought that lxde had a different autostart script so that it wouldn't run both the standalone openbox script and the lxde script.
Offline
I thought that lxde had a different autostart script so that it wouldn't run both the standalone openbox script and the lxde script.
It does. https://wiki.archlinux.org/index.php/LX … t_Programs
How to post. A sincere effort to use modest and proper language and grammar is a sign of respect toward the community.
Offline
I tried putting the command in /etc/rc.local and in ~/.config/lxsession/LXDE/autostart file. It does not work from either place.
On checking 'ps -aux | grep xautolock', there is no entry. The other entries of autostart file are seen to be executed. Where could be the error?
The entry in ~/.config/lxsession/LXDE/autostart file is:
@xautolock -time 3 -locker '/sbin/poweroff' &
and entry in visudo is:
myusername ALL=(ALL) NOPASSWD: /sbin/shutdown -h now,/sbin/halt,/sbin/poweroff,/sbin/reboot
The command 'sudo poweroff' does not ask for password when typed on terminal.
The command xautolock -time 3 -locker '/sbin/poweroff' also does not work when typed from terminal.
Last edited by rnarch (2012-09-02 15:41:48)
Offline
You forgot to include sudo in your command:
@xautolock -time 3 -locker 'sudo /sbin/poweroff' &
Offline
I think I also remember seeing somewhere that in lxde, you are *not* to put the trailing &... you may need to confirm this as it has been a while since I've used lxde.
Also, just to you are aware, it is called xautolock because it is a program designed for X. Putting that in your rc.local will typically run it before you have an X server running, so will simply fail.
Offline
I think I also remember seeing somewhere that in lxde, you are *not* to put the trailing &...
You are correct again. https://wiki.archlinux.org/index.php/LX … t_Programs
Seems you remember more about LXDE than you think.
How to post. A sincere effort to use modest and proper language and grammar is a sign of respect toward the community.
Offline
WonderWoofy wrote:I think I also remember seeing somewhere that in lxde, you are *not* to put the trailing &...
You are correct again. https://wiki.archlinux.org/index.php/LX … t_Programs
Seems you remember more about LXDE than you think.
I am an openbox user (amongst other WM's), so I just remember it's setup being kinda funky relative to the setup of standalone openbox.
Offline
Finally, it is working! The command entered in ~/.config/lxsession/LXDE/autostart file is:
@xautolock -time 30 -locker 'sudo /sbin/poweroff'
It has to be combined with visudo entry:
myusername ALL=(ALL) NOPASSWD: /sbin/poweroff
Thanks for your help. I am marking this thread as solved.
Last edited by rnarch (2012-09-02 15:43:20)
Offline
Pages: 1