You are not logged in.

#1 2014-10-21 06:34:27

mah0
Member
Registered: 2011-04-21
Posts: 47

BASH How to reset script var while it's running?

This simple script is executed by motion when it detects movement. The issue is that it does it constantly while there is any movement. How can I modify it to just reset the timeout and not to invoke another instance?
P.S. Sorry if I wasn't very clear.

#!/bin/sh

export DISPLAY=:0
timeout=20

wmctrl -a vlc
sleep $timeout
wmctrl -a chromium

Offline

#2 2014-10-21 08:44:50

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: BASH How to reset script var while it's running?

What sort of movement are you talking about? Mouse movement? I cannot see anything in the code which acts on movement.

Can you elaborate what exactly are you trying to achieve?

Offline

#3 2014-10-21 09:39:14

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: BASH How to reset script var while it's running?

I'm guessing that the script is executed by the application motion.

It might depend on how motion executes it, but you could look into the Bash command "read".
See http://mywiki.wooledge.org/BashGuide/InputAndOutput

Last edited by skanky (2014-10-21 09:39:39)


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#4 2014-10-21 09:40:00

mah0
Member
Registered: 2011-04-21
Posts: 47

Re: BASH How to reset script var while it's running?

x33a,
I'm talking about this program. It has `on_motion_detected` command that executes external program or a script.
I want to display a nagios statusmap on the screen, and to focus vlc player, when motion detects movement on one of the two ip cameras, then switch back to chromium.
What I did so far is this: motion executes this script on `on_motion_detected` and another one decides to which window give focus based on the last motion time. Is this solution any good?

Last edited by mah0 (2014-10-21 09:44:16)

Offline

Board footer

Powered by FluxBB