7

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.

  1. 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.

  2. 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.

2

1 Answer 1

6

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.

DISPLAY=:0 xprintidle

or

export DISPLAY=:0
xprintidle

either should work.

1
  • 2
    Keep in mind this will change if you have another monitor (larger/better one) made first display (and you later unplug it, when you take your laptop with you). I spent few hours debugging why my script stopped working today... Feb 6, 2018 at 20:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .