Skip to content

Commit

Permalink
Merge pull request #36 from xzl01/main
Browse files Browse the repository at this point in the history
feat: use default terminal or common terminal
  • Loading branch information
yuzh0816 authored Aug 30, 2024
2 parents 5801091 + e7bb2a6 commit bf08607
Showing 1 changed file with 37 additions and 8 deletions.
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();
};
}
}
}

0 comments on commit bf08607

Please sign in to comment.