LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   howto exec a cmd after certain time of inactivity? (https://www.linuxquestions.org/questions/slackware-14/howto-exec-a-cmd-after-certain-time-of-inactivity-525664/)

minike 02-05-2007 12:46 AM

howto exec a cmd after certain time of inactivity?
 
hi, I'm traying to find out how to trigger a command after X minutes (exactly as a screensaver do) .. I thought it could be possible from xorg.conf, but.. those settings are just for blanking the screen, not for anything.

I also reviewed the xscreensaver app, but didn't find in it an option like "use this screensaver" where to add the command.

so, what I'm looking for is a way to use kinda "screen-saver engine" ..or something that allows me to trigger a command after certain inactivity time. (I need it just under X, no need to work in console).

if there is a way or app already within slack, the better.
anyway, if it's needed to add some proggy, I'll try it out.

thanks in advance

pdw_hu 02-05-2007 03:09 AM

You can use:
at - executes commands at a specified time.

minike 02-05-2007 10:09 AM

thanks 4 taking your time to answer..
but -til I know, `at` do not execute commands after certain time of inactivity, just do it after an exact amount of time given by the user.

what I'm looking 4 is something like the "first part" of a screensaver application (the part in where inactivity is measured)

any idea will be welcome.

pdw_hu 02-05-2007 10:14 AM

Ya RLY :)
Sorry my bad for not reading it carefully. Can't help you in that case tho :)

H_TeXMeX_H 02-05-2007 06:35 PM

Quote:

Originally Posted by pdw_hu
Ya RLY :)
Sorry my bad for not reading it carefully. Can't help you in that case tho :)

No, actually, you were right in the first place:

Quote:

Originally Posted by man at
batch
executes commands when system load levels permit; in other words, when the load average drops below 0.8, or the value specified in the invocation of atrun.

http://www.die.net/doc/linux/man/man1/at.1.html

malo_umoran 02-06-2007 04:28 AM

This script runs a command when a xscreensaver locks or blanks desktop. Something similar can be easily made for gnome-screensaver:

Code:

#!/usr/bin/perl -w

use strict;

delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin';

$<=0;  # become root not just effective root

open(XS,"/usr/bin/xscreensaver-command -watch|") or die;
while(<XS>) {
 
  ## do something when screensaved blanks the desktop
  if(/^BLANK/i) {
      system("/run/this/command");

  ## do something after unblanking
  } elsif(/^UNBLANK/i) {
      system("/run/this/command");

  ## do something when screen is locked
  } elsif(/^LOCK/i) {
      system("/run/this/command");
  }

  ## do something when screen is unlocked
  } elsif(/^UNLOCK/i) {
      system("/run/this/command");
  }
}

Just set up you xscreensaver to lock or blank the screen after X minutes of inactivity.

You have to put the script in autostart of you desktop environment (for Gnome: in Sessions Manager). It should be run every time when X is started or you logged in.

M.

minike 02-06-2007 06:01 AM

very thanks 4 the answers.
I solved doing this:
I opened the xscreensaver control-gui, looked 4 a screensaver entry unusable; selected it and in its (advanced) properties, deleted it name and put in its place the command I needed.
this way works just fine ..but blanks the screen! -nothing is perfect, uh? ;)
think it's the easiest way to do the job.
(about the "at" command:
right, there's something called "batch"..
but I've never been able to make the 'at' command work-I give up using it long time ago)

cheers


All times are GMT -5. The time now is 06:19 PM.