From 912dce87ee3280aa9f093d000eade3223e459b99 Mon Sep 17 00:00:00 2001 From: xzl Date: Fri, 30 Aug 2024 17:45:42 +0800 Subject: [PATCH 1/3] feat: use default terminal or common terminal --- UotanToolbox/MainView.axaml.cs | 56 ++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/UotanToolbox/MainView.axaml.cs b/UotanToolbox/MainView.axaml.cs index ca67e836..0bdaa53b 100644 --- a/UotanToolbox/MainView.axaml.cs +++ b/UotanToolbox/MainView.axaml.cs @@ -39,28 +39,58 @@ private void InputElement_OnPointerPressed(object sender, PointerPressedEventArg } private void OpenTerminal(object sender, RoutedEventArgs e) +{ + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - 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)) + Process.Start(new ProcessStartInfo + { + FileName = "cmd.exe", + WorkingDirectory = Path.Combine(Global.bin_path, "platform-tools"), + UseShellExecute = true + }); + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + 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) + { try { Process.Start(new ProcessStartInfo { - FileName = "/usr/bin/gnome-terminal", + FileName = terminal, Arguments = $"--working-directory={Path.Combine(Global.bin_path, "platform-tools", "adb")}", UseShellExecute = false }); + break; // If successful, break out of the loop + } + catch + { + // 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")); + } } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + Process.Start("open", "-a Terminal " + Path.Combine(Global.bin_path, "platform-tools", "adb")); + } +} + private void InitializeComponent() { @@ -72,4 +102,4 @@ private void InitializeComponent() Settings.Default.Save(); }; } -} \ No newline at end of file +} From 1d1faa10f1c3bbccbde208b08331cb55fa5145a2 Mon Sep 17 00:00:00 2001 From: yuzh <46953451+yuzh0816@users.noreply.github.com> Date: Fri, 30 Aug 2024 18:13:22 +0800 Subject: [PATCH 2/3] Update MainView.axaml.cs --- UotanToolbox/MainView.axaml.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UotanToolbox/MainView.axaml.cs b/UotanToolbox/MainView.axaml.cs index 0bdaa53b..2282731a 100644 --- a/UotanToolbox/MainView.axaml.cs +++ b/UotanToolbox/MainView.axaml.cs @@ -62,8 +62,8 @@ private void OpenTerminal(object sender, RoutedEventArgs e) "lxterminal", // LXDE terminal "tilix", // Tilix terminal "alacritty", // Alacritty terminal - "xterm" // Xterm as fallback - "kitty" // Kitty terminal + "xterm", // Xterm as fallback + "kitty", // Kitty terminal "wezterm" // Wezterm terminal }; From e7bb2a6392e74f3b651147367f4013571d978f60 Mon Sep 17 00:00:00 2001 From: yuzh <46953451+yuzh0816@users.noreply.github.com> Date: Fri, 30 Aug 2024 18:20:26 +0800 Subject: [PATCH 3/3] Update MainView.axaml.cs --- UotanToolbox/MainView.axaml.cs | 61 +++++++++++++++++----------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/UotanToolbox/MainView.axaml.cs b/UotanToolbox/MainView.axaml.cs index 2282731a..0c885449 100644 --- a/UotanToolbox/MainView.axaml.cs +++ b/UotanToolbox/MainView.axaml.cs @@ -39,20 +39,20 @@ private void InputElement_OnPointerPressed(object sender, PointerPressedEventArg } private void OpenTerminal(object sender, RoutedEventArgs e) -{ - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - Process.Start(new ProcessStartInfo + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - FileName = "cmd.exe", - WorkingDirectory = Path.Combine(Global.bin_path, "platform-tools"), - UseShellExecute = true - }); - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - string[] terminalCommands = new string[] + Process.Start(new ProcessStartInfo + { + FileName = "cmd.exe", + WorkingDirectory = Path.Combine(Global.bin_path, "platform-tools"), + UseShellExecute = true + }); + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { + string[] terminalCommands = new string[] + { "x-terminal-emulator", // Generic terminal emulator "gnome-terminal", // GNOME terminal "deepin-terminal", // deepin terminal @@ -65,32 +65,31 @@ private void OpenTerminal(object sender, RoutedEventArgs e) "xterm", // Xterm as fallback "kitty", // Kitty terminal "wezterm" // Wezterm terminal - }; + }; - foreach (var terminal in terminalCommands) - { - try + foreach (var terminal in terminalCommands) { - Process.Start(new ProcessStartInfo + try { - FileName = terminal, - Arguments = $"--working-directory={Path.Combine(Global.bin_path, "platform-tools", "adb")}", - UseShellExecute = false - }); - break; // If successful, break out of the loop - } - catch - { - // Continue trying other terminals if one fails + 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 + { + // Continue trying other terminals if one fails + } } } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + Process.Start("open", "-a Terminal " + Path.Combine(Global.bin_path, "platform-tools", "adb")); + } } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - Process.Start("open", "-a Terminal " + Path.Combine(Global.bin_path, "platform-tools", "adb")); - } -} - private void InitializeComponent() {