Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I want to remap capslock to control #2730

Closed
tclh123 opened this issue Dec 7, 2017 · 5 comments
Closed

I want to remap capslock to control #2730

tclh123 opened this issue Dec 7, 2017 · 5 comments

Comments

@tclh123
Copy link

tclh123 commented Dec 7, 2017

loadkeys will report Couldn't get a file descriptor referring to the console.

# strace loadkeys /home/xxx/capslock2ctrl.kmap
execve("/usr/bin/loadkeys", ["loadkeys", "/home/xxx/capslock2ctrl.kmap"], [/* 13 vars */]) = 0
brk(NULL)                               = 0x1006000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f07e20f0000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=20683, ...}) = 0
mmap(NULL, 20683, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f07e20f5000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\t\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1868984, ...}) = 0
mmap(NULL, 3971488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f07e1a30000
mprotect(0x7f07e1bf0000, 2097152, PROT_NONE) = 0
mmap(0x7f07e1df0000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c0000) = 0x7f07e1df0000
mmap(0x7f07e1df6000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f07e1df6000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f07e20e0000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f07e20d0000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f07e20c0000
arch_prctl(ARCH_SET_FS, 0x7f07e20d0700) = 0
mprotect(0x7f07e1df0000, 16384, PROT_READ) = 0
mprotect(0x610000, 4096, PROT_READ)     = 0
mprotect(0x7f07e2025000, 4096, PROT_READ) = 0
munmap(0x7f07e20f5000, 20683)           = 0
brk(NULL)                               = 0x1006000
brk(0x1027000)                          = 0x1027000
open("/proc/self/fd/0", O_RDWR)         = 3
ioctl(3, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(3, KDGKBTYPE, 0x7ffffe09cd47)     = -1 ENOTTY (Inappropriate ioctl for device)
close(3)                                = 0
open("/dev/tty", O_RDWR)                = 3
ioctl(3, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(3, KDGKBTYPE, 0x7ffffe09cd47)     = -1 ENOTTY (Inappropriate ioctl for device)
close(3)                                = 0
open("/dev/tty0", O_RDWR)               = -1 EIO (Input/output error)
open("/dev/tty0", O_WRONLY)             = -1 EIO (Input/output error)
open("/dev/tty0", O_RDONLY)             = -1 EIO (Input/output error)
open("/dev/vc/0", O_RDWR)               = -1 ENOENT (No such file or directory)
open("/dev/vc/0", O_WRONLY)             = -1 ENOENT (No such file or directory)
open("/dev/vc/0", O_RDONLY)             = -1 ENOENT (No such file or directory)
open("/dev/systty", O_RDWR)             = -1 ENOENT (No such file or directory)
open("/dev/systty", O_WRONLY)           = -1 ENOENT (No such file or directory)
open("/dev/systty", O_RDONLY)           = -1 ENOENT (No such file or directory)
open("/dev/console", O_RDWR)            = -1 ENOENT (No such file or directory)
open("/dev/console", O_WRONLY)          = -1 ENOENT (No such file or directory)
open("/dev/console", O_RDONLY)          = -1 ENOENT (No such file or directory)
open("/dev/tty1", O_RDWR)               = 3
ioctl(3, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(3, KDGKBTYPE, 0x7ffffe09cd47)     = -1 ENOTTY (Inappropriate ioctl for device)
close(3)                                = 0
open("/dev/tty2", O_RDWR)               = 3
ioctl(3, TCGETS, {B38400 opost isig -icanon -echo ...}) = 0
ioctl(3, KDGKBTYPE, 0x7ffffe09cd47)     = -1 ENOTTY (Inappropriate ioctl for device)
close(3)                                = 0
open("/dev/tty3", O_RDWR)               = -1 ENOENT (No such file or directory)
open("/dev/tty3", O_WRONLY)             = -1 ENOENT (No such file or directory)
open("/dev/tty3", O_RDONLY)             = -1 ENOENT (No such file or directory)
open("/dev/tty4", O_RDWR)               = -1 ENOENT (No such file or directory)
open("/dev/tty4", O_WRONLY)             = -1 ENOENT (No such file or directory)
open("/dev/tty4", O_RDONLY)             = -1 ENOENT (No such file or directory)
open("/dev/tty5", O_RDWR)               = -1 ENOENT (No such file or directory)
open("/dev/tty5", O_WRONLY)             = -1 ENOENT (No such file or directory)
open("/dev/tty5", O_RDONLY)             = -1 ENOENT (No such file or directory)
open("/dev/tty6", O_RDWR)               = -1 ENOENT (No such file or directory)
open("/dev/tty6", O_WRONLY)             = -1 ENOENT (No such file or directory)
open("/dev/tty6", O_RDONLY)             = -1 ENOENT (No such file or directory)
open("/dev/tty7", O_RDWR)               = -1 ENOENT (No such file or directory)
open("/dev/tty7", O_WRONLY)             = -1 ENOENT (No such file or directory)
open("/dev/tty7", O_RDONLY)             = -1 ENOENT (No such file or directory)
open("/dev/tty8", O_RDWR)               = -1 ENOENT (No such file or directory)
open("/dev/tty8", O_WRONLY)             = -1 ENOENT (No such file or directory)
open("/dev/tty8", O_RDONLY)             = -1 ENOENT (No such file or directory)
open("/dev/tty9", O_RDWR)               = -1 ENOENT (No such file or directory)
open("/dev/tty9", O_WRONLY)             = -1 ENOENT (No such file or directory)
open("/dev/tty9", O_RDONLY)             = -1 ENOENT (No such file or directory)
open("/dev/tty10", O_RDWR)              = -1 ENOENT (No such file or directory)
open("/dev/tty10", O_WRONLY)            = -1 ENOENT (No such file or directory)
open("/dev/tty10", O_RDONLY)            = -1 ENOENT (No such file or directory)
open("/dev/tty11", O_RDWR)              = -1 ENOENT (No such file or directory)
open("/dev/tty11", O_WRONLY)            = -1 ENOENT (No such file or directory)
open("/dev/tty11", O_RDONLY)            = -1 ENOENT (No such file or directory)
open("/dev/tty12", O_RDWR)              = -1 ENOENT (No such file or directory)
open("/dev/tty12", O_WRONLY)            = -1 ENOENT (No such file or directory)
open("/dev/tty12", O_RDONLY)            = -1 ENOENT (No such file or directory)
write(2, "Couldn't get a file descriptor r"..., 56Couldn't get a file descriptor referring to the console
) = 56
exit_group(1)                           = ?
+++ exited with 1 +++

related #1806

@Biswa96
Copy link

Biswa96 commented Dec 7, 2017

Does that key remapping work only in WSL domain? Or for whole Windows system. I generally use AutoHotKey for those keyboard tweaks.

@Brian-Perkins
Copy link

WSL does not currently support any of the console IOCTLs. In the strace above and in the related #1806, KDGKBTYPE is failing. To actually do the key remapping, I suspect additional IOCTLs beyond KDGKBTYPE would also be needed.

@therealkenc
Copy link
Collaborator

therealkenc commented Dec 7, 2017

related #1806

Yes this is the same #1806. This one (and the other) is awkward because technically this issue is tag linux-behavior. If you ssh into a Real Linux™ box you would get the same error if you try to use loadkeys(1).

The User Voice cited regarding setxkbmap #787 is related but more complicated. We'll get into the weeds real fast about how X11 keyboard mapping (and the X protocol) works. Let's save that for another day.

At base like Biswapriyo suggests, for now to get the behaviour you are looking for, you would need to remap capslock to control in Windows -- because that's where your keyboard driver lives.

@tclh123
Copy link
Author

tclh123 commented Dec 8, 2017

OK, I just use AutoHotKey to do this remapping, thanks everyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants