diff --git a/lib/api/wsl.dart b/lib/api/wsl.dart index c0ba528..a2ebb02 100644 --- a/lib/api/wsl.dart +++ b/lib/api/wsl.dart @@ -12,6 +12,7 @@ import 'package:wsl2distromanager/api/safe_paths.dart'; import 'package:wsl2distromanager/components/constants.dart'; import 'package:wsl2distromanager/components/helpers.dart'; import 'package:wsl2distromanager/components/logging.dart'; +import 'package:wsl2distromanager/components/notify.dart'; /// Used to store the instances of WSL in a list. class Instances { @@ -200,11 +201,19 @@ class WSLApi { mode: ProcessStartMode.normal, runInShell: true); } - /// Start Windows Terminal + /// Start Windows Terminal\ + /// *(falls back to PowerShell on exception)* void startWindowsTerminal(String distribution) async { - List args = ['wt', 'wsl', '-d', distribution, '--cd', '~']; - Process.start('start', args, - mode: ProcessStartMode.normal, runInShell: true); + List launchWslHome = ['wsl', '-d', distribution, '--cd', '~']; + try { + await Process.start('wt', launchWslHome); + } catch (_) { + // Windows Terminal not installed + Notify.message('openwithwt-not-found-error'.i18n()); + + var args = ['powershell', '-noexit', '-command', launchWslHome.join(' ')]; + await Process.run('start', args, runInShell: true); + } } /// Copy a WSL distro by name diff --git a/lib/i18n/de.json b/lib/i18n/de.json index 53a1831..29e38d8 100644 --- a/lib/i18n/de.json +++ b/lib/i18n/de.json @@ -8,6 +8,7 @@ "started-text": "gestartet", "openwithexplorer-text": "Mit Datei-Explorer öffnen", "openwithwt-text": "Mit Windows-Terminal öffnen", + "openwithwt-not-found-error": "Windows Terminal nicht gefunden. Wird im PowerShell geöffnet.", "openwithvscode-text": "Mit VS-Code öffnen", "copy-text": "Kopieren", "rename-text": "Umbenennen", diff --git a/lib/i18n/en.json b/lib/i18n/en.json index 8ee759b..5c04cd8 100644 --- a/lib/i18n/en.json +++ b/lib/i18n/en.json @@ -8,6 +8,7 @@ "started-text": "started", "openwithexplorer-text": "Open with File Explorer", "openwithwt-text": "Open with Windows Terminal", + "openwithwt-not-found-error": "Windows Terminal not found. Launching in PowerShell instead.", "openwithvscode-text": "Open with VS Code", "copy-text": "Copy", "rename-text": "Rename",