diff --git a/server/internal/remote/manager.go b/server/internal/remote/manager.go index 0975e8c..4268a65 100644 --- a/server/internal/remote/manager.go +++ b/server/internal/remote/manager.go @@ -2,6 +2,7 @@ package remote import ( "fmt" + "os/exec" "time" "github.com/kataras/go-events" @@ -244,7 +245,14 @@ func (manager *RemoteManager) GetScreenSize() *types.ScreenSize { } func (manager *RemoteManager) SetKeyboardLayout(layout string) { - xorg.SetKeyboardLayout(layout) + // Workaround for https://github.com/m1k1o/neko/issues/45 + // When pressing `shift` + `,` instead of `<` comes `>`. + variant := "" + if layout == "us" { + variant = "intl" + } + + exec.Command("setxkbmap", layout, variant).Run() } func (manager *RemoteManager) SetKeyboardModifiers(NumLock int, CapsLock int, ScrollLock int) { diff --git a/server/internal/xorg/xorg.c b/server/internal/xorg/xorg.c index 89335d9..3acb27b 100644 --- a/server/internal/xorg/xorg.c +++ b/server/internal/xorg/xorg.c @@ -166,13 +166,6 @@ short XGetScreenRate() { return XRRConfigCurrentRate(conf); } -void SetKeyboardLayout(char *layout) { - // TOOD: refactor, use native API. - char cmd[13] = "setxkbmap "; - strncat(cmd, layout, 2); - int r = system(cmd); -} - void SetKeyboardModifiers(int num_lock, int caps_lock, int scroll_lock) { Display *display = getXDisplay(); diff --git a/server/internal/xorg/xorg.go b/server/internal/xorg/xorg.go index 5de1dbe..2086e3d 100644 --- a/server/internal/xorg/xorg.go +++ b/server/internal/xorg/xorg.go @@ -10,7 +10,6 @@ import "C" import ( "fmt" - "regexp" "sync" "time" "unsafe" @@ -211,20 +210,6 @@ func GetScreenSize() *types.ScreenSize { return nil } -func SetKeyboardLayout(layout string) { - mu.Lock() - defer mu.Unlock() - - if !regexp.MustCompile(`^[a-zA-Z]+$`).MatchString(layout) { - return - } - - layoutUnsafe := C.CString(layout) - defer C.free(unsafe.Pointer(layoutUnsafe)) - - C.SetKeyboardLayout(layoutUnsafe) -} - func SetKeyboardModifiers(num_lock int, caps_lock int, scroll_lock int) { mu.Lock() defer mu.Unlock() diff --git a/server/internal/xorg/xorg.h b/server/internal/xorg/xorg.h index 88eca16..5e10260 100644 --- a/server/internal/xorg/xorg.h +++ b/server/internal/xorg/xorg.h @@ -40,7 +40,6 @@ void XDisplayClose(void); void XDisplaySet(char *input); - void SetKeyboardLayout(char *layout); void SetKeyboardModifiers(int num_lock, int caps_lock, int scroll_lock); #endif