Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// apertureOpts.videoCodec = 'hevc';
// }
console.log(`Collected settings after ${(Date.now() - past) / 1000}s`);
if (hideDesktopIcons) {
await desktopIcons.hide();
}
console.log(`Hide desktop icons after ${(Date.now() - past) / 1000}s`);
if (doNotDisturb) {
wasDoNotDisturbAlreadyEnabled = await dnd.isEnabled();
if (!wasDoNotDisturbAlreadyEnabled) {
dnd.enable();
}
}
console.log(`Took care of DND after ${(Date.now() - past) / 1000}s`);
try {
await aperture.startRecording(apertureOpts);
} catch (error) {
track('recording/stopped/error');
dialog.showErrorBox('Recording error', error.message);
past = null;
return;
}
const startTime = (Date.now() - past) / 1000;
if (startTime > 3) {
apertureOpts.audioDeviceId = audioInputDeviceId;
} else {
const [defaultAudioDevice] = await audioDevices();
apertureOpts.audioDeviceId = defaultAudioDevice && defaultAudioDevice.id;
}
}
if (app.kap.settings.get('hideDesktopIcons')) {
await desktopIcons.hide();
}
if (app.kap.settings.get('doNotDisturb')) {
wasDoNotDisturbAlreadyEnabled = await doNotDisturb.isEnabled();
if (!wasDoNotDisturbAlreadyEnabled) {
doNotDisturb.enable();
}
}
try {
await aperture.startRecording(apertureOpts);
ipcRenderer.send('did-start-recording');
log(`Started recording after ${(Date.now() - past) / 1000}s`);
} catch (err) {
// This prevents the button from being reset, since the recording has not yet started
// This delay is due to internal framework delays in aperture native code
if (err.message.includes('stopRecording')) {
log(`Recording not yet started, can't stop recording before it actually started`);
return;
}
ipcRenderer.send('will-stop-recording');
(async () => {
switch (command) {
case 'on':
await doNotDisturb.enable();
break;
case 'off':
await doNotDisturb.disable();
break;
case 'toggle':
await doNotDisturb.toggle();
break;
case 'status':
console.log(await doNotDisturb.isEnabled() ? 'on' : 'off');
break;
default:
cli.showHelp();
}
})();