-   Linux - General (
-   -   automatically run command in terminal after x minutes of idle time. (

williantalvane 07-24-2012 04:23 AM

automatically run command in terminal after x minutes of idle time.
Hi, I'd like to know if there is any way to automatically run a specific command in the terminal after the terminal has been idle for x minutes. I use terminator, so I have several terminal windows open at the same time. What I want to do is to make my terminal run a command when the idle time reaches x minutes. The command I want to run is:
> cmatrix -b

It's just a fun command that I want to use as a terminal screen saver.
I think I want something like this in my .bashrc file:

> if (terminal.idle.time = 5 min) {
> cmatrix -b
> } else {
> do nothing}

Is it possible?

Thanks a lot.

whizzit 07-25-2012 06:31 PM

Two options come to mind:
  1. xidle
  2. xautolock

I presume you're using Ubuntu, from your post icon.

The first I've used in the past (maybe on BSD) but can't find this in standard repos for Linux (well Debian & Ubuntu).
By the look of it the second could be fashioned to use with --time and specifying a script to --notifier or --locker.

williantalvane 02-20-2013 12:42 PM

I still don't know how to do that. Could you explain me how xautolock would do that? What I want is very simple. I want to script that says:
If terminal idle time reaches 5 min, the terminal will execute the following command: cmatrix -b
There must be some way to do this simple task.

codergeek 02-21-2013 11:21 PM

The most simplest way to execute a command after a certain time period is with sleep


sleep 5m ; cmatrix -b

All times are GMT -5. The time now is 08:54 AM.