You are not logged in.

#1 2012-08-31 01:19:31

rnarch
Member
Registered: 2012-03-17
Posts: 292

xautolock command help [solved]

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

#2 2012-08-31 01:20:55

2ManyDogs
Member
Registered: 2012-01-15
Posts: 1,631

Re: xautolock command help [solved]

Online

#3 2012-08-31 01:22:39

rnarch
Member
Registered: 2012-03-17
Posts: 292

Re: xautolock command help [solved]

Thanks for your prompt reply.

Offline

#4 2012-09-01 00:37:46

rnarch
Member
Registered: 2012-03-17
Posts: 292

Re: xautolock command help [solved]

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

#5 2012-09-01 02:36:35

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,058

Re: xautolock command help [solved]

Well first test if your sudo entries are working. Run:

sudo -k
sudo poweroff

And see if it prompts for a password.

Offline

#6 2012-09-01 05:39:20

rnarch
Member
Registered: 2012-03-17
Posts: 292

Re: xautolock command help [solved]

"sudo poweroff" command works without asking for password.

Offline

#7 2012-09-01 06:05:26

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: xautolock command help [solved]

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

#8 2012-09-01 08:01:56

rnarch
Member
Registered: 2012-03-17
Posts: 292

Re: xautolock command help [solved]

It is not working even when I have removed:

alias poweroff='sudo poweroff'

Offline

#9 2012-09-01 09:10:52

rnarch
Member
Registered: 2012-03-17
Posts: 292

Re: xautolock command help [solved]

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

#10 2012-09-01 14:55:18

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: xautolock command help [solved]

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

#11 2012-09-01 17:34:34

rnarch
Member
Registered: 2012-03-17
Posts: 292

Re: xautolock command help [solved]

I am running LXDE. The window manager is openbox.

Offline

#12 2012-09-01 20:50:00

alienated_humour
Member
From: NYC
Registered: 2011-07-28
Posts: 23

Re: xautolock command help [solved]

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

#13 2012-09-01 22:52:14

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: xautolock command help [solved]

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

#14 2012-09-01 23:01:37

2ManyDogs
Member
Registered: 2012-01-15
Posts: 1,631

Re: xautolock command help [solved]

WonderWoofy wrote:

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

Online

#15 2012-09-02 07:44:40

rnarch
Member
Registered: 2012-03-17
Posts: 292

Re: xautolock command help [solved]

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

#16 2012-09-02 14:23:50

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,058

Re: xautolock command help [solved]

You forgot to include sudo in your command:

@xautolock -time 3 -locker 'sudo /sbin/poweroff' &

Offline

#17 2012-09-02 14:51:26

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: xautolock command help [solved]

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

#18 2012-09-02 15:03:12

2ManyDogs
Member
Registered: 2012-01-15
Posts: 1,631

Re: xautolock command help [solved]

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.

Online

#19 2012-09-02 15:31:14

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: xautolock command help [solved]

2ManyDogs wrote:
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

#20 2012-09-02 15:41:12

rnarch
Member
Registered: 2012-03-17
Posts: 292

Re: xautolock command help [solved]

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

Board footer

Powered by FluxBB