fix(preflight): remove keyboard layout auto-detection
- Remove detectEnvironment() and detectKeymap() functions - Remove keyboard detection from preflight Execute phase - Keyboard layout now defaults to 'us' in form, user can override - No programmatic method exists to detect loadkeys-set keyboard state
- commit
- 48f527b1bffcbc820ef1e27ae4b84769ffed71d1
- author
- bnema · · 2025-10-26 21:32 UTC
- parent
- ea9cd09
- signature
- unsigned
1 file · +1 -45
M internal/phases/preflight.go +1 -45
| @@ -73,13 +73,10 @@ func (p *PreflightPhase) PreCheck() error { | |||
| 73 | 73 | func (p *PreflightPhase) Execute(progressChan chan<- ProgressUpdate) PhaseResult { | |
| 74 | 74 | p.SendProgress(progressChan, "Running preflight checks...", 1, 2) | |
| 75 | 75 | ||
| 76 | - | // Detect environment | |
| 77 | - | p.detectEnvironment(progressChan) | |
| 78 | - | ||
| 79 | 76 | // Set defaults | |
| 80 | 77 | p.SetDefaults() | |
| 81 | 78 | ||
| 82 | - | p.SendProgress(progressChan, "Environment detected", 2, 2) | |
| 79 | + | p.SendProgress(progressChan, "Preflight checks complete", 2, 2) | |
| 83 | 80 | p.SendComplete(progressChan, "Preflight complete") | |
| 84 | 81 | ||
| 85 | 82 | return PhaseResult{ | |
| @@ -88,47 +85,6 @@ func (p *PreflightPhase) Execute(progressChan chan<- ProgressUpdate) PhaseResult | |||
| 88 | 85 | } | |
| 89 | 86 | } | |
| 90 | 87 | ||
| 91 | - | // detectEnvironment auto-detects keyboard layout and network | |
| 92 | - | func (p *PreflightPhase) detectEnvironment(progressChan chan<- ProgressUpdate) { | |
| 93 | - | p.SendOutput(progressChan, "Detecting keyboard layout...") | |
| 94 | - | ||
| 95 | - | keymap := p.detectKeymap() | |
| 96 | - | p.config.Keymap = keymap | |
| 97 | - | p.SendOutput(progressChan, fmt.Sprintf("[OK] Keyboard layout: %s", keymap)) | |
| 98 | - | } | |
| 99 | - | ||
| 100 | - | // detectKeymap detects current keyboard layout | |
| 101 | - | func (p *PreflightPhase) detectKeymap() string { | |
| 102 | - | out, err := exec.Command("localectl", "status").Output() | |
| 103 | - | ||
| 104 | - | switch { | |
| 105 | - | case err != nil: | |
| 106 | - | return "us" // Default fallback | |
| 107 | - | } | |
| 108 | - | ||
| 109 | - | lines := strings.Split(string(out), "\n") | |
| 110 | - | for _, line := range lines { | |
| 111 | - | if !strings.Contains(line, "VC Keymap") { | |
| 112 | - | continue | |
| 113 | - | } | |
| 114 | - | ||
| 115 | - | parts := strings.Fields(line) | |
| 116 | - | if len(parts) < 3 { | |
| 117 | - | continue | |
| 118 | - | } | |
| 119 | - | ||
| 120 | - | keymap := parts[2] | |
| 121 | - | switch keymap { | |
| 122 | - | case "(unset)", "": | |
| 123 | - | return "us" | |
| 124 | - | default: | |
| 125 | - | return keymap | |
| 126 | - | } | |
| 127 | - | } | |
| 128 | - | ||
| 129 | - | return "us" | |
| 130 | - | } | |
| 131 | - | ||
| 132 | 88 | // SetDefaults sets default configuration values | |
| 133 | 89 | func (p *PreflightPhase) SetDefaults() { | |
| 134 | 90 | switch { | |
| @@ -73,13 +73,10 @@ func (p *PreflightPhase) PreCheck() error { | |||||
| 73 | func (p *PreflightPhase) Execute(progressChan chan<- ProgressUpdate) PhaseResult { | 73 | func (p *PreflightPhase) Execute(progressChan chan<- ProgressUpdate) PhaseResult { | ||
| 74 | p.SendProgress(progressChan, "Running preflight checks...", 1, 2) | 74 | p.SendProgress(progressChan, "Running preflight checks...", 1, 2) | ||
| 75 | 75 | ||||
| 76 | - | // Detect environment | |||
| 77 | - | p.detectEnvironment(progressChan) | |||
| 78 | - | ||||
| 79 | // Set defaults | 76 | // Set defaults | ||
| 80 | p.SetDefaults() | 77 | p.SetDefaults() | ||
| 81 | 78 | ||||
| 82 | - | p.SendProgress(progressChan, "Environment detected", 2, 2) | 79 | + | p.SendProgress(progressChan, "Preflight checks complete", 2, 2) |
| 83 | p.SendComplete(progressChan, "Preflight complete") | 80 | p.SendComplete(progressChan, "Preflight complete") | ||
| 84 | 81 | ||||
| 85 | return PhaseResult{ | 82 | return PhaseResult{ | ||
| @@ -88,47 +85,6 @@ func (p *PreflightPhase) Execute(progressChan chan<- ProgressUpdate) PhaseResult | |||||
| 88 | } | 85 | } | ||
| 89 | } | 86 | } | ||
| 90 | 87 | ||||
| 91 | - | // detectEnvironment auto-detects keyboard layout and network | |||
| 92 | - | func (p *PreflightPhase) detectEnvironment(progressChan chan<- ProgressUpdate) { | |||
| 93 | - | p.SendOutput(progressChan, "Detecting keyboard layout...") | |||
| 94 | - | ||||
| 95 | - | keymap := p.detectKeymap() | |||
| 96 | - | p.config.Keymap = keymap | |||
| 97 | - | p.SendOutput(progressChan, fmt.Sprintf("[OK] Keyboard layout: %s", keymap)) | |||
| 98 | - | } | |||
| 99 | - | ||||
| 100 | - | // detectKeymap detects current keyboard layout | |||
| 101 | - | func (p *PreflightPhase) detectKeymap() string { | |||
| 102 | - | out, err := exec.Command("localectl", "status").Output() | |||
| 103 | - | ||||
| 104 | - | switch { | |||
| 105 | - | case err != nil: | |||
| 106 | - | return "us" // Default fallback | |||
| 107 | - | } | |||
| 108 | - | ||||
| 109 | - | lines := strings.Split(string(out), "\n") | |||
| 110 | - | for _, line := range lines { | |||
| 111 | - | if !strings.Contains(line, "VC Keymap") { | |||
| 112 | - | continue | |||
| 113 | - | } | |||
| 114 | - | ||||
| 115 | - | parts := strings.Fields(line) | |||
| 116 | - | if len(parts) < 3 { | |||
| 117 | - | continue | |||
| 118 | - | } | |||
| 119 | - | ||||
| 120 | - | keymap := parts[2] | |||
| 121 | - | switch keymap { | |||
| 122 | - | case "(unset)", "": | |||
| 123 | - | return "us" | |||
| 124 | - | default: | |||
| 125 | - | return keymap | |||
| 126 | - | } | |||
| 127 | - | } | |||
| 128 | - | ||||
| 129 | - | return "us" | |||
| 130 | - | } | |||
| 131 | - | ||||
| 132 | // SetDefaults sets default configuration values | 88 | // SetDefaults sets default configuration values | ||
| 133 | func (p *PreflightPhase) SetDefaults() { | 89 | func (p *PreflightPhase) SetDefaults() { | ||
| 134 | switch { | 90 | switch { | ||