Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use default terminal or common terminal #36

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 37 additions & 8 deletions UotanToolbox/MainView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,54 @@ private void InputElement_OnPointerPressed(object sender, PointerPressedEventArg
private void OpenTerminal(object sender, RoutedEventArgs e)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Process.Start(new ProcessStartInfo
{
FileName = "cmd.exe",
WorkingDirectory = Path.Combine(Global.bin_path, "platform-tools"),
UseShellExecute = true
});
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
try
{
string[] terminalCommands = new string[]
{
"x-terminal-emulator", // Generic terminal emulator
"gnome-terminal", // GNOME terminal
"deepin-terminal", // deepin terminal
"konsole", // KDE Konsole
"xfce4-terminal", // XFCE terminal
"mate-terminal", // MATE terminal
"lxterminal", // LXDE terminal
"tilix", // Tilix terminal
"alacritty", // Alacritty terminal
"xterm", // Xterm as fallback
"kitty", // Kitty terminal
"wezterm" // Wezterm terminal
};

foreach (var terminal in terminalCommands)
{
Process.Start(new ProcessStartInfo
try
{
Process.Start(new ProcessStartInfo
{
FileName = terminal,
Arguments = $"--working-directory={Path.Combine(Global.bin_path, "platform-tools", "adb")}",
UseShellExecute = false
});
break; // If successful, break out of the loop
}
catch
{
FileName = "/usr/bin/gnome-terminal",
Arguments = $"--working-directory={Path.Combine(Global.bin_path, "platform-tools", "adb")}",
UseShellExecute = false
});
// Continue trying other terminals if one fails
}
}
catch { }
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Process.Start("open", "-a Terminal " + Path.Combine(Global.bin_path, "platform-tools", "adb"));
}
}

private void InitializeComponent()
Expand All @@ -72,4 +101,4 @@ private void InitializeComponent()
Settings.Default.Save();
};
}
}
}
Loading