zsh-users
 help / color / mirror / code / Atom feed
* Idle function?
@ 1999-03-29  3:37 Bek Oberin
  1999-03-29  4:23 ` Sweth Chandramouli
  1999-03-29  7:16 ` Bart Schaefer
  0 siblings, 2 replies; 3+ messages in thread
From: Bek Oberin @ 1999-03-29  3:37 UTC (permalink / raw)
  To: zsh-users


Is it possible for a console to auto-execute a command when it has
been idle for x number of minutes?  I don't want it to log off, just
reread some config files.

bekj

-- 
: --Hacker-Neophile-Eclectic-Geek-Grrl-Queer-Disabled-Boychick--
: gossamer@tertius.net.au   http://www.tertius.net.au/~gossamer/


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Idle function?
  1999-03-29  3:37 Idle function? Bek Oberin
@ 1999-03-29  4:23 ` Sweth Chandramouli
  1999-03-29  7:16 ` Bart Schaefer
  1 sibling, 0 replies; 3+ messages in thread
From: Sweth Chandramouli @ 1999-03-29  4:23 UTC (permalink / raw)
  To: zsh-users

On Mon, Mar 29, 1999 at 01:37:56PM +1000, Bek Oberin wrote:
> Is it possible for a console to auto-execute a command when it has
> been idle for x number of minutes?  I don't want it to log off, just
> reread some config files.
	i could swear you asked this sometime last year, too... i think the 
eventual answer was something like "have your preexec reset an IDLETIME
variable, and then start a background process that checked the value of
IDLETIME every so often and did something if it hadn't been reset in the
relevant time period".
	the details should be in the archives.

	-- sweth.

-- 
Sweth Chandramouli
IS Coordinator, The George Washington University
<sweth@gwu.edu> / (202) 994 - 8521 (V) / (202) 994 - 0458 (F)
<a href="http://astaroth.nit.gwu.edu/~sweth/disc.html">*</a>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Idle function?
  1999-03-29  3:37 Idle function? Bek Oberin
  1999-03-29  4:23 ` Sweth Chandramouli
@ 1999-03-29  7:16 ` Bart Schaefer
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 1999-03-29  7:16 UTC (permalink / raw)
  To: zsh-users

On Mar 29,  1:37pm, Bek Oberin wrote:
} Subject: Idle function?
}
} Is it possible for a console to auto-execute a command

What is "a console"?

} when it has been idle for x number of minutes?

Like Sweth, I remember you asking a similar question some while ago.
It was the reverse last time, though, wasn't it?  How to do something
when the tty had NOT been idle for some length of time?

Zsh has the $TTYIDLE variable and $TMOUT ... I personally have this in
my init files:

 # Update title bar periodically if it has been idle a long time (10 min).
 # Otherwise let precmd() do it, so we don't cause unwanted scroll-to-bot.
 precmd() { TMOUT=600 ; title }
 TRAPALRM() { TMOUT=60 ; title }

The `title` function puts the current time and current directory on the
screen somewhere -- in the status bar if the terminal has one, or in the
title bar of an xterm (whence the name), or wherever.  Normally this is
updated every time a prompt is printed, in precmd(), which is often more
than once a minute.

If I'm away from my terminal for 10 minutes, however, TMOUT kicks in and
the title starts updating every 60 seconds from TRAPALRM.  As soon as I
get back and start running commands again, the delay goes back to 10
minutes.

You'll probably find almost exactly that description in the archives a
few previous times, if you look.

If you want something that works even when a command (say, an editor) is
in the foreground, then you have to do something like background a loop
that alternately sleeps for a while and checks $TTYIDLE.  Unfortunately,
you can't do this with a subshell because TTYIDLE is always -1 in a job
backgrounded that way; so something like:

   zsh -fc "sleep 10; ((TTYIDLE > x * 60)) && echo Do Something 1>&2"

That still doesn't get the "topmost" zsh (assuming that's what you mean
by "a console") to do anything; it makes itself pretty unreachable when
a child process is in the foreground.  So you might be just as well off
with the TMOUT hack.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-03-29  7:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-29  3:37 Idle function? Bek Oberin
1999-03-29  4:23 ` Sweth Chandramouli
1999-03-29  7:16 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).