diff options
Diffstat (limited to 'SpacebarDiscordDesktopLauncher/LinuxDiscordClientFinder.cs')
-rw-r--r-- | SpacebarDiscordDesktopLauncher/LinuxDiscordClientFinder.cs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/SpacebarDiscordDesktopLauncher/LinuxDiscordClientFinder.cs b/SpacebarDiscordDesktopLauncher/LinuxDiscordClientFinder.cs new file mode 100644 index 0000000..f986c51 --- /dev/null +++ b/SpacebarDiscordDesktopLauncher/LinuxDiscordClientFinder.cs @@ -0,0 +1,23 @@ +namespace SpacebarDiscordDesktopLauncher; + +public class LinuxDiscordClientFinder +{ + public static string? FindDiscord() + { + Console.WriteLine($"Looking for installed Discord desktop instance..."); + + var pathDirectories = Environment.GetEnvironmentVariable("PATH")!.Split(':'); + foreach (var pathDirectory in pathDirectories) + { + if (!Directory.Exists(pathDirectory)) continue; + foreach (var file in Directory.GetFiles(pathDirectory)) + { + var fileInfo = new FileInfo(file); + if (fileInfo.Name.ToLower().StartsWith("discord")) + return fileInfo.FullName; + } + } + + return null; + } +} \ No newline at end of file |