Skip to content

Commit

Permalink
feat(Application Search): Linux Support (#1078)
Browse files Browse the repository at this point in the history
* Added support for Linux in Application Search

* Commit to restart pull request

* Added support for Linux in Application Search

* Commit to restart pull request

* App search functional in dev build

* Added Linux support

* Fix formatting

* Fixed conflict and combined Linux icon generators

* Addressed code review feedback

* Moved GtkLaunchActionHandler to extension folder

* Added test

* Fixed typecheck issue

* Moved createGtkLaunchAction to extension folder

* Removed duplicated functions

* Fixed race conditions in Linux Icon extractor

* Refactor Linux app search to use native filesystem

* Forgot to stage files for previous commit

* Use more accurate class name

* Use EnvironmentVariableProvider

* Moved LinuxAppIconExtractor into Linux folder

* fix: prettier formatting

* Changed GtkLaunch to LaunchDesktopFile

* Use more accurate property name

* Only export needed files

* Use more accurate property name

* Added @ke1v as code owner of linux part of ApplicationSearch extension

* Use more accurate property name

* Import type only

* Simplified code

* Added line breaks for better readabiltiy

* Only invoke operating system specific code when needed

* Added support for x-cinnamon desktop environment

* Simplified code

---------

Co-authored-by: Oliver Schwendener <oliver.schwendener@hotmail.com>
Co-authored-by: Oliver Schwendener <oliver.schwendener@proton.me>
  • Loading branch information
3 people authored May 11, 2024
1 parent 2b71b96 commit 7e42f5b
Show file tree
Hide file tree
Showing 25 changed files with 1,022 additions and 59 deletions.
8 changes: 3 additions & 5 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ src/main/Core/IniFileParser @ke1v

# Extensions

# [EXAMPLE] ApplicationSearch
assets/Extensions/ApplicationSearch @oliverschwendener
src/common/Extensions/ApplicationSearch @oliverschwendener
src/main/Extensions/ApplicationSearch @oliverschwendener
src/renderer/Extensions/ApplicationSearch @oliverschwendener
# ApplicationSearch
src/main/Extensions/ApplicationSearch/Linux @ke1v
src/renderer/Extensions/ApplicationSearch/Linux @ke1v
3 changes: 3 additions & 0 deletions assets/Extensions/ApplicationSearch/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"linux-applications.png" and "linux-generic-app-icon.png" by GNOME Project
(http://www.gnome.org) is licensed under CC BY-SA 3.0
(https://creativecommons.org/licenses/by-sa/3.0/)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface FileSystemUtility {
readTextFile(filePath: string): Promise<string>;
readJsonFile<T>(filePath: string): Promise<T>;
readJsonFileSync<T>(filePath: string): T;
readDirectory(folderPath: string): Promise<string[]>;
removeFile(filePath: string): Promise<void>;
writeTextFile(data: string, filePath: string): Promise<void>;
writeJsonFile<T>(data: T, filePath: string): Promise<void>;
Expand Down
2 changes: 1 addition & 1 deletion src/main/Core/FileSystemUtility/NodeJsFileSystemUtility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class NodeJsFileSystemUtility implements FileSystemUtility {
return (await this.readFile(filePath)).toString();
}

private readDirectory(folderPath: string): Promise<string[]> {
public async readDirectory(folderPath: string): Promise<string[]> {
return new Promise((resolve, reject) => {
readdir(folderPath, (error, fileNames) => {
if (error) {
Expand Down
14 changes: 13 additions & 1 deletion src/main/Core/ImageGenerator/ImageGeneratorModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { CacheFileNameGenerator } from "./CacheFileNameGenerator";
import type { FileIconExtractor } from "./FileIconExtractor";
import { FileImageGenerator } from "./FileImageGenerator";
import { GenericFileIconExtractor } from "./GenericFileIconExtractor";
import { LinuxAppIconExtractor } from "./Linux";
import { UrlImageGenerator } from "./UrlImageGenerator";
import { WindowsApplicationIconExtractor, WindowsFolderIconExtractor } from "./Windows";
import { MacOsApplicationIconExtractor, MacOsFolderIconExtractor } from "./macOS";
Expand Down Expand Up @@ -47,7 +48,18 @@ export class ImageGeneratorModule {
// To prevent the execution of all icon extractor constructors, we use a function here that is only invoked
// for the current operating system.
const operatingSystemSpecificIconExtractors: Record<OperatingSystem, () => FileIconExtractor[]> = {
Linux: () => [],
Linux: () => [
new LinuxAppIconExtractor(
dependencyRegistry.get("FileSystemUtility"),
dependencyRegistry.get("CommandlineUtility"),
dependencyRegistry.get("IniFileParser"),
dependencyRegistry.get("Logger"),
cacheFileNameGenerator,
cacheFolderPath,
dependencyRegistry.get("App").getPath("home"),
dependencyRegistry.get("EnvironmentVariableProvider"),
),
],
macOS: () => [
new MacOsFolderIconExtractor(
dependencyRegistry.get("AssetPathResolver"),
Expand Down
Loading

0 comments on commit 7e42f5b

Please sign in to comment.