From ce9c03b0e1ddd9fbb711ac26229e768df8b19c97 Mon Sep 17 00:00:00 2001 From: Kendall Garner <17521368+kgarner7@users.noreply.github.com> Date: Sat, 17 Feb 2024 03:55:57 +0000 Subject: [PATCH] [bugfix]: Macos trusted accessibility (#512) * [bugfix]: macos trusted accessibility * update readme --- README.md | 4 ++++ src/main/features/core/player/media-keys.ts | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 486afa8d..faa5513b 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,12 @@ Rewrite of [Sonixd](https://github.com/jeffvli/sonixd). Download the [latest desktop client](https://github.com/jeffvli/feishin/releases). The desktop client is the recommended way to use Feishin. It supports both the MPV and web player backends, as well as includes built-in fetching for lyrics. +#### MacOS Notes + If you're using a device running macOS 12 (Monterey) or higher, [check here](https://github.com/jeffvli/feishin/issues/104#issuecomment-1553914730) for instructions on how to remove the app from quarantine. +For media keys to work, you will be prompted to allow Feishin to be a Trusted Accessibility Client. After allowing, you will need to restart Feishin for the privacy settings to take effect. + ### Web and Docker Visit [https://feishin.vercel.app](https://feishin.vercel.app) to use the hosted web version of Feishin. The web client only supports the web player backend. diff --git a/src/main/features/core/player/media-keys.ts b/src/main/features/core/player/media-keys.ts index 2aefd7fd..bac8c2ca 100644 --- a/src/main/features/core/player/media-keys.ts +++ b/src/main/features/core/player/media-keys.ts @@ -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'); });