1
0

feat: enhance Whisper language selection in onboarding with auto-detect option and switch Wayland paste shortcut to Ctrl+V.

This commit is contained in:
2026-03-03 12:28:09 +01:00
parent 9bf72169db
commit 91638940ff
2 changed files with 27 additions and 18 deletions

View File

@@ -120,18 +120,29 @@ public static class OnboardCommand
.UseConverter(c => c == "whisper-large-v3" ? "whisper-large-v3 (Accurate)" : "whisper-large-v3-turbo (Fast)"));
}
var langChoice = AnsiConsole.Prompt(
new SelectionPrompt<string>()
.Title("Select [green]Spoken Language[/] for Whisper:")
.AddChoices(new[] { "Auto-detect (multilingual)", "Specify language code" })
.UseConverter(c => c));
if (langChoice == "Specify language code")
{
config.WhisperLanguage = AnsiConsole.Prompt(
new TextPrompt<string>("Microphone Spoken Language (e.g. en, es, zh):")
new TextPrompt<string>("Language code (e.g. en, es, zh, de):")
.DefaultValue(string.IsNullOrWhiteSpace(config.WhisperLanguage) ? "en" : config.WhisperLanguage)
.AllowEmpty()
.Validate(lang =>
{
if (string.IsNullOrWhiteSpace(lang)) return ValidationResult.Success();
if (lang.Contains(",") || lang.Contains(" "))
return ValidationResult.Error("[red]Please provide only one language code (e.g., 'en' not 'en, es')[/]");
return ValidationResult.Success();
}));
}
else
{
config.WhisperLanguage = string.Empty;
}
var sessionType = Environment.GetEnvironmentVariable("XDG_SESSION_TYPE")?.ToLowerInvariant();
var typingBackends = sessionType == "wayland" ? new[] { "wtype", "wl-clipboard", "ydotool" } : new[] { "xdotool", "ydotool" };

View File

@@ -6,9 +6,7 @@ namespace Toak.IO.Injectors;
/// <summary>
/// Text injector that writes text to the Wayland clipboard via <c>wl-copy</c>
/// and then pastes it using Shift+Insert via <c>wtype</c>.
/// Whitespace-only content is typed directly with <c>wtype</c> to avoid
/// wl-copy silently stripping leading/trailing spaces from clipboard content.
/// and then pastes it using Ctrl+V via <c>wtype</c>.
/// </summary>
public class WlClipboardTextInjector(INotifications notifications) : ITextInjector
{
@@ -39,11 +37,11 @@ public class WlClipboardTextInjector(INotifications notifications) : ITextInject
Task.Delay(100).Wait();
// Simulate Shift+Insert to paste into the focused window
// Simulate Ctrl+V to paste into the focused window
var pasteInfo = new ProcessStartInfo
{
FileName = Constants.Commands.TypeWayland,
Arguments = "-M shift -k Insert -m shift",
Arguments = "-M ctrl -k v -m ctrl",
UseShellExecute = false,
CreateNoWindow = true
};
@@ -91,11 +89,11 @@ public class WlClipboardTextInjector(INotifications notifications) : ITextInject
await Task.Delay(100);
// Simulate Shift+Insert to paste into the focused window
// Simulate Ctrl+V to paste into the focused window
var pasteInfo = new ProcessStartInfo
{
FileName = Constants.Commands.TypeWayland,
Arguments = "-M shift -k Insert -m shift",
Arguments = "-M ctrl -k v -m ctrl",
UseShellExecute = false,
CreateNoWindow = true
};