File: webcam.sh

package info (click to toggle)
vgrabbj 0.9.9-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid
  • size: 760 kB
  • sloc: ansic: 2,703; sh: 1,244; makefile: 29
file content (26 lines) | stat: -rw-r--r-- 677 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
# Amaya Rodrigo sastre <amaya@debian.org>, 15 Jan 2001
# This is free software, under the terms of the GPL v2 or later
# See http://www.gnu.org/copyleft/gpl.html
# Comments on this script are highly appreciated.

pid=`fuser /dev/video | cut -b 22-30`

# If it's not being used, we take a snapshot:
if [ "pid" != "" ]; then
	/usr/bin/vgrabbj
# If it's in use:
else
	# Find out who is using the device:
	program=`ps ax | grep $pid | grep -v grep | cut -d \/ -f 4`

	# If it's a crashed vgrabbj, we kill it and take a snapshot.
	if [ "program" = "vgrabbj" ]; then
		kill -9 $pid
		/usr/bin/vgrabbj
	# If it's another program, leave it alone:
	else
		exit 0
	fi
fi