From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8338 invoked from network); 29 Mar 1999 03:39:11 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 29 Mar 1999 03:39:11 -0000 Received: (qmail 14616 invoked by alias); 29 Mar 1999 03:38:29 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2251 Received: (qmail 14609 invoked from network); 29 Mar 1999 03:38:27 -0000 Date: Mon, 29 Mar 1999 13:37:56 +1000 From: Bek Oberin To: zsh-users@sunsite.auc.dk Subject: Idle function? Message-ID: <19990329133756.A505@tertius.net.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.3i X-Religion: linux slrn mutt vim 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/ From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8691 invoked from network); 29 Mar 1999 04:24:26 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 29 Mar 1999 04:24:26 -0000 Received: (qmail 16529 invoked by alias); 29 Mar 1999 04:23:56 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2253 Received: (qmail 16518 invoked from network); 29 Mar 1999 04:23:50 -0000 Date: Sun, 28 Mar 1999 23:23:32 -0500 From: Sweth Chandramouli To: zsh-users@sunsite.auc.dk Subject: Re: Idle function? Message-ID: <19990328232332.B11812@astaroth.nit.gwu.edu> Mail-Followup-To: zsh-users@sunsite.auc.dk References: <19990329133756.A505@tertius.net.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95i In-Reply-To: <19990329133756.A505@tertius.net.au> 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 / (202) 994 - 8521 (V) / (202) 994 - 0458 (F) * From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14770 invoked from network); 29 Mar 1999 07:17:08 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 29 Mar 1999 07:17:08 -0000 Received: (qmail 23755 invoked by alias); 29 Mar 1999 07:16:36 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2254 Received: (qmail 23748 invoked from network); 29 Mar 1999 07:16:32 -0000 From: "Bart Schaefer" Message-Id: <990328231626.ZM9717@candle.brasslantern.com> Date: Sun, 28 Mar 1999 23:16:26 -0800 In-Reply-To: <19990329133756.A505@tertius.net.au> Comments: In reply to Bek Oberin "Idle function?" (Mar 29, 1:37pm) References: <19990329133756.A505@tertius.net.au> X-Mailer: Z-Mail (4.0b.820 20aug96) To: zsh-users@sunsite.auc.dk Subject: Re: Idle function? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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