From 7e342008c70a4510affbe764b10d7892c3213e38 Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Thu, 27 Jun 2024 04:14:49 +0100 Subject: [PATCH] fix: find supported terminal on operating systems other than Debian. closes #61 The implementation of `_getTerminalEmulator` is specific to Debian-based systems, as it relies on the `x-terminal-emulator` symbolic link. This link does not exist on other Linux distributions or on macOS. This patch first tries to find the `x-terminal-emulator` symbolic link. If it doesn't exist or returns an empty string, it then iterates over a list of supported terminal emulators and uses the `whichSync` function to check if they exist in the PATH. It sets `_terminalEmulator` to the first terminal emulator it finds in the PATH. --- lib/src/pages/manager.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/src/pages/manager.dart b/lib/src/pages/manager.dart index 1cda222..e25b73b 100644 --- a/lib/src/pages/manager.dart +++ b/lib/src/pages/manager.dart @@ -89,6 +89,18 @@ class _ManagerState extends State with PreferencesMixin { _terminalEmulator = path.basename(terminalEmulator); }); } + } else { + // If x-terminal-emulator doesn't exist or returns empty, look for + // supported terminals in the PATH + for (String terminal in _supportedTerminalEmulators) { + String? terminalPath = whichSync(terminal); + if (terminalPath != null) { + setState(() { + _terminalEmulator = terminal; + }); + break; + } + } } }