Show a modal for macOS media permissions

This commit is contained in:
Fedor Indutny 2025-02-27 11:09:06 -08:00 committed by GitHub
parent 71dea5cbf3
commit 0c875b444b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 461 additions and 14 deletions

View file

@ -2988,12 +2988,32 @@ async function ensureFilePermissions(onlyFiles?: Array<string>) {
ipc.handle('get-media-access-status', async (_event, value) => {
// This function is not supported on Linux
if (!systemPreferences.getMediaAccessStatus) {
return undefined;
return 'unknown';
}
return systemPreferences.getMediaAccessStatus(value);
});
ipc.handle(
'open-system-media-permissions',
async (_event, mediaType: 'camera' | 'microphone') => {
if (!OS.isMacOS()) {
return;
}
if (mediaType === 'camera') {
await shell.openExternal(
'x-apple.systempreferences:com.apple.preference.security?Privacy_Camera'
);
} else if (mediaType === 'microphone') {
await shell.openExternal(
'x-apple.systempreferences:com.apple.preference.security?Privacy_Microphone'
);
} else {
throw missingCaseError(mediaType);
}
}
);
ipc.handle('get-auto-launch', async () => {
return app.getLoginItemSettings(await getDefaultLoginItemSettings())
.openAtLogin;