Skip to content

Instantly share code, notes, and snippets.

@skwirrel
Created May 14, 2020 07:44
Show Gist options
  • Save skwirrel/4fdbd25407c560e78b13973e7d76a94e to your computer and use it in GitHub Desktop.
Save skwirrel/4fdbd25407c560e78b13973e7d76a94e to your computer and use it in GitHub Desktop.
This is a simple script to create a log of Zoom activity on a Linux machine
#!/usr/bin/php
<?php
/*
MIT License
Copyright (c) Ben Jefferson 2020
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Introduction
============
As a freelancer I need to bill for my time. Since a lot of my time is not spent in Zoom meetings I wanted
something to automatically record this for me so that my billing is accurate.
This is a simple script to create a log of Zoom activity.
Output
======
The log records each meeting (once it has finished). The meeting duration is rounded to the nearest 0.25 hour
Log output looks like this...
----------------------------------------
12/5/2020 0 Zoom meeting 16:51-16:57
13/5/2020 4.75 Zoom meeting 09:10-14:00
13/5/2020 0.75 Zoom meeting 15:03-15:53
13/5/2020 2 Zoom meeting 17:25-19:21
----------------------------------------
That is...
Date Duration Details
Unfortunately there is no way (that I could find) of getting hold of the meeting ID.
I found that I forgot what some meetings were about so time alone was not enough.
So.... the script now also takes 2 screenshots at 5 and 7 minutes into the meeting
to help jog my memory of who was on the call and what it was about.
Limitations
===========
- Only tested on Debian Linux. YMMV
- The screenshots only work if the Zoom window is on the active desktop
- hence the warning 10s before so you can move to that desktop
- The script uses the fact that Zoom opens the camera device to determine if you are in a meeting
- Therefore if you join audio-only the meeting will not be recorded
- No idea what happens if you have more than one camera!
*/
// ======= CONFIGURATION =========
$screenshotDir = '/home/benj/zoomScreenshots';
$logFile = '/home/benj/zoomLog.txt';
// ===== END CONFIGURATION =======
function zoomRunning() {
$pid = chop(`pidof /opt/zoom/zoom`);
$procDir = "/proc/$pid/fd";
if (!is_dir($procDir)) return false;
$dir = openDir($procDir);
clearstatcache();
$found = false;
while( ($file = readdir($dir)) !== false ) {
$filePath = $procDir.'/'.$file;
if (!is_link($filePath)) continue;
$dest = readlink($filePath);
if (strpos($dest,'/dev/video')!==0) continue;
$found = true;
break;
}
closedir($dir);
return $found;
}
$currentState = false;
$needScreenshot = 2;
while(true) {
$newState = zoomRunning();
if ($newState!=$currentState) {
if ($newState) {
$meetingStart = time();
} else {
$mins = round((time()-$meetingStart)/(60*15))*0.25;
$output = date('j/n/Y',$meetingStart)."\t".$mins."\t\tZoom meeting ".date('H:i',$meetingStart).'-'.date('H:i',time());
$output .= "\n";
file_put_contents( $output, $logFile, FILE_APPEND );
$needScreenshot = 2;
}
}
if ($newState && (time()-$meetingStart)>300 && $needScreenshot) {
//take a screenshot
`notify-send "Taking zoom screenshot in 10s"`;
sleep(10);
$screenshotFilename = sprintf('%s/%s-%d.png',$screenshotDir,date('Ymd_Hi',$meetingStart),3-$needScreenshot);
`import -screen -window 'Zoom' "$screenshotFilename"`;
`notify-send "Zoom window captured"`;
$needScreenshot--;
}
$currentState = $newState;
sleep(120);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment