diff --git a/src/main/Extensions/ApplicationSearch/ApplicationSearch.test.ts b/src/main/Extensions/ApplicationSearch/ApplicationSearch.test.ts index efaf6966d..f47af11cb 100644 --- a/src/main/Extensions/ApplicationSearch/ApplicationSearch.test.ts +++ b/src/main/Extensions/ApplicationSearch/ApplicationSearch.test.ts @@ -134,6 +134,7 @@ describe(ApplicationSearch, () => { getExtensionSettingKey("ApplicationSearch", "windowsFileExtensions"), getExtensionSettingKey("ApplicationSearch", "includeWindowsStoreApps"), getExtensionSettingKey("ApplicationSearch", "macOsFolders"), + getExtensionSettingKey("ApplicationSearch", "mdfindFilterOption"), ]); }); }); diff --git a/src/main/Extensions/ApplicationSearch/ApplicationSearch.ts b/src/main/Extensions/ApplicationSearch/ApplicationSearch.ts index 93ec7eccd..c79183228 100644 --- a/src/main/Extensions/ApplicationSearch/ApplicationSearch.ts +++ b/src/main/Extensions/ApplicationSearch/ApplicationSearch.ts @@ -46,6 +46,7 @@ export class ApplicationSearch implements Extension { getExtensionSettingKey("ApplicationSearch", "windowsFileExtensions"), getExtensionSettingKey("ApplicationSearch", "includeWindowsStoreApps"), getExtensionSettingKey("ApplicationSearch", "macOsFolders"), + getExtensionSettingKey("ApplicationSearch", "mdfindFilterOption"), ]; } @@ -69,6 +70,7 @@ export class ApplicationSearch implements Extension { openApplication: "Open application", openApplicationAsAdministrator: "Open application as administrator", copyFilePathToClipboard: "Copy file path to clipboard", + advanced: "Advanced", }, "de-CH": { extensionName: "Anwendungssuche", @@ -76,6 +78,7 @@ export class ApplicationSearch implements Extension { openApplication: "Anwendung starten", openApplicationAsAdministrator: "Anwendung als Administrator starten", copyFilePathToClipboard: "Dateipfad in Zwischenablage kopieren", + advanced: "Erweitert", }, }; } diff --git a/src/main/Extensions/ApplicationSearch/Settings.ts b/src/main/Extensions/ApplicationSearch/Settings.ts index ea845f1a6..d3caedbff 100644 --- a/src/main/Extensions/ApplicationSearch/Settings.ts +++ b/src/main/Extensions/ApplicationSearch/Settings.ts @@ -27,6 +27,7 @@ export class Settings { "/Applications", join(this.app.getPath("home"), "Applications"), ], + mdfindFilterOption: "kMDItemKind=='Application'", includeWindowsStoreApps: true, windowsFileExtensions: ["lnk"], windowsFolders: [ diff --git a/src/main/Extensions/ApplicationSearch/macOS/MacOsApplicationRepository.ts b/src/main/Extensions/ApplicationSearch/macOS/MacOsApplicationRepository.ts index 0a059a47d..f76d6fe34 100644 --- a/src/main/Extensions/ApplicationSearch/macOS/MacOsApplicationRepository.ts +++ b/src/main/Extensions/ApplicationSearch/macOS/MacOsApplicationRepository.ts @@ -34,7 +34,7 @@ export class MacOsApplicationRepository implements ApplicationRepository { } private async getAllFilePaths(): Promise { - return (await this.commandlineUtility.executeCommand(`mdfind "kMDItemKind == 'Application'"`)) + return (await this.commandlineUtility.executeCommand(`mdfind "${this.getMdFindFilterOption()}"`)) .split("\n") .map((filePath) => normalize(filePath).trim()) .filter((filePath) => filePath.endsWith(".app")) @@ -43,6 +43,20 @@ export class MacOsApplicationRepository implements ApplicationRepository { .filter((filePath) => ![".", ".."].includes(filePath)); } + private getMdFindFilterOption() { + const filterOptions: Record = { + "kind:application": "kind:application", + "kMDItemKind=='Application'": "kMDItemKind == 'Application'", + "kMDItemContentType=='com.apple.application-bundle'": + "kMDItemContentType == 'com.apple.application-bundle'", + }; + + return ( + filterOptions[this.settings.getValue("mdfindFilterOption")] ?? + filterOptions[this.settings.getDefaultValue("mdfindFilterOption")] + ); + } + private filterFilePathByConfiguredFolders(filePath: string): boolean { return this.settings.getValue("macOsFolders").some((folderPath) => filePath.startsWith(folderPath)); } diff --git a/src/renderer/Extensions/ApplicationSearch/MacOs/MacOsSettings.tsx b/src/renderer/Extensions/ApplicationSearch/MacOs/MacOsSettings.tsx index c0b2e9416..6abc5485c 100644 --- a/src/renderer/Extensions/ApplicationSearch/MacOs/MacOsSettings.tsx +++ b/src/renderer/Extensions/ApplicationSearch/MacOs/MacOsSettings.tsx @@ -1,9 +1,11 @@ import { useContextBridge, useExtensionSetting } from "@Core/Hooks"; +import { Setting } from "@Core/Settings/Setting"; import { SettingGroup } from "@Core/Settings/SettingGroup"; import { SettingGroupList } from "@Core/Settings/SettingGroupList"; -import { Button, Input, Tooltip } from "@fluentui/react-components"; +import { Button, Dropdown, Input, Option, Tooltip } from "@fluentui/react-components"; import { AddRegular, DismissRegular, FolderRegular } from "@fluentui/react-icons"; import { useState } from "react"; +import { useTranslation } from "react-i18next"; export const MacOsSettings = () => { const { contextBridge } = useContextBridge(); @@ -12,11 +14,18 @@ export const MacOsSettings = () => { const [newFolder, setNewFolder] = useState(""); + const { t } = useTranslation(`extension[${extensionId}]`); + const { value: folders, updateValue: setFolders } = useExtensionSetting({ extensionId, key: "macOsFolders", }); + const { value: mdfindFilterOption, updateValue: updateMdfindFilterOption } = useExtensionSetting({ + extensionId, + key: "mdfindFilterOption", + }); + const removeFolder = async (indexToRemove: number) => { await setFolders(folders.filter((_, index) => index !== indexToRemove)); }; @@ -82,6 +91,29 @@ export const MacOsSettings = () => { /> + + { + if (optionValue) { + updateMdfindFilterOption(optionValue); + } + }} + > + + + + + } + /> + ); };