Motion - Feature Request 2014x 01x 24x 174516

Feature Request: Enable and disable recording in motion


I am using motion to monitor my office work area. Huge numbers of files are created of me staring at my computer screen.

Perhaps it would be nice to only record when I am away from my desk.

I found a program, blueproximity, that pairs with a bluetooth device and when the device goes in and out of radio range, issues a definable command. The default commands invoke the "gnome-screensaver-command" with either "--activate" or "--deactivate".

It is also possible to pass a "--query" command to "gnome-screensaver-command" and this returns a string, "The screensaver is inactive", or the converse.

So it it possible to know if the screensaver is active or not and this could be used to control recording of images to disk.

So I looked at the code for motion and it did not seem like it would be too hard to issue a system command somewhere in the main motion loop. The system command could run the screensaver query and return a true or false result. Then if the result of the system command was false, abort processing until the next time to check for a new image.

I just could not decide exactly where to insert this test. The main loop is a fairly large subroutine and I saw several places that might work but could not decide which was the best place.

-- StevenSnelgrove - 24 Jan 2014

Follow up


Maybe I can get this to work using the start and stop features in the web interface.

-- StevenSnelgrove - 24 Jan 2014

Yes, this worked.

Here is the configuration setup for blueproximity to cause it to work with motion.

Get blueproximity from sourceforge.

Note that when your run blueproximity the first time from the menu, it will pop a config dialog. The next time you run, it sees that there is already a config and will not raise the config. Instead, when running there will be a minimized icon on the status bar. Click this to raise the config dialog. If you edit the config file directly, the program should be stopped as the files are not read again when the config is raised.

The config is in the .blueproximity directory in the user's home directory. I have built shell scripts in order to do more commands than space would allow in the normal interface.

-----> ls standard.conf

-----> ls -l
total 16K
-rwxr-xr-x 1 sls sls 361 Jan 24 13:55
-rwxr-xr-x 1 sls sls 625 Jan 24 14:21
-rwxr-xr-x 1 sls sls 751 Jan 24 14:20
-rw-r--r-- 1 sls sls 448 Jan 24 13:58 standard.conf



-----> cat standard.conf
device_mac = 00:25:E5:61:0F:8C
device_channel = 7
lock_distance = 7
lock_duration = 6
unlock_distance = 4
unlock_duration = 1
lock_command = /bin/bash ~/.blueproximity/
unlock_command = /bin/bash ~/.blueproximity/
proximity_command = /bin/bash ~/.blueproximity/
proximity_interval = 5
buffer_size = 1
log_to_syslog = False
log_syslog_facility = local6
log_to_file = True
log_filelog_filename = /home/sls/blueproximity.log



-----> cat

# Executed when the bluetooth connection drops because the paired device is out of range

echo "Away from desk" >> ~/blueproximity.log

# Start the screensaver and lock the screen
gnome-screensaver-command --lock

# Tell motion to start recording, 0 is the first thread index
curl http://localhost:8080/0/detection/start >/dev/null 2>&1



-----> cat

# Executed when blueproximity detects a bluetooth connection with the paired device

echo "Back at desk" >> ~/blueproximity.log

# Tell motion to stop recording, 0 is the first thread index
curl http://localhost:8080/0/detection/pause >/dev/null 2>&1

# Turn off the screensaver and unlock
gnome-screensaver-command -d

# Turning off the screensaver does not unblank the screen
# Simulate a mouse move to get xorg to reset the activity counter
# and do the right thing about power management
# This works but leaves the mouse in upper left corner of screen
xdotool mousemove 0 0
xdotool mousemove 5 5



-----> cat

# This is a keep-alive command to make sure the screen does not lock while we are present
# Note that this runs even when the screen is locked

# The default configuration had the command "gnome-screensave-command -p" for poke.
# However, my version of this command (Mint) does not implement poke.
# So use the xdotool command instead

#echo "Proximity command invoked, do nothing" >> ~/blueproximity.log

# This works but is a little bad because it may move the mouse while you are working with it
# It is also bad because when the screen is locked and then goes blanked, doing the poke will
# unblank the screen. Probably not what is wanted. So for now, do nothing.
# There has to be a better way!
#xdotool mousemove 0 0

-- StevenSnelgrove - 24 Jan 2014

Topic revision: r3 - 24 Jan 2014, StevenSnelgrove
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.