login-app: Able to change keymap

This commit is contained in:
nemunaire 2023-02-20 18:58:13 +01:00
parent 3055d4d02a
commit 77acf55271
4 changed files with 50 additions and 1 deletions

View File

@ -11,6 +11,8 @@ ADD cmd ./
RUN go build -v -ldflags="-s -w" -tags netgo -o login-app
RUN apk add --no-cache kbd
FROM alpine:3.17
MAINTAINER Pierre-Olivier Mercier <nemunaire@nemunai.re>
@ -21,5 +23,7 @@ COPY --from=gobuild /go/src/login-app/login-app /bin/login-app
COPY --from=gobuild /usr/share/udhcpc/default.script /usr/share/udhcpc/default.script
COPY --from=gobuild /etc/terminfo/l/linux /etc/terminfo/l/linux
COPY --from=gobuild /usr/share/terminfo/l/linux /usr/share/terminfo/l/linux
COPY --from=gobuild /usr/bin/loadkeys /usr/bin/loadkeys
COPY --from=gobuild /usr/share/keymaps/xkb/fr.map.gz /usr/share/keymaps/xkb/us.map.gz /usr/share/keymaps/xkb/fr-bepo.map.gz /usr/share/keymaps/xkb/us-colemak.map.gz /usr/share/keymaps/xkb/
ENTRYPOINT ["/bin/login-app"]

View File

@ -14,6 +14,9 @@ func CreateLoginDialog(app *tview.Application, next func(username, password stri
form.GetFormItemByLabel("Login").(*tview.InputField).GetText(),
form.GetFormItemByLabel("Password").(*tview.InputField).GetText(),
)
}).
AddButton("Settings...", func() {
goToSettings(app)
})
form.SetBorder(true).SetTitle(" SRS Adlin - Login ")

View File

@ -0,0 +1,42 @@
package main
import (
"os/exec"
"github.com/rivo/tview"
)
var LastKeymap = 0
func goToSettings(app *tview.Application) {
var form *tview.Form
form = tview.NewForm().
AddDropDown("Keymap", []string{"QWERTY us", "AZERTY fr", "BÉPO", "Colemak us"}, LastKeymap, nil).
AddButton(" Save config ", func() {
if kbmap, _ := form.GetFormItemByLabel("Keymap").(*tview.DropDown).GetCurrentOption(); LastKeymap != kbmap {
file := "/usr/share/keymaps/xkb/"
switch kbmap {
case 1:
file += "fr.map.gz"
case 2:
file += "fr-bepo.map.gz"
case 3:
file += "us-colemak.map.gz"
default:
file += "us.map.gz"
}
exec.Command("/usr/bin/loadkeys", file).Run()
LastKeymap = kbmap
}
askLogin(app)
})
form.GetFormItemByLabel("Keymap").(*tview.DropDown).SetFieldWidth(25)
form.SetBorder(true).SetTitle(" SRS Adlin - Settings ")
app.SetRoot(modal(form, 25, 7), true)
app.SetFocus(form)
return
}

View File

@ -6,7 +6,7 @@ import (
func CreateUEFIDialog(app *tview.Application, next func()) {
modal := tview.NewModal().
SetText("Not UEFI boot\nYou should reboot, enter UEFI Setup (F2) and disable Legacy boot").
SetText("This machine does not boot in UEFI mode!\nYou should reboot now, enter UEFI Setup (F2) and disable Legacy boot. Or choose another machine, that boot in UEFI.").
AddButtons([]string{"Reboot", "Ignore"}).
SetDoneFunc(func(buttonIndex int, buttonLabel string) {
if buttonLabel == "Reboot" {