Skip to content

Loading…

Slight change to the way the video device use is determined #35

Merged
merged 1 commit into from

2 participants

@mjbrooks

The original CAM=lsof $CAMERA worked fine until I found out
that Bodhi Linux (and therefore perhaps others) returned quite
a few processes. So we are more acurate with this test and are
looking specifically for the 'mem' File Descriptor (FD) being
listed in the return of lsof

Tested on: Ubuntu 12.04, 12.10 and Bodhi 2.1.0

For reference. here's the output of lsof on Bodhi Linux with the
webcam in use as indicated by the 4th entry where the FD column
shows 'mem':

mjbrooks@dharma: ~ $ lsof /dev/video0
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
enlighten 2642 mjbrooks 13r CHR 81,0 0t0 10634 /dev/video0
nm-applet 2710 mjbrooks 13r CHR 81,0 0t0 10634 /dev/video0
pithos 2711 mjbrooks 13r CHR 81,0 0t0 10634 /dev/video0
skype 2712 mjbrooks mem CHR 81,0 10634 /dev/video0
skype 2712 mjbrooks 13r CHR 81,0 0t0 10634 /dev/video0
skype 2712 mjbrooks 66u CHR 81,0 0t0 10634 /dev/video0
remmina 2713 mjbrooks 13r CHR 81,0 0t0 10634 /dev/video0
enlighten 2722 mjbrooks 13r CHR 81,0 0t0 10634 /dev/video0
terminolo 5005 mjbrooks 13r CHR 81,0 0t0 10634 /dev/video0
chrome 6618 mjbrooks 13r CHR 81,0 0t0 10634 /dev/video0
chrome 6623 mjbrooks 13r CHR 81,0 0t0 10634 /dev/video0
terminolo 8241 mjbrooks 13r CHR 81,0 0t0 10634 /dev/video0

It's not entirely clear why it's retuning these on Bodhi when Ubuntu
does not since Bodhi Linux is based on Ubuntu. Perhaps it's just
how e17 does things.

@mjbrooks mjbrooks Slight change to the way the video device use is determined
The original CAM=`lsof $CAMERA` worked fine until I found out
that Bodhi Linux (and therefore perhaps others) returned quite
a few processes. So we are more acurate with this test and are
looking specifically for the 'mem' File Descriptor (FD) being
listed in the return of lsof

Tested on: Ubuntu 12.04, 12.10 and Bodhi 2.1.0

For reference. here's the output of lsof on Bodhi Linux with the
webcam in use as indicated by the 4th entry where the FD column
shows 'mem':

mjbrooks@dharma: ~ $ lsof /dev/video0
COMMAND    PID     USER   FD   TYPE DEVICE SIZE/OFF  NODE NAME
enlighten 2642 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0
nm-applet 2710 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0
pithos    2711 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0
skype     2712 mjbrooks  mem    CHR   81,0          10634 /dev/video0
skype     2712 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0
skype     2712 mjbrooks   66u   CHR   81,0      0t0 10634 /dev/video0
remmina   2713 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0
enlighten 2722 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0
terminolo 5005 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0
chrome    6618 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0
chrome    6623 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0
terminolo 8241 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0

It's not entirely clear why it's retuning these on Bodhi when Ubuntu
does not since Bodhi Linux is based on Ubuntu. Perhaps it's just
how e17 does things.
d5beaef
@todbot todbot merged commit 450b94c into todbot:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 1, 2013
  1. @mjbrooks

    Slight change to the way the video device use is determined

    mjbrooks committed
    The original CAM=`lsof $CAMERA` worked fine until I found out
    that Bodhi Linux (and therefore perhaps others) returned quite
    a few processes. So we are more acurate with this test and are
    looking specifically for the 'mem' File Descriptor (FD) being
    listed in the return of lsof
    
    Tested on: Ubuntu 12.04, 12.10 and Bodhi 2.1.0
    
    For reference. here's the output of lsof on Bodhi Linux with the
    webcam in use as indicated by the 4th entry where the FD column
    shows 'mem':
    
    mjbrooks@dharma: ~ $ lsof /dev/video0
    COMMAND    PID     USER   FD   TYPE DEVICE SIZE/OFF  NODE NAME
    enlighten 2642 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0
    nm-applet 2710 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0
    pithos    2711 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0
    skype     2712 mjbrooks  mem    CHR   81,0          10634 /dev/video0
    skype     2712 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0
    skype     2712 mjbrooks   66u   CHR   81,0      0t0 10634 /dev/video0
    remmina   2713 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0
    enlighten 2722 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0
    terminolo 5005 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0
    chrome    6618 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0
    chrome    6623 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0
    terminolo 8241 mjbrooks   13r   CHR   81,0      0t0 10634 /dev/video0
    
    It's not entirely clear why it's retuning these on Bodhi when Ubuntu
    does not since Bodhi Linux is based on Ubuntu. Perhaps it's just
    how e17 does things.
Showing with 11 additions and 3 deletions.
  1. +11 −3 linux/contrib/blink1-webcam-busylight.sh
View
14 linux/contrib/blink1-webcam-busylight.sh
@@ -76,17 +76,25 @@ trap cleanup SIGINT SIGTERM
#infinite loop, stop with CTRL-c
while true; do
- CAM=`lsof $CAMERA`;
+ # Check the video device and determine if it is being used
+ #
+ # The original CAM=`lsof $CAMERA` worked fine until I found
+ # out that Bodhi Linux (and therefore perhaps others)
+ # returned quite a few processes. So we are more acurate with
+ # this test and are looking specifically for the 'mem' File
+ # Descriptor (FD) being listed in the return of lsof
+ CAM=`lsof $CAMERA | awk '{print $4}' | grep 'mem' | wc -l`
+
# If the camera is in use and we're not already "busy"
- if [[ $CAM && $BUSY -eq 0 ]]; then
+ if [[ $CAM -ne 0 && $BUSY -eq 0 ]]; then
BUSY=1 # We're busy now, so...
# set the Blink(1) to COLOR_CAM
$TOOL --rgb $COLOR_CAM > /dev/null 2>&1
# Otherwise if the camera is not on,
# check if the microphone is being used
- elif [[ ! $CAM ]]; then
+ elif [[ $CAM -eq 0 ]]; then
MIC=`lsof $MICROPHONE`
# If the microphone is being used and we're not already "busy"
Something went wrong with that request. Please try again.