[bugfix]: Macos trusted accessibility (#512)

* [bugfix]: macos trusted accessibility

* update readme
This commit is contained in:
Kendall Garner 2024-02-17 03:55:57 +00:00 committed by GitHub
parent 1e5d446ced
commit ce9c03b0e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View file

@ -1,7 +1,26 @@
/* eslint-disable promise/always-return */
import { BrowserWindow, globalShortcut } from 'electron';
import { BrowserWindow, globalShortcut, systemPreferences } from 'electron';
import { isMacOS } from '../../../utils';
import { store } from '../settings';
export const enableMediaKeys = (window: BrowserWindow | null) => {
if (isMacOS()) {
const shouldPrompt = store.get('should_prompt_accessibility', true) as boolean;
const trusted = systemPreferences.isTrustedAccessibilityClient(shouldPrompt);
if (shouldPrompt) {
store.set('should_prompt_accessibility', false);
}
if (!trusted) {
window?.webContents.send('toast-from-main', {
message:
'Feishin is not a trusted accessibility client. Media keys will not work until this setting is changed',
type: 'warning',
});
}
}
globalShortcut.register('MediaStop', () => {
window?.webContents.send('renderer-player-stop');
});