zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@zsh.org>
Cc: "A. Wik" <awik32@gmail.com>
Subject: Re: Call a function when idle?
Date: Mon, 14 Dec 2020 08:06:30 -0800	[thread overview]
Message-ID: <CAH+w=7YwtDNBMzZ8Vx52XwVmkZgT8a0eGNHzJa0+OFQfTwkdxA@mail.gmail.com> (raw)
In-Reply-To: <CAHYJk3QNN7yGZspvXyNhn3WVhss-xYZ9dW-kSY1QnLT9ED3gaw@mail.gmail.com>

On Mon, Dec 14, 2020 at 6:57 AM Mikael Magnusson <mikachu@gmail.com> wrote:
>
> On 12/14/20, A. Wik <awik32@gmail.com> wrote:
> >
> > So, the question is how to set up an idle timer to call the function.
> > I figured someone had already done something like that before (perhaps
> > to log out automatically).
>
> You may want to unset TMOUT in your handler and then arrange for it to
> be set when you enter a new command line and/or any relevant
> information has changed, otherwise you will come back to a lot of the
> same information.

I've been using the following for years to maintain the title bars in
my xterm-compatible shell windows:

typeset top=$'\C-[]0;'
typeset back=$'\C-G'
title () {
    setopt localoptions promptpercent
    print -nP "%{$top${*:-%m.%l:%2c - %t}$back%}"
}
TRAPALRM () {
    TMOUT=60
    title
}
precmd () {
    TMOUT=600
    title
}

This updates the title bar on every prompt, and then after 10 minutes
of idle time it updates it again every minute.


  reply	other threads:[~2020-12-14 16:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-14 11:57 A. Wik
2020-12-14 14:57 ` Mikael Magnusson
2020-12-14 16:06   ` Bart Schaefer [this message]
2020-12-15 11:09     ` A. Wik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7YwtDNBMzZ8Vx52XwVmkZgT8a0eGNHzJa0+OFQfTwkdxA@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=awik32@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).