How to run a script when no keyboard or mouse activity

Hi all,

Need some help. I want to run a script when there is no keyboard or mouse
activity for X amount of minutes.
Like a screensaver does, but to run a script instead. Anyone know how to
do this?

Been wondering how to attempt this for quite some time, Any help is
appreciated!

Regards,
Kevin
mojo7777 at gmail dot com
NightHawk [ Mo, 28 Januar 2008 07:46 ] [ ID #1917750 ]

Re: How to run a script when no keyboard or mouse activity

On 28 Jan 2008 06:46:15 GMT, NightHawk wrote:
[...]
> Need some help. I want to run a script when there is no keyboard or mouse
> activity for X amount of minutes.
> Like a screensaver does, but to run a script instead. Anyone know how to
> do this?
>
> Been wondering how to attempt this for quite some time, Any help is
> appreciated!
[...]

On X11, you may use XScreenSaverQueryInfo() to query the idle
time.

That means writing a few lines of C code.

There exists a non-standard X utility that you may download off
the web, called xprintidle that does that:

$ ltrace xprintidle
__libc_start_main(0x8048630, 1, 0xbfd8f154, 0x8048790, 0x8048800 <unfinished ...>
XOpenDisplay(NULL) = 0x804a008
XScreenSaverQueryExtension(0x804a008, 0xbfd8f0ac, 0xbfd8f0a8, 0x804857e, 0xbfd8f154) = 1
XScreenSaverQueryInfo(0x804a008, 106, 0xbfd8f090, 0x804857e, 0xbfd8f154) = 1
printf("%lu\n", 2121
) = 3
XCloseDisplay(0x804a008) = <void>

http://www.dtek.chalmers.se/~henoch/text/xprintidle.html

If you feel brave, on Linux, you could watch /proc/interrupts
and parse information in /proc/irq or elsewhere to see what
corresponds to your mice and keyboards.

You may also use xscreensaver or xlockmore that are able to run
arbitrary commands upon reaching a given idle time. May not be
easy to do automatically (in a script) or reliably (without
interferring with the user's screen saver for instance).

--
Stephane
Stephane CHAZELAS [ Mo, 28 Januar 2008 11:17 ] [ ID #1917759 ]

Re: How to run a script when no keyboard or mouse activity

NightHawk <mojo7777 [at] gmail.com> writes:
>
>Need some help. I want to run a script when there is no keyboard or mouse
>activity for X amount of minutes.
>Like a screensaver does, but to run a script instead. Anyone know how to
>do this?
>

Configure the X server to think your script is a screensaver and run it.

-Greg
--
::::::::::::: Greg Andrews ::::: gerg [at] panix.com :::::::::::::
I have a map of the United States that's actual size.
-- Steven Wright
gerg [ Mi, 30 Januar 2008 02:10 ] [ ID #1919720 ]

Re: How to run a script when no keyboard or mouse activity

On Wed, 30 Jan 2008 01:10:05 +0000, Greg Andrews wrote:

> NightHawk <mojo7777 [at] gmail.com> writes:
>>
>>Need some help. I want to run a script when there is no keyboard or
>>mouse activity for X amount of minutes.
>>Like a screensaver does, but to run a script instead. Anyone know how
>>to do this?
>>
>>
> Configure the X server to think your script is a screensaver and run it.
>
> -Greg

Do you know how to do this?

--Kevin
NightHawk [ Mi, 30 Januar 2008 06:24 ] [ ID #1919729 ]

Re: How to run a script when no keyboard or mouse activity

NightHawk <mojo7777 [at] gmail.com> writes:
>On Wed, 30 Jan 2008 01:10:05 +0000, Greg Andrews wrote:
>
>> NightHawk <mojo7777 [at] gmail.com> writes:
>>>
>>>Need some help. I want to run a script when there is no keyboard or
>>>mouse activity for X amount of minutes.
>>>Like a screensaver does, but to run a script instead. Anyone know how
>>>to do this?
>>>
>>>
>> Configure the X server to think your script is a screensaver and run it.
>>
>
>Do you know how to do this?
>

It has been several years since I compiled a few new screensavers and
configured my X server to run them. I don't remember the details at
the moment.

Does your desktop have any menus labeled "Screensaver"? What do you
use, Gnome, KDE, CDE, something else?

-Greg
--
::::::::::::: Greg Andrews ::::: gerg [at] panix.com :::::::::::::
I have a map of the United States that's actual size.
-- Steven Wright
gerg [ Mi, 30 Januar 2008 09:26 ] [ ID #1919732 ]
Linux » comp.unix.shell » How to run a script when no keyboard or mouse activity

Vorheriges Thema: ksh: (Null character) Set mark
Nächstes Thema: bash test badly implemented