I have lxle (Lubuntu) 12.04 installed and I spent lots of time looking for working solution to make PC shutdown after some period of idle state.
After checking many programs which haven't worked I decided to spend much time of shell script solution run by cronjob
I am stuck on 2 problems here.
-
xprintidle doesn't give any results (empty string) when it is run by cronjob – no matter in crontab file or shell file in those environments it just give empty string instead of number of milliseconds of idle.
-
Secondly it seems not simple for me to run my script from crontab for shutdown commend as a root.
Could you give me a link explaining that topic? I know only sudo as a user, but script shouldn't ask for password but just shutdown system.
Best Answer
You need to set the DISPLAY environment variable before calling it, you can try this in the virtual consoles (Ctrl-Alt-F1) since they don't have the DISPLAY variable set, they will act exactly like the cron script will act.
or
either should work.