feat: enhance Whisper language selection in onboarding with auto-detect option and switch Wayland paste shortcut to Ctrl+V.
This commit is contained in:
@@ -120,18 +120,29 @@ public static class OnboardCommand
|
|||||||
.UseConverter(c => c == "whisper-large-v3" ? "whisper-large-v3 (Accurate)" : "whisper-large-v3-turbo (Fast)"));
|
.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(
|
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)
|
.DefaultValue(string.IsNullOrWhiteSpace(config.WhisperLanguage) ? "en" : config.WhisperLanguage)
|
||||||
.AllowEmpty()
|
|
||||||
.Validate(lang =>
|
.Validate(lang =>
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(lang)) return ValidationResult.Success();
|
|
||||||
if (lang.Contains(",") || lang.Contains(" "))
|
if (lang.Contains(",") || lang.Contains(" "))
|
||||||
return ValidationResult.Error("[red]Please provide only one language code (e.g., 'en' not 'en, es')[/]");
|
return ValidationResult.Error("[red]Please provide only one language code (e.g., 'en' not 'en, es')[/]");
|
||||||
|
|
||||||
return ValidationResult.Success();
|
return ValidationResult.Success();
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
config.WhisperLanguage = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var sessionType = Environment.GetEnvironmentVariable("XDG_SESSION_TYPE")?.ToLowerInvariant();
|
var sessionType = Environment.GetEnvironmentVariable("XDG_SESSION_TYPE")?.ToLowerInvariant();
|
||||||
var typingBackends = sessionType == "wayland" ? new[] { "wtype", "wl-clipboard", "ydotool" } : new[] { "xdotool", "ydotool" };
|
var typingBackends = sessionType == "wayland" ? new[] { "wtype", "wl-clipboard", "ydotool" } : new[] { "xdotool", "ydotool" };
|
||||||
|
|||||||
@@ -6,9 +6,7 @@ namespace Toak.IO.Injectors;
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Text injector that writes text to the Wayland clipboard via <c>wl-copy</c>
|
/// 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>.
|
/// and then pastes it using Ctrl+V 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.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class WlClipboardTextInjector(INotifications notifications) : ITextInjector
|
public class WlClipboardTextInjector(INotifications notifications) : ITextInjector
|
||||||
{
|
{
|
||||||
@@ -39,11 +37,11 @@ public class WlClipboardTextInjector(INotifications notifications) : ITextInject
|
|||||||
|
|
||||||
Task.Delay(100).Wait();
|
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
|
var pasteInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = Constants.Commands.TypeWayland,
|
FileName = Constants.Commands.TypeWayland,
|
||||||
Arguments = "-M shift -k Insert -m shift",
|
Arguments = "-M ctrl -k v -m ctrl",
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
CreateNoWindow = true
|
CreateNoWindow = true
|
||||||
};
|
};
|
||||||
@@ -91,11 +89,11 @@ public class WlClipboardTextInjector(INotifications notifications) : ITextInject
|
|||||||
|
|
||||||
await Task.Delay(100);
|
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
|
var pasteInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = Constants.Commands.TypeWayland,
|
FileName = Constants.Commands.TypeWayland,
|
||||||
Arguments = "-M shift -k Insert -m shift",
|
Arguments = "-M ctrl -k v -m ctrl",
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
CreateNoWindow = true
|
CreateNoWindow = true
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user