login-app: Able to change keymap
This commit is contained in:
parent
3055d4d02a
commit
77acf55271
@ -11,6 +11,8 @@ ADD cmd ./
|
|||||||
|
|
||||||
RUN go build -v -ldflags="-s -w" -tags netgo -o login-app
|
RUN go build -v -ldflags="-s -w" -tags netgo -o login-app
|
||||||
|
|
||||||
|
RUN apk add --no-cache kbd
|
||||||
|
|
||||||
|
|
||||||
FROM alpine:3.17
|
FROM alpine:3.17
|
||||||
MAINTAINER Pierre-Olivier Mercier <nemunaire@nemunai.re>
|
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 /usr/share/udhcpc/default.script /usr/share/udhcpc/default.script
|
||||||
COPY --from=gobuild /etc/terminfo/l/linux /etc/terminfo/l/linux
|
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/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"]
|
ENTRYPOINT ["/bin/login-app"]
|
||||||
|
@ -14,6 +14,9 @@ func CreateLoginDialog(app *tview.Application, next func(username, password stri
|
|||||||
form.GetFormItemByLabel("Login").(*tview.InputField).GetText(),
|
form.GetFormItemByLabel("Login").(*tview.InputField).GetText(),
|
||||||
form.GetFormItemByLabel("Password").(*tview.InputField).GetText(),
|
form.GetFormItemByLabel("Password").(*tview.InputField).GetText(),
|
||||||
)
|
)
|
||||||
|
}).
|
||||||
|
AddButton("Settings...", func() {
|
||||||
|
goToSettings(app)
|
||||||
})
|
})
|
||||||
form.SetBorder(true).SetTitle(" SRS Adlin - Login ")
|
form.SetBorder(true).SetTitle(" SRS Adlin - Login ")
|
||||||
|
|
||||||
|
42
pkg/login-app/cmd/dialog-settings.go
Normal file
42
pkg/login-app/cmd/dialog-settings.go
Normal 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
|
||||||
|
}
|
@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
func CreateUEFIDialog(app *tview.Application, next func()) {
|
func CreateUEFIDialog(app *tview.Application, next func()) {
|
||||||
modal := tview.NewModal().
|
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"}).
|
AddButtons([]string{"Reboot", "Ignore"}).
|
||||||
SetDoneFunc(func(buttonIndex int, buttonLabel string) {
|
SetDoneFunc(func(buttonIndex int, buttonLabel string) {
|
||||||
if buttonLabel == "Reboot" {
|
if buttonLabel == "Reboot" {
|
||||||
|
Reference in New Issue
Block a user