diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-12-09 02:58:11 +0100 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-12-09 02:58:47 +0100 |
commit | 959e18046d6ec0bc9eefc8efd9b136cb14314af6 (patch) | |
tree | 76a30a39ccce380ee79bc79f4c96dfd35c44a6e9 /SpacebarDiscordDesktopLauncher/LinuxDiscordClientFinder.cs | |
download | SpacebarDiscordDesktopLauncher-959e18046d6ec0bc9eefc8efd9b136cb14314af6.tar.xz |
Initial commit
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 |