date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,429,949,980,000 |
When I tried to install something from GitHub or even update and upgrade the system, the error message shown below is displayed. This is on the Kali distribution. The problem is related to the Realtek driver with an Alpha wireless network adapter. I am stuck in this situation so I hope someone can help.
Here's the output when for example I try to upgrade the system (or install some software from GitHub, try to compile something etc.):
8814au.ko.xz:
Uninstallation
Deleting from: /lib/modules/6.6.9-amd64/updates/dkms/
Original module
No original module was found for this module on this kernel.
Use the dkms install command to reinstall any previous module version. depmod...... dkms: running auto installation service for kernel 6.6.9-amd64.
88XXau.ko.xz:
Running module version sanity check.
Module version v5.6.4.2_35491.20191025 for 88XXau.ko.xz exactly matches what is already found in kernel 6.6.9-amd64.
DKMS will not replace this module.
You may override by specifying --force.
Error! Installation aborted.
Sign command: /lib/modules/6.6.9-amd64/build/scripts/sign-file
Signing key: /var/lib/dkms/mok.key
Public certificate (MOK): /var/lib/dkms/mok.pub
Building module:
Cleaning build area...
/usr/src/realtek-rtl8814au-5.8.5.1~git20231211.866a910/dkms-make.sh..........................................................................................
Signing module /var/lib/dkms/realtek-rtl8814au/5.8.5.1~git20231211.866a910/build/8814au.ko
Cleaning build area...
8814au.ko.xz: Running module version sanity check.
Original module
No original module exists within this kernel
Installation
Installing to /lib/modules/6.6.9-amd64/updates/dkms/ depmod......
88XXau.ko.xz:
Running module version sanity check.
Module version v5.6.4.2_35491.20191025 for 88XXau.ko.xz
exactly matches what is already found in kernel 6.6.9-amd64.
DKMS will not replace this module.
You may override by specifying --force.
Error! Installation aborted.
dkms autoinstall on 6.6.9-amd64/x86_64 succeeded for realtek-rtl8814au
dkms autoinstall on 6.6.9-amd64/x86_64 failed for 8812au(6) realtek- rtl88xxau(6)
Error! One or more modules failed to install during autoinstall.
Refer to previous errors for more information.
dkms: autoinstall for kernel: 6.6.9-amd64 failed!
run-parts: /etc/kernel/header_postinst.d/dkms exited with return code 11
Failed to process /etc/kernel/header_postinst.d at /var/lib/dpkg/info/linux-headers-6.6.9-amd64.postinst line 11.
dpkg: error processing package linux-headers-6.6.9-amd64 (--configure):
installed linux-headers-6.6.9-amd64 package post-installation script subprocess returned error exit status 11
Setting up libtss2-sys1:amd64 (4.0.1-7) ...
Setting up libtss2-tcti-swtpm0:amd64 (4.0.1-7) ...
Setting up libtss2-tcti-libtpms0:amd64 (4.0.1-7) ...
Setting up libtss2-tcti-device0:amd64 (4.0.1-7) ...
Setting up libtss2-tcti-spi-helper0:amd64 (4.0.1-7) ...
Setting up libtss2-tcti-cmd0:amd64 (4.0.1-7) ...
Setting up libtss2-tcti-mssim0:amd64 (4.0.1-7) ...
Setting up libtss2-esys-3.0.2-0:amd64 (4.0.1-7) ...
Setting up libopenconnect5:amd64 (9.12-1+b1) ...
Processing triggers for libc-bin (2.37-12) ... Errors were encountered while processing:
linux-headers-6.6.9-amd64 E: Sub-process /usr/bin/dpkg returned an error code (1)
After installing some software I try to upgrade the OS but I can't even do that because of the same problem. Can anyone help me fix this?
Here's dkms status:
8812au/5.6.4.2_35491.20191025, 6.6.9-amd64, x86_64: built
realtek-rtl8814au/5.8.5.1~git20231211.866a910, 6.6.9-amd64, x86_64: installed
realtek-rtl88xxau/5.6.4.2~git20231117.a3e0c0b, 6.6.9-amd64, x86_64: built
and uname -r output:
6.6.9-amd64
|
Under /usr/src/ look for dkms.conf for the modules
8812au
realtek-rtl8814au
realtek-rtl88xxau
under every correspondent folder is a file named
dkms.conf
Search in this files for string
AUTOINSTALL="yes"
to
AUTOINSTALL="no"
so dkms don't try to build/install them.
sudo dkms remove 8812au/5.6.4.2_35491.20191025 -k 6.6.9-amd64
also
sudo dkms remove realtek-rtl88xxau/5.6.4.2~git20231117.a3e0c0b -k 6.6.9-amd64
and
sudo apt update && sudo dpkg --configure -a
But I can not help which module is the right one for your wlan.
| "Error! Installation aborted" - dkms problem when installing or upgrading |
1,429,949,980,000 |
I am just a newbie that is trying to learn. I can't see anything in the OLED display (ssd0303).
I am just using this demo: https://www.freertos.org/portlm3s811keil.html
as you can see it says that:
The print task is the only task permitted to access the LCD - thus
ensuring mutual exclusion and consistent access to the resource. Other
tasks do not access the LCD directly, but instead send the text they
wish to display to the print task. The print task spends most of its
time blocked - only waking when a message is queued for display.
but actually, if I compile using make and running using qemu-system-arm -M lm3s811evb -kernel gcc/RTOSDemo.bin I can only see that black screen.
Why? Is there something I am not considering? It should work out of the box, since it's also writen in the official doc that I mentioned. So why I see black screen?
Probably there is something I am not considering because I am a newbie
|
I fixed by compiling via Keil instead of gcc:
https://forums.freertos.org/t/i-am-trying-to-emulate-a-board-which-has-a-oled-display-but-cant-see-anything-can-you-tell-me-if-there-is-something-important-i-am-not-considering/18689/3
| I am trying to emulate a board which has a OLED display, but can't see anything. Can you tell me if there is something important I am not considering? [closed] |
1,429,949,980,000 |
we have RHEL 7.6 server ( VM server )
that performed unexpected reboot twice ( we can see the reboot from last command )
after review on dmesg output , we can see the following messages ,
Jul 3 09:56:42 server_MA02 kernel: ata12: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata5: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata11: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata4: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata10: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata14: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata13: SATA lin
k down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata15: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata16: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata20: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata21: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata26: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata19: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata29: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata32: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata28: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata31: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata25: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata30: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata22: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata18: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata17: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata23: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata24: SATA link down (SStatus 0 SControl 300)
Jul 3 09:56:42 server_MA02 kernel: ata27: SATA link down (SStatus 0 SControl 300)
is that above messages chould be part of the problem that VM machines perform unexpected reboot ?
|
When you say "VM server", do you mean the server is a physical machine that hosts VMs, or that the server is a Virtual Machine?
If the logs are from a physical machine, it seems a large number of SATA links have died at once; maybe power supply problems, or SATA controller problems?
If the server is a VM, this might mean the host suddenly stopped providing virtual disks to the VM: you should check the logs of the physical host (or contact its administrators, if it's hosted by someone else) to see if the host has a hardware problem of some sort.
| RHEL + how to verify the dmesg log in order to find the root cause of unexpected reboot |
1,429,949,980,000 |
So my Ubuntu VM /boot is now full, I know I managed to fix this long time ago, but now what ever I do it seems to not work.
xxx@ubuntu:~$ df -h
Filsystem Storlek Använt Ledigt Anv% Monterat på
udev 2,0G 0 2,0G 0% /dev
tmpfs 396M 6,1M 390M 2% /run
/dev/mapper/ubuntu--vg-root 45G 6,4G 37G 15% /
tmpfs 2,0G 0 2,0G 0% /dev/shm
tmpfs 5,0M 0 5,0M 0% /run/lock
tmpfs 2,0G 0 2,0G 0% /sys/fs/cgroup
/dev/sda1 472M 469M 0 100% /boot
/dev/sdb1 689G 77G 578G 12% /mnt/VIDEO_RECORDING
tmpfs 396M 0 396M 0% /run/user/1000
I am running GNU/Linux 4.4.0-145-generic x86_64 and if I run:
dpkg --list | grep linux-image
I get a lot of kernel images. So because it is full I want to try to remove with:
sudo apt autoremove
and:
sudo apt-get purge linux-image-4.4.0-101-generic
I get:
Läser paketlistor… Färdig
Bygger beroendeträd
Läser tillståndsinformation… Färdig
Du bör köra ”apt-get -f install” för att korrigera dessa.
Följande paket har beroenden som inte kan tillfredsställas:
linux-image-generic : Beroende av: linux-image-4.4.0-150-generic men det är inte installerat eller
linux-image-unsigned-4.4.0-150-generic men det är inte installerat
Rekommenderar: thermald men det är inte installerat
linux-modules-extra-4.4.0-150-generic : Beroende av: linux-image-4.4.0-150-generic men det är inte installerat eller
linux-image-unsigned-4.4.0-150-generic men det är inte installerat
Yes I know this is Swedish, but it says that it is dependent of linux-image-4.4.0-150-generic, but it is not installed. So it suggests me to run:
apt-get -f install
Then it tries to download linux-image-4.4.0-150-generic but fails of course due lack of space. I am sure that I found some way to actually remove the kernel images manually with rm command, but I dont know where they kernel images are stored, I also tried to install byobu, to help me remove the kernel images but no space... You know..
So, is my solution now to manually remove the kernel images and if how?
Thanks!
xxx@ubuntu:/boot$ dpkg --list | grep linux-image
rc linux-image-4.4.0-101-generic 4.4.0-101.124 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc linux-image-4.4.0-103-generic 4.4.0-103.126 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc linux-image-4.4.0-104-generic 4.4.0-104.127 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc linux-image-4.4.0-108-generic 4.4.0-108.131 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc linux-image-4.4.0-109-generic 4.4.0-109.132 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc linux-image-4.4.0-112-generic 4.4.0-112.135 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc linux-image-4.4.0-116-generic 4.4.0-116.140 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc linux-image-4.4.0-119-generic 4.4.0-119.143 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc linux-image-4.4.0-121-generic 4.4.0-121.145 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc linux-image-4.4.0-124-generic 4.4.0-124.148 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc linux-image-4.4.0-127-generic 4.4.0-127.153 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc linux-image-4.4.0-128-generic 4.4.0-128.154 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc linux-image-4.4.0-130-generic 4.4.0-130.156 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
pi linux-image-4.4.0-133-generic 4.4.0-133.159 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-134-generic 4.4.0-134.160 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-137-generic 4.4.0-137.163 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-138-generic 4.4.0-138.164 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-139-generic 4.4.0-139.165 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-141-generic 4.4.0-141.167 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-142-generic 4.4.0-142.168 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-143-generic 4.4.0-143.169 amd64 Signed kernel image generic
ii linux-image-4.4.0-145-generic 4.4.0-145.171 amd64 Signed kernel image generic
iF linux-image-4.4.0-148-generic 4.4.0-148.174 amd64 Signed kernel image generic
rc linux-image-4.4.0-87-generic 4.4.0-87.110 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
rc linux-image-extra-4.4.0-101-generic 4.4.0-101.124 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc linux-image-extra-4.4.0-103-generic 4.4.0-103.126 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc linux-image-extra-4.4.0-104-generic 4.4.0-104.127 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc linux-image-extra-4.4.0-108-generic 4.4.0-108.131 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc linux-image-extra-4.4.0-109-generic 4.4.0-109.132 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc linux-image-extra-4.4.0-112-generic 4.4.0-112.135 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc linux-image-extra-4.4.0-116-generic 4.4.0-116.140 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc linux-image-extra-4.4.0-119-generic 4.4.0-119.143 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc linux-image-extra-4.4.0-121-generic 4.4.0-121.145 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc linux-image-extra-4.4.0-124-generic 4.4.0-124.148 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc linux-image-extra-4.4.0-127-generic 4.4.0-127.153 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc linux-image-extra-4.4.0-128-generic 4.4.0-128.154 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc linux-image-extra-4.4.0-130-generic 4.4.0-130.156 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-133-generic 4.4.0-133.159 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-134-generic 4.4.0-134.160 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-137-generic 4.4.0-137.163 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-138-generic 4.4.0-138.164 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-139-generic 4.4.0-139.165 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-141-generic 4.4.0-141.167 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-142-generic 4.4.0-142.168 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
rc linux-image-extra-4.4.0-87-generic 4.4.0-87.110 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
iU linux-image-generic 4.4.0.150.158 amd64 Generic Linux kernel image
xxx@ubuntu:/boot$ sudo du /boot
2355 /boot/grub/fonts
2118 /boot/grub/i386-pc
253 /boot/grub/locale
7121 /boot/grub
12 /boot/lost+found
477697 /boot
yes I find the kernels in the /boot folder.
|
Manual cleanup of /boot
Go to the /boot directory:
cd /boot
Get list of all files:
ls
Get currently running kernel version:
uname -r
Remove old kernels and initramdisks. Keep the currently running kernel and its initrd.
rm FILE_NAME FILE_NAME FILE_NAME
# Maybe you should use `sudo`:
sudo rm FILE_NAME FILE_NAME FILE_NAME
(just copy&paste file names)
Correct cleanup method
Install aptitude, it is menu-based package manager:
sudo apt-get install aptitude
Run aptitude:
sudo aptitude
Find (key /) text linux-image, press Enter. Press _ (purge) or - (remove) for each package you want to remove. Press g to review the changes and then g again.
| /dev/sda1/boot is full |
1,429,949,980,000 |
I have a custom application running on an embedded linux (generated with Buildroot). The kernel is patched with grsec and then, in the linux-menuconfig I enable GRsecurity. I haven't enable any more Grsec related options (except preventing code reuse).
Everything works fine, except that one application crashes with a coredump and causes a kernel panic.
I have tried the same application, without enabling Grsecurity in the kernel (but still patching the kernel) and it works fine.
The application, needs harware access through a special device (let's say /dev/mydev) and a module loaded at boot in a /etc/rc file.
My thoughts are that, maybe, grsec prevents or alter the load of the module, even though lsmod or modinfo shows correctly the module.
The most troubling thing, is that it is hard to get more info about this, as the kernel panic causes reboot of the device (so I can only read the last line of the messages).
Here is the error message:
worker_thread+0x58/0x490
process_one_work+0x3b0/0x3b0
kkthread_create_on_node+0x1b0/0x1b0
Any one knows if something needed to be configured in the kernel so any out of tree module could be loaded properly ?
I tried reading the official wikibook but most of it is about the RBAC which is not activated when I launch the application.
|
It was tricky, but I found the source of the problem, even if I'm still trying to understand it.
So, there was an option the kernel configuration that was the activated by default: "prevent code reuse attacks". I deactivated it, and it worked fine.
I still trying to get a better understanding of what it actually does, but I am guessing it changes something of how shared libraries are used (maybe).
Anyway, deactivating it solved my problem. So I consider my problem solved.
More info:
https://grsecurity.net/rap_faq.php
| grsec causes coredump of application and kernel panic |
1,429,949,980,000 |
My uname -r (and as is my real problem, Java system property os.version) returns a version number that has dashes in it. It looks like: 5.9.12-gentoo-blah-blah.
This breaks an app I'm using which doesn't like the dashes in the version number (it expects just a number, no dashes allowed).
How can I change the version number of my operating system? I just want to return the kernel version and don't worry about the rest.
|
The OS release is returned from the kernel by the uname system call (man 2 uname for limited information about it). The information can also be found under /proc/sys/kernel/osrelease. That file is read-only and there's no way to change the OS release of a kernel after it has been built.
The OS release is set in the Makefile of the kernel. The first 4 lines are:
VERSION =
PATCHLEVEL =
SUBLEVEL =
EXTRAVERSION =
It's also possible that extra information is added during the build if you build from a version control repository.
The kernel from Gentoo adds an EXTRAVERSION which has dashes in it. Before building the kernel modify the Makefile to set the version to what you want.
| How can I change the OS version output? |
1,429,949,980,000 |
So I'm compiling the 6.0.3 kernel in Debian 11, and I've been given the task of getting the smallest kernel possible that boots and has Internet connection.
I find myself at a point where I've compiled the kernel 89 times in total, and my kernel has 599 static modules and 0 loadable modules.
I'm using the command make nconfig and I've searched high and low for the section to disable the GUI, but I can't find it. My OS boots still with a GUI, and I want to disable that because I'm sure I can remove a lot of modules that way and make my kernel even smaller.
Somebody knows which section of the menu has this option?
EDIT:
The task is finished and I've ended up with 533 static modules + 0 dynamic modules.
I literally can't remove any more modules, and the GUI is still working and there is no section in the menu to disable it.
You were all right, thanks!
|
To build a minimal kernel you should use make tinyconfig instead of make nconfig.
To disable the graphic interface, use:
sudo systemctl set-default multi-user.target
to revert back:
sudo systemctl set-default graphical.target
But it doesn't make the kernel smaller.
| How to disable GUI when compiling the linux kernel? |
1,429,949,980,000 |
Why do I need to know where is the code source?
I found a bug in the config file of the service named wpa_supplicant, when using some shell, like sh or zsh instead of bash for the root user
$ cat /etc/passwd
root:x:0:0:root:/root:/bin/zsh
this error is in this file : /etc/sv/wpa_supplicant/auto
Because in bash, we can find in two directories like that
for f in /etc/wpa_supplicant/wpa_supplicant-*.conf /etc/wpa_supplicant-*.conf ;
do
#....
done
but we can't do it in another shell
my PR is changing this for-loop or adding bash shebang,
but can't find `Void-Linux source in GitHub
|
The source code can be found here.
Your eventual pull request would modify this file.
You could first file a bug report (an issue in Github). That lets other people see the problem and search for solutions. Then you could create the PR and associate it with the issue.
The document Contributing to void-packages has more information on how to contribute.
| Where can I find the source code of Voidlinux |
1,429,949,980,000 |
In Virtual machine, Kali, I assigned the memory 4G, like this;
But there is a problem.
I installed self-build kernel at the guest to hack the memory.
# uname -a
Linux 15ud490-gx76k 6.8.4+ #8 SMP PREEMPT_DYNAMIC Sat Apt 6 15:49:20 KST 2024 x86_64 x86_64 x86_64 GNU/Linux
And I want to see an erea of end of memory, typed like below.
It says a size of memory is 16*0x336000 bytes.
Then I inferenced the memory size with the results (On the host).
$ python3
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 16*0x07fff0
8388352
>>> 16*0x07fff0/1024/1024
7.999755859375
>>> 16*0x335ff0/1024/1024
51.374755859375
>>> 16*0x336000/1024/1024
51.375
>>> 521000/1024/1024
0.49686431884765625
>>> (1024*1024*4+521000+3288)*1024/1024/1024/1024 # Convert into gigabytes
4.5
I gave the memory 4G to guest but it has 4.5GiB according to the above.
The swap is 1G so it's nonsense.
Where is the source of 0.5G memory?????
|
Neither is the physical memory space built for your RAM necessarily contiguous, nor is RAM the only thing that gets physical addresses: your computer has memory-mapped buses / devices.
Try cat /proc/iomem to see the mapping of devices to physical memory space. lsmem greatly simplifies what is really the address space mapping!
This is by no means specific to Linux: that's how pretty much all modern computer architectures work.
Now in your specific case, I guess the extra "truly RAM" that you see are actually not that, but trapped addresses used for communication between hypervisor and VM.
| Where is 512M RAM from? |
1,429,949,980,000 |
Who starts a program to run on RAM? Is it Kernel?
Suppose I hit 'ls' command in linux, I know it is running on RAM processed by CPU-Core and make sys-call (to Kernel) whenever necessary and flush the o/p using syscall. But who really makes the 'ls' to run on a RAM?
|
When you type ls in a terminal, the shell that's running in that terminal (maybe bash, or zsh, etc.) will call a syscall telling the kernel to fork its process. It then tells the kernel to replace the process image of the new process to the ls program, with the execve syscall. This will load the code of the ls program from the disk into ram.
So if you mean what program causes the program to be run, it's the shell.
| Who starts a program to run? |
1,429,949,980,000 |
I started with a Debian Jessie distribution and have upgraded it from a 3.X kernel to 4.19 now. There are still things that are not fully working (broken packages etc). As I am going through cleanup I have found that currently running lsb_release -a gets me:
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.11 (jessie)
Release: 8.11
Codename: jessie
Would a proper Debian Kernel upgrade change the output of lsb_release?
|
lsb_release doesn’t output the kernel version, so no, upgrading the kernel won’t change its output.
| Will Upgrading Debian Kernel Change output of lsb_release? |
1,429,949,980,000 |
I see unusual info from the dmesg as the following:
addr2line[207071]: segfault at 30 ip 1000543d41881 sp 00037fff87dd4420 error 6
addr2line[207089]: segfault at 0 ip 0200353455f8c9052e sp 034347fffb8dd3980 error 6 in libbfd-2.20.51.0.2-5.36.el6.so[7f13f800+d2000]
addr2line[207100]: segfault at 0 ip 002075454f3652e sp 0503434ff084fd0a0 error 6 in libbfd-2.20.51.0.2-5.36.el6.so[7f836545440+d2000]
what this lines are indicate ?
|
Program addr2line had segmentation fault with error 6 (attempt to write in unmapped memory). The program likely crashed at that point.
A detailed answer on how to interpret the message is provided on Stack Overflow.
| segfault from dmesg + redhat linux |
1,429,949,980,000 |
I am requesting opinions on expected and desired outcome of prog initialization, specifically loading of shared libraries for a program that I do not have source code. All code delivered via RPMs.
Suspect prog exhibits constant Revc-Q buffering on two TCP conns. Other end of TCP conns looks good. Suspect prog buffers 1000-10000 bytes almost constantly, rarely goes to zero. Host of suspect prog shows tcpActiveOpens.0 50,000 with tcpAttemptFails.0 at 47,000 with both incrementing continuously. Many other probable TCP issues.
When ldd run on suspect prog returns total of 42 libraries with 24 "not found" the other 18 resolve with a DIR and hexaddr. Put an strace wrapper around suspect prog and noted the many "-1 ENOENT" on every library, not just the ones noted "not found" with ldd. All libraries are eventually found and loaded into suspect progs mem. Some have as many as 42 ENOENT before success.
Contacted dev with findings and have been assured that when I ran ldd I needed to source their environment config file, which is supposed to run at prog launch and set all library paths. No comment on the ENOENT.
Questions: When you have finished your code and complied, do you validate with tools such as ldd? Should ldd always return 0, or is some or a lot of "not founds" not always an issue. And what about the ENOENTs? It seems to me that there should be zero errors if the code is compiled and running correctly.
|
ldd should always return OK, otherwise the program can't run. On the other hand, there are ways to control where the dynamic linker searches for shared libraries. Based on the reply you got from the program supplier, I assume they have delivered some kind of startup script that sets up the program environment so that the search paths are satisfied. If you don't run the program like it is intended to be run, ldd will very likely report errors.
The ENOENT errors are perfectly normal when the library search path contains several directories. The dynamic linker tries to find what it is looking for by opening the requested file, and if it is not found ("No such file or directory"), it proceeds to the next directory in the search path. This applies not only to shared libraries, but also other types of files. For example, if a configuration file is optional, the program just ignores the error message and continues execution.
Ps. I found the newspaper personals ad style of you question amusing.
| Linux Prog has 24 Libs Fails LDD, and strace shows 692 "1 ENOENT" during prog library reads |
1,429,949,980,000 |
I'm trying to install Kubuntu on a VM in order to do some deep learning following this guide:
https://github.com/BVLC/caffe/wiki/Ubuntu-14.04-VirtualBox-VM
I'm stuck in the step of the guide that says "Install system updates (3.13.0-32 -> 3.13.0-36)". As far as I've understood this means that I should update the kernel of the OS. However, when I search Google for how to do this I find many different ways to do it (https://www.google.dk/search?q=kubuntu+update+kernel&ie=utf-8&oe=utf-8&gws_rd=cr&ei=lhakVLShMIrMygOciIHICA). None of them seem very easy and I can't seem to figure out how to get exactly version 3.13.0-36.
What is the easiest way to update the kernel, and is it even necessary to update the kernel in order for the installation to work?
|
No it is not necessary but, If you want to be up to date then do them..
or else type on command line
apt-get update
apt-get upgrade
it will update your repository and upgrade the needed packages automatically.
| Is it neccessary for me to update my kernel? And how? [closed] |
1,429,949,980,000 |
According to
https://builders.intel.com/docs/networkbuilders/intel-speed-select-technology-base-frequency-enhancing-performance.pdf
page 11, linux support SST-BF since 4.20
but I can't find it's related code in github:
https://github.com/torvalds/linux
|
Accroding to
https://github.com/intel/CommsPowerManagement/blob/master/sst_bf.py#L121
Get the SST-BF base frequencey
base_filename = "/sys/devices/system/cpu/cpu" + str(core) + "/cpufreq/base_frequency"
linux 4.20 intel pstate source code:
https://elixir.bootlin.com/linux/v4.20/source/drivers/cpufreq/intel_pstate.c#L739
cpufreq_freq_attr_ro(base_frequency);
This line of code only added since 4.20
| Where is Intel speed select driver? [closed] |
1,429,949,980,000 |
What are benefits of updating kernel ?
On linux mint 18 kde I had updated kernel two times but still I'm getting latest update so though its not recommend I did and so what are benefits of updating kernel ?
|
Yes you should update the kernel when the system asked you to do
Security Fixes: close up problems of security that has been discovered. You’ll always be safer with the new kernel.
Stability Improvements: it can improve the stability of the system (exp: the system crash through regular use).
Increase the speed of the Linux machine and improve the overall productivity quite a bit.
Updated Drivers because the new kernel includes the latest open source drivers for devices.
| Benefits of updating kernel |
1,429,949,980,000 |
Please tell me about the register r1 and r2 that bootloader uses to pass the information to the kernel. What are they? where are they located? and some details.
|
Assuming you are talking about the ARM Linux boot protocol, r1 and r2 are CPU registers. There are 16 general-purpose registers on 32-bit ARM processors, named r0-r15.
| Register r1 and r2 in boot process [closed] |
1,429,949,980,000 |
Where are the Linux os installation files located? why are the installation files not run every time an OS is booted and only during the first boot ? How does it know that the OS is already installed ?
|
The installation files for a Linux distribution are stored on the installation medium (a USB stick, or an optical disk of some sort, typically, and there are other possible sources). When you boot the installation medium, it knows that it’s supposed to install the operating system because that’s what it’s designed to do; in some cases, it serves multiple purposes and it will ask what to do — install, or start a live environment, or a recovery environment.
The installed system is separate, and doesn’t include the installation files. It thus “knows” that it’s not supposed to install itself.
On a computer on which a Linux distributions has been installed, nothing prevents you from booting an installation system, and then the installation will start over.
| where are linux installation files located? |
1,429,949,980,000 |
Is operating system and kernel one and the same? I have a doubt about the difference between both of them.
|
What we call the kernel is the operating system's low level functionality.
On most operating system designs, there is a core component to do that job, even if named differently.
While it is possible to boot to a single process which would take care of everything on its own, it would still be the highest ranked process, not just a regular soldier (kernel analogy).
| Can operating system work without kernel? [closed] |
1,429,949,980,000 |
I am interested in history of creating a GNU/Linux and how did these two operating systems unified.
So, there was GNU, and it needed a kernel. They were developing their own kernel called "GNU Heart". But Richard Stallman said that he didn't like it. Then he found out that there was Linux, and then these two operating systems unified. So, my question is:
How could GNU work without kernel before they unified with Linux?
Or maybe I miss something?
|
GNU applications couldn't indeed run without a kernel. v.g. without anything capable of performing system calls, interfacing with the hardware…
The libc enabling the interface between application programs and system calls (in kernel progams) was the key element.
libc was already compatible with many systems when Stallman started his GNU project in the early 80s.
| Can OS work without kernel? |
1,490,106,000,000 |
Why aren't .zips obsolete, now that most, if not all, modern kernels support on-the-fly compression?
|
.zip files are not only used for commpresion, many other file fomats may just be .zip files at heart. Many other file extensions are really just .zip files at heart but make it makes easier for software to read what is in them while also making it easier for files to be shared and stored. Imagine having to send a folder to someone and making sure you didn't save something inside it. I remember watching a youtube video about this, but I can't seem to find it. However if you take even a .docx file and rename it to a .zip then when you extract it i think it will make more sense.
| Why are zips still used even when kernels compress files by default? |
1,490,106,000,000 |
we are trying to upgrade our RHEL server 7.6 to RHEL 8.4
as
leapp preupgrade --no-rhsm --enablerepo BaseOS --enablerepo AppStream
but finally we get the following errors
============================================================
UPGRADE INHIBITED
============================================================
Upgrade has been inhibited due to the following problems:
1. Inhibitor: The installed OS version is not supported for the in-place upgrade to RHEL 8
2. Inhibitor: Detected loaded kernel drivers which have been removed in RHEL 8. Upgrade cannot proceed.
3. Inhibitor: Missing required answers in the answer file
Consult the pre-upgrade report for details and possible remediation.
============================================================
UPGRADE INHIBITED
============================================================
any idea how to continue from above stage?
note:
under /etc/leapp/files , we set the following files
ls -ltr /etc/leapp/files
total 3100
-rw-r--r-- 1 root root 47708 Aug 15 12:55 unsupported_pci_ids.json
-rw-r--r-- 1 root root 20711 Aug 15 12:55 unsupported_driver_names.json
-rw-r--r-- 1 root root 3057300 Aug 15 12:55 pes-events.json
-rw-r--r-- 1 root root 39703 Aug 15 12:55 repomap.csv
more /var/log/leapp/leapp-report.txt
Risk Factor: high (inhibitor)
Title: The installed OS version is not supported for the in-place upgrade to RHEL 8
Summary: The supported OS releases for the upgrade process:
RHEL-ALT 7.6
RHEL-SAPHANA 7.7
RHEL 7.9
|
Inhibitor: The installed OS version is not supported for the in-place upgrade to RHEL 8
You need to upgrade to the latest RHEL 7 minor version first (7.9), see Supported in-place upgrade paths for Red Hat Enterprise Linux (there are some exceptions for different architectures, but I assume these do not apply to you because you got this error).
Inhibitor: Missing required answers in the answer file
Check the pre-upgrade report in leapp-report.txt and answer the questions. See the upgrade documentation Chapter 3. Reviewing the pre-upgrade report for more details.
Inhibitor: Detected loaded kernel drivers which have been removed in RHEL 8. Upgrade cannot proceed.
Removed drivers are also in the pre-upgrade report. Check which drivers were removed (full list is available here) and unload the modules using rmmod before the upgrade.
| upgrade RHEL version 7.6 to RHEL 8.4 ( offline ) |
1,303,906,768,000 |
It's a situation that has happened quite often to me: after I press (with a different intention) Ctrl-S in a terminal, the interaction (input or output) with it is frozen. It's probably a kind of "scroll lock" or whatever.
How do I unfreeze the terminal after this?
(This time, I have been working with apt-shell inside a bash inside urxvt--not sure which of them is responsible for the special handling of Ctrl-S: I was searching the history of commands backwards with C-r, as usual for readline, but then I wanted to go "back" forwards through the history with the usual--at least in Emacs--C-s (1, 2, 3), but that caused the terminal to freeze. Well, scrolling/paging to view past things still works in the terminal, but no interaction with the processes run there.)
|
Press Ctrl-Q to unfreeze.
This stop/start scheme is software flow control, which is implemented by the OS's terminal device driver rather than the shell or terminal emulator. It can be configured with the stty command.
To disable it altogether, put stty -ixon in a shell startup script such as ~/.bashrc or ~/.zshrc. To instead just allow any key to get things flowing again, use stty ixany.
| How to unfreeze after accidentally pressing Ctrl-S in a terminal? |
1,303,906,768,000 |
Ctrl+S stops all output to the terminal which can be restarted with Ctrl+Q.
But, why does Ctrl+S exist in the first place? What problem was trying to be solved by putting that control sequence in place?
|
Long before there were computers, there were teleprinters (a.k.a. teletypewriters, a.k.a. teletypes). Think of them as roughly the same technology as a telegraph, but with some type of keyboard and some type of printer attached to them.
Because teletypes already existed when computers were first being built, and because computers at the time were room-sized, teletypes became a convenient user interface to the first computers – type in a command, hit the send button, wait for a while, and the output of the command is printed to a sheet of paper in front of you.
Software flow control originated around this era – if the printer couldn't print as fast as the teletype was receiving data, for instance, the teletype could send an XOFF flow control command (Ctrl+S) to the remote side saying "Stop transmitting for now", and then could send the XON flow control command (Ctrl+Q) to the remote side saying "I've caught up, please continue".
And this usage survives in Unix because modern terminal emulators are emulating physical terminals (like the vt100) which themselves were (in some ways) emulating teletypes.
| What is the point of Ctrl-S? |
1,303,906,768,000 |
I am a cat-owner and a cat-lover. But I don't like it when my cat sits on my keyboard and pushes randoms keys and messes everything up.
I have an idea to have a function key that turns off the keyboard (except for one special key combination). I know there is already Ctl-S, but this freezes the keyboard and keeps track of the input until the keyboard is unlocked.
Is there any way have the keyboard disregard all input except one hard-to-press-accidentally key combination?
Bonus points: Is there any way to do the same thing in Windows?
|
Open vim
Even the most intelligent cat will not be able to exit vim.
| Keyboard set to "cat mode" |
1,303,906,768,000 |
Suppose I press the A key in a text editor and this inserts the character a in the document and displays it on the screen. I know the editor application isn't directly communicating with the hardware (there's a kernel and stuff in between), so what is going on inside my computer?
|
There are several different scenarios; I'll describe the most common ones. The successive macroscopic events are:
Input: the key press event is transmitted from the keyboard hardware to the application.
Processing: the application decides that because the key A was pressed, it must display the character a.
Output: the application gives the order to display a on the screen.
GUI applications
The de facto standard graphical user interface of unix systems is the X Window System, often called X11 because it stabilized in the 11th version of its core protocol between applications and the display server. A program called the X server sits between the operating system kernel and the applications; it provides services including displaying windows on the screen and transmitting key presses to the window that has the focus.
Input
+----------+ +-------------+ +-----+
| keyboard |------------->| motherboard |-------->| CPU |
+----------+ +-------------+ +-----+
USB, PS/2, … PCI, …
key down/up
First, information about the key press and key release is transmitted from the keyboard to the computer and inside the computer. The details depend on the type of hardware. I won't dwell more on this part because the information remains the same throughout this part of the chain: a certain key was pressed or released.
+--------+ +----------+ +-------------+
-------->| kernel |------->| X server |--------->| application |
+--------+ +----------+ +-------------+
interrupt scancode keysym
=keycode +modifiers
When a hardware event happens, the CPU triggers an interrupt, which causes some code in the kernel to execute. This code detects that the hardware event is a key press or key release coming from a keyboard and records the scan code which identifies the key.
The X server reads input events through a device file, for example /dev/input/eventNNN on Linux (where NNN is a number). Whenever there is an event, the kernel signals that there is data to read from that device. The device file transmits key up/down events with a scan code, which may or may not be identical to the value transmitted by the hardware (the kernel may translate the scan code from a keyboard-dependent value to a common value, and Linux doesn't retransmit the scan codes that it doesn't know).
X calls the scan code that it reads a keycode. The X server maintains a table that translates key codes into keysyms (short for “key symbol”). Keycodes are numeric, whereas keysyms are names such as A, aacute, F1, KP_Add, Control_L, … The keysym may differ depending on which modifier keys are pressed (Shift, Ctrl, …).
There are two mechanisms to configure the mapping from keycodes to keysyms:
xmodmap is the traditional mechanism. It is a simple table mapping keycodes to a list of keysyms (unmodified, shifted, …).
XKB is a more powerful, but more complex mechanism with better support for more modifiers, in particular for dual-language configuration, among others.
Applications connect to the X server and receive a notification when a key is pressed while a window of that application has the focus. The notification indicates that a certain keysym was pressed or released as well as what modifiers are currently pressed. You can see keysyms by running the program xev from a terminal. What the application does with the information is up to it; some applications have configurable key bindings.
In a typical configuration, when you press the key labeled A with no modifiers, this sends the keysym a to the application; if the application is in a mode where you're typing text, this inserts the character a.
Relationship of keyboard layout and xmodmap goes into more detail on keyboard input. How do mouse events work in linux? gives an overview of mouse input at the lower levels.
Output
+-------------+ +----------+ +-----+ +---------+
| application |------->| X server |---····-->| GPU |-------->| monitor |
+-------------+ +----------+ +-----+ +---------+
text or varies VGA, DVI,
image HDMI, …
There are two ways to display a character.
Server-side rendering: the application tells the X server “draw this string in this font at this position”. The font resides on the X server.
Client-side rendering: the application builds an image that represents the character in a font that it chooses, then tells the X server to display that image.
See What are the purposes of the different types of XWindows fonts? for a discussion of client-side and server-side text rendering under X11.
What happens between the X server and the Graphics Processing Unit (the processor on the video card) is very hardware-dependent. Simple systems have the X server draw in a memory region called a framebuffer, which the GPU picks up for display. Advanced systems such as found on any 21st century PC or smartphone allow the GPU to perform some operations directly for better performance. Ultimately, the GPU transmits the screen content pixel by pixel every fraction of a second to the monitor.
Text mode application, running in a terminal
If your text editor is a text mode application running in a terminal, then it is the terminal which is the application for the purpose of the section above. In this section, I explain the interface between the text mode application and the terminal. First I describe the case of a terminal emulator running under X11. What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'? may be useful background here. After reading this, you may want to read the far more detailed What are the responsibilities of each Pseudo-Terminal (PTY) component (software, master side, slave side)?
Input
+-------------------+ +-------------+
----->| terminal emulator |-------------->| application |
+-------------------+ +-------------+
keysym character or
escape sequence
The terminal emulator receives events like “Left was pressed while Shift was down”. The interface between the terminal emulator and the text mode application is a pseudo-terminal (pty), a character device which transmits bytes. When the terminal emulator receives a key press event, it transforms this into one or more bytes which the application gets to read from the pty device.
Printable characters outside the ASCII range are transmitted as one or more byte depending on the character and encoding. For example, in the UTF-8 encoding of the Unicode character set, characters in the ASCII range are encoded as a single bytes, while characters outside that range are encoded as multiple bytes.
Key presses that correspond to a function key or a printable character with modifiers such as Ctrl or Alt are sent as an escape sequence. Escape sequences typically consist of the character escape (byte value 27 = 0x1B = \033, sometimes represented as ^[ or \e) followed by one or more printable characters. A few keys or key combination have a control character corresponding to them in ASCII-based encodings (which is pretty much all of them in use today, including Unicode): Ctrl+letter yields a character value in the range 1–26, Esc is the escape character seen above and is also the same as Ctrl+[, Tab is the same as Ctrl+I, Return is the same as Ctrl+M, etc.
Different terminals send different escape sequences for a given key or key combination. Fortunately, the converse is not true: given a sequence, there is in practice at most one key combination that it encodes. The one exception is the character 127 = 0x7f = \0177 which is often Backspace but sometimes Delete.
In a terminal, if you type Ctrl+V followed by a key combination, this inserts the first byte of the escape sequence from the key combination literally. Since escape sequences normally consist only of printable characters after the first one, this inserts the whole escape sequence literally. See key bindings table? for a discussion of zsh in this context.
The terminal may transmit the same escape sequence for some modifier combinations (e.g. many terminals transmit a space character for both Space and Shift+Space; xterm has a mode to distinguish modifier combinations but terminals based on the popular vte library don't). A few keys are not transmitted at all, for example modifier keys or keys that trigger a binding of the terminal emulator (e.g. a copy or paste command).
It is up to the application to translate escape sequences into symbolic key names if it so desires.
Output
+-------------+ +-------------------+
| application |-------------->| terminal emulator |--->
+-------------+ +-------------------+
character or
escape sequence
Output is rather simpler than input. If the application outputs a character to the pty device file, the terminal emulator displays it at the current cursor position. (The terminal emulator maintains a cursor position, and scrolls if the cursor would fall under the bottom of the screen.) The application can also output escape sequences (mostly beginning with ^[ or ^]) to tell the terminal to perform actions such as moving the cursor, changing the text attributes (color, bold, …), or erasing part of the screen.
Escape sequences supported by the terminal emulator are described in the termcap or terminfo database. Most terminal emulator nowadays are fairly closely aligned with xterm. See Documentation on LESS_TERMCAP_* variables? for a longer discussion of terminal capability information databases, and How to stop cursor from blinking and Can I set my local machine's terminal colors to use those of the machine I ssh into? for some usage examples.
Application running in a text console
If the application is running directly in a text console, i.e. a terminal provided by the kernel rather than by a terminal emulator application, the same principles apply. The interface between the terminal and the application is still a byte stream which transmits characters, with special keys and commands encoded as escape sequences.
Remote application, accessed over the network
Remote text application
If you run a program on a remote machine, e.g. over SSH, then the network communication protocol relays data at the pty level.
+-------------+ +------+ +-----+ +----------+
| application |<--------->| sshd |<--------->| ssh |<--------->| terminal |
+-------------+ +------+ +-----+ +----------+
byte stream byte stream byte stream
(char/seq) over TCP/… (char/seq)
This is mostly transparent, except that sometimes the remote terminal database may not know all the capabilities of the local terminal.
Remote X11 application
The communication protocol between applications an the server is itself a byte stream that can be sent over a network protocol such as SSH.
+-------------+ +------+ +-----+ +----------+
| application |<---------->| sshd |<------>| ssh |<---------->| X server |
+-------------+ +------+ +-----+ +----------+
X11 protocol X11 over X11 protocol
TCP/…
This is mostly transparent, except that some acceleration features such as movie decoding and 3D rendering that require direct communication between the application and the display are not available.
| How do keyboard input and text output work? |
1,303,906,768,000 |
Where can I find a complete list of the keyboard combinations which send signals in Linux?
Eg:
Ctrl+C - SIGINT
Ctrl+\ - SIGQUIT
|
The Linux N_TTY line discipline only sends three different signals: SIGINT, SIGQUIT, and SIGTSTP. By default the following control characters produce the signals:
Ctrl+C - SIGINT
Ctrl+\ - SIGQUIT
Ctrl+Z - SIGTSTP
| List of terminal generated signals (eg Ctrl-C -> SIGINT) |
1,303,906,768,000 |
Is there a way from command line to retrieve the list of all available
keyboard layouts and relative variants?
I need to list all the valid layout/variants choices to be used then from setxkbmap.
Also about the layout toggle options, is there a way to retrieve a list of all available choices (e.g. grp:shift_caps_toggle , ...)
I know that with
setxkbmap -query
I retrieve the list of my current ones, but I need the whole list of options.
UPDATE:
I've been told about the command
man xkeyboard-config
which provides all the info to the command line.
Furthermore, using
man -P cat xkeyboard-config
the output goes to stdout and can be parsed with scripts or c code
|
Try looking in /usr/share/X11/xkb/symbols as described on the setxkbmap man page. The options can be found in various files, try doing a grep -rinH alts_toggle /usr/share/X11/xkb. /usr/share/X11/xkb/rules/xorg.xml looks like a good choice.
| List all valid kbd layouts, variants and toggle options (to use with setxkbmap) |
1,303,906,768,000 |
My terminal setup is gnome-terminal + tmux + zsh with vi bindings.
In applications like vim or even in the zsh's command line vi editing mode, I need to frequently hit the ESC key but there is a small delay before the effects of this key take place. See GNU Screen makes Vim ESC key slow
After some experimentation, I found that hitting ESC key and immediately another key (say b) has the same effect as hitting Alt+b. I don't know why this is the case (probably for legacy reasons when there was no Alt? I don't know). Either way, I have two Alt keys and I don't want this behaviour with my ESC key. I have tried with C+[ and its the same problem with that too.
I'm not sure who is responsible for this, gnome-terminal or tmux or my OS itself (Ubuntu Natty). Any ideas on how to address this would be great.
Update: I checked without tmux on a different terminal (LXTerminal) and the delay is present there too.
|
Here's an actual fix. Add the following to .tmux.conf:
set -s escape-time 0
As mentioned in the comments: The server may need to be restarted.
tmux kill-server kills the server; you may need to restart it.
Alternatively, you can reload the configuration file
from the command prompt inside tmux by typing your tmux prefix
(default Ctrl+B) followed by :
and entering source-file ~/.tmux.conf.
| ESC key causes a small delay in terminal due to its Alt+ behavior |
1,303,906,768,000 |
I use an Apple wired keyboard on Linux. By default the function keys (F1, F2, F3, etc) require the fn key to be pressed for them to work. Without the fn key, these keys control the features like Screen Brightness, Volume, and Music Track Control.
Is there any way to swap these around, so the Function keys do not require the fn modifier, but the other functions (Brightness etc) do?
|
You need to add 0 or 2 into /sys/module/hid_apple/parameters/fnmode.
i.e.:
echo 2 > /sys/module/hid_apple/parameters/fnmode
There seems to be some confusion regarding what the difference between the two values might be. Quoting the Ubuntu documentation:
0 = disabled : Disable the 'fn' key. Pressing 'fn'+'F8' will behave
like you only press 'F8'
1 = fkeyslast : Function keys are used as
last key. Pressing 'F8' key will act as a special key. Pressing
'fn'+'F8' will behave like a F8.
2 = fkeysfirst : Function keys are
used as first key. Pressing 'F8' key will behave like a F8. Pressing
'fn'+'F8' will act as special key (play/pause).
Note that this also works for me on Fedora.
As several people have commented, this change is temporary. You can stick it in your login shell's RC file or into cron so that you don't have to worry about it.
You can also change your driver settings to make this change permanent, like so:
echo options hid_apple fnmode=2 | sudo tee -a /etc/modprobe.d/hid_apple.conf
sudo update-initramfs -u -k all
# reboot when convenient
credits to https://askubuntu.com/a/7553
| On an Apple Keyboard under Linux, how do I make the Function keys work without the fn modifier key? |
1,303,906,768,000 |
Whenever I'm at the console login, I press up arrow intentionally to see the previously typed commands. But I see this ^[[A.
But when I press Ctrl Alt Print Screen Scroll Lock Pause Break Page Up Page Down Win keys doesn't echo any characters.
What might be the reason behind?
Does ^[[A sort of characters imply anything?
|
Keyboards send events to the computer. An event says “scan code nnn down” or “scan code nnn up”. At the other end of the chain, applications running in a terminal expect input in the form of a sequence of characters. (Unless they've requested raw access, like the X server does.) When you press A, the keyboard sends the information “scan code 38 down”. The console driver looks up its keymap and transforms this into “character a” (if no modifier key is pressed).
When you press a key or key combination that doesn't result in a character, the information needs to be encoded in terms of characters. A few keys and key combinations have corresponding control characters, e.g. Ctrl+A sends the character ␁ (byte value 1), Return sends the character ␍ (Ctrl+M, byte value 13), etc. Most function keys don't have a corresponding character and instead send a sequence of characters that starts with the ␛ (escape, byte value 27) character. For example, the key Up is translated into the escape sequence ␛[A (three characters: escape, open bracket, capital A).
The user name prompt on the console is dumb and doesn't understand most escape sequences. It doesn't have the line edition and history features that you're used to: those are provided by the shell, and until you log in, you don't have a shell. So it simply displays the escape sequence. There is no glyph for the ␛ character, so it's displayed as ^[. The ^ sign is traditionally used as a prefix for control characters, and escape is ^[ because of its byte value: it's the byte value of [, minus 64.
If you press Up at a shell prompt, this sends the same 3-character sequence to your shell. The shell interprets this as a command sequence (typically to recall the previous history item). If you press Ctrl+V then Up at a shell prompt, this inserts the escape sequence at the prompt: Ctrl+V is a command to insert the next character literally instead of interpreting it as a command, so the ␛ character is not interpreted as the start of an escape sequence.
Some keys are only modifiers and are not transmitted to terminal applications. For example, when you press Shift, this information stays in the terminal driver, and is taken into account if you then press A, so the driver sends A to the application instead of a.
Additionally some function keys may not be mapped in your console.
For a similar view in the GUI, see What is bash's meta key?
| Is there any reason why I get ^[[A when I press up arrow at the console login screen? |
1,303,906,768,000 |
I have a standard keyboard with numerical keys on the right side (I guess it's called 104-key keyboard). I want to use the numerical keys only as numerical keys. That means I don't want the NumLock to switch on and off the numerical keys.
However, sometimes it happens (I don't know how, perhaps by me accidentally hitting the NumLock key) that the NumLock is turned off, and I have to press it again. This is extremely annoying.
Is it possible to disable switching off NumLock?
In other words: I want my numerical keys to always act as number keys, and to disable the NumLock switch.
I am using Debian and LXDE (Openbox).
UPDATE:
I have been using now for several years the solution, where I use in Openbox to execute a script when NumLock key is pressed. This script then turns NumLock on again.
<keybind key="Num_Lock">
<action name="Execute">
<command>numlock-on.sh</command>
</action>
</keybind>
apart from being a dirty hack, this does not work reliably. Somehow, still it happens to me that the numlock key gets disabled on my keyboard.
I am frustrated with the idea of a numlock key. The concept of numlock and Caps Lock are pure evil.
Anyway, I tried the second solution, where I put the following into my openbox autostart script:
xmodmap -e 'keycode 77 = Escape'
but this does not work at all.
First, when I log in to openbox, everything works fine, and the numerical keys work as numerical keys.
But when I press numlock, it not only disables the numerical keys, but when I press 7 for example, I get OH, and then the numerical keys serve as arrow keys.
Pressing NumLock key again does not enable numerical keys. I have to log out and log back in again.
So the xmodmap solution did not work as expected.
How can I once and for all disable completely the satanic feature of NumLock key?
|
I have actually been able to solve this once and for all with another way:
There is a whole thread about this: https://codereview.stackexchange.com/a/147817/104270
But actually it is as easy as calling:
# the program `numlockx` is from the package `numlockx`
# the program `setxkbmap` is from the package `x11-xkb-utils`
numlockx on
setxkbmap -option numpad:mac
after your GUI login. I myself am using it, and it's working flawlessly.
| Keep NumLock always on |
1,303,906,768,000 |
Playing with xmodmap I encountered a modifier key I hadn't heard of: Mode_switch. It seems to have something to do with inserting special characters.
I assigned it to a key but it seems to have no effect. What is it for? Is it different from ISO_Level3_Shift (Alt Gr)?
|
Mode_switch is the old-style (pre-XKB) name of the key that is called AltGr on many keyboard layouts. It is similar to Shift, in that when you press a key that corresponds to a character, you get a different character if Shift or AltGr is also pressed. Unlike Shift, Mod_switch is not a modifier in the X11 sense because it normally applies to characters, not to function keys, so applications only need to perform a character lookup to obtain the desired effect.
ISO_Level3_Shift is the XKB version of this key. Generally speaking, XKB is a lot more complicated and can do some extra fancy stuff. XKB's mechanism is more general as it allows keyboard layouts to vary in which keys are influenced by which modifiers, it generalizes sticky (CapsLock-style) and simultaneous-press (Shift-style) modifiers and so on.
| What is the Mode_switch modifier for? |
1,303,906,768,000 |
I am looking for an explanation of what happens in Linux when this key combination is pressed to change the current terminal. In particular, what software component intercepts this key combination and changes the terminal? Is it the kernel? If it is the kernel, could you provide the location of the source file which handles this?
Edit:
I want to understand how this works in both a graphical (X11) and text-based environment.
|
It is the kernel. Keep in mind the keyboard is hardware and everything that happens there passes through the kernel; in the case of VT switching, it handles the event completely itself and does not pass anything on to userspace (however, I believe there is an ioctl related means by which userspace programs can be notified of a switch occurring involving them and perhaps affect it, which X no doubt does).
The kernel has a keymap build into it; this can be modified while running with loadkeys, and viewed with dumpkeys:
[...]
keycode 59 = F1 F13 Console_13 F25
alt keycode 59 = Console_1
control alt keycode 59 = Console_1
keycode 60 = F2 F14 Console_14 F26
alt keycode 60 = Console_2
control alt keycode 60 = Console_2
keycode 61 = F3 F15 Console_15 F27
alt keycode 61 = Console_3
control alt keycode 61 = Console_3
[...]
The kernel source contains a default keymap file which looks exactly like this; for 3.12.2 it's src/drivers/tty/vt/defkeymap.map. You'll also notice there is a corresponding defkeymap.c file (this can be generated with loadkeys --mktable). The handling is in keyboard.c (all these files are in the same directory) which calls set_console() from vt.c:
» grep set_console *.c
keyboard.c: set_console(last_console);
keyboard.c: set_console(i);
keyboard.c: set_console(i);
keyboard.c: set_console(value);
vt.c:int set_console(int nr)
vt_ioctl.c: set_console(arg);
I edited some hits out of that list; you can see the function signature on the second last line.
So these are the things involved in the switching. If you look at the sequence of calls, eventually you come back to kbd_event() in keyboard.c. This is registered as an event handler for the module:
(3.12.2 drivers/tty/vt/keyboard.c line 1473)
MODULE_DEVICE_TABLE(input, kbd_ids);
static struct input_handler kbd_handler = {
.event = kbd_event, <--- function pointer HERE
.match = kbd_match,
.connect = kbd_connect,
.disconnect = kbd_disconnect,
.start = kbd_start,
.name = "kbd",
.id_table = kbd_ids,
};
int __init kbd_init(void)
{
[...]
error = input_register_handler(&kbd_handler);
Hence, kbd_event() should be called when something bubbles up from the actual hardware driver (probably something from drivers/hid/ or drivers/input/). However, you won't see it referred to as kbd_event outside of that file, since it is registered via a function pointer.
Some resources for scrutinizing the kernel
The Linux Cross Reference Identifier Search is a great tool.
The Interactive Linux Kernel Map is an interesting graphical front end to the cross reference tool.
There are a few historical archives of the massive Linux Kernel Mailing List (LKML), which goes back to at least 1995; some of them are not maintained and have broken search features, but the gmane one seems to work very well. People have asked a lot of questions on the mail list and it is a primary means of communication amongst the developers as well.
You can inject your own printk lines into the source as a simple means of tracing (not all of the standard C lib can be used in kernel code, including printf from stdio). printk stuff ends up in syslog.
Wolfgang Mauerer wrote a great big book on the 2.6 kernel, Professional Linux Kernel Architecture, which goes through a lot of the source. Greg Kroah-Hartman, one of the principle devs for the last decade, also has a lot of things kicking around.
| What happens when Ctrl + Alt + F<Num> is pressed? |
1,303,906,768,000 |
I'm trying to put in an email the temperature outside in degrees. On my Mac, the degree symbol (°) is Option+Shift+8. But I'm writing the email in Thunderbird on an Ubuntu 10.10 with the default US English keyboard layout. What key combination do I use to get the degree symbol under X11?
EDIT: Gert successfully answered the question... but, bonus points for any easier to use keystroke than what's in his answer!
|
Set up a Compose key. On Ubuntu, this is easily done in the keyboard preferences, “Layout” tab, “Options” subdialog. Caps Lock is a good choice as it's pretty much useless (all remotely serious editors have a command to make the selection uppercase for the rare times it's needed).
Press Compose followed by two characters (occasionally three) to enter a character you don't have on your keyboard. Usually the resulting character combines the two characters you type, for example Compose ' a enters á and Compose s s enters ß. The degree symbol ° is one of the less memorable combinations, it's on Compose o o.
| How do I type the degree symbol under X11 (using a default English keyboard layout)? |
1,303,906,768,000 |
Is there a utility that allows to graphically display the current keyboard layout?
This can be useful, for example, when writing in a foreign language and having the physical keyboard only indicating the local language (positioning of symbols, etc.). I would like to get a display similar to the following:
|
xkeycaps seems to do what you want, if I understand you correctly.
| How to display the current keyboard layout? |
1,303,906,768,000 |
In the magic sysrq key combinations, there is the combination alt+sysrq+r which, according to wikipedia, does the following:
Switch the keyboard from raw mode, the mode used by programs such as
X11 and svgalib, to XLATE mode
What is raw mode? and what is XLATE mode?
Can I switch back to raw mode once I have switched to XLATE mode?
How can I tell which mode my keyboard is in?
|
When you press a key on your keyboard, it sends a numeric code to the computer, called a scan code. The scan code tells the computer which key was pressed; for example, on a typical US keyboard, the A key sends the scan code 30 when you press it (and 158 when you release it). The keyboard driver reports these codes directly to applications when the keyboard is in raw mode (“raw” means unprocessed, straight off-the-keyboard). A few programs use raw mode and do their own keyboard processing; the X server is the most prominent one.
Most programs expect that when you press the A key, the program reads the character a (ASCII 97), and that when you press Shift+A the program reads A (ASCII 65), and when you press Ctrl+A the program reads the Ctrl+A character (ASCII 1). Keys that don't have associated characters send escape sequences, e.g. \e[A for Left, where \e is the ESC character (ASCII 27). The keyboard driver performs this translation when the keyboard is in ASCII mode, also called XLATE mode (short for “translate”). XLATE mode lets applications do character input, at the cost of not having access to such nuances as “Left Shift key pressed” or Ctrl+Shift+A as distinct from Ctrl+A.
The kbd_mode lets you switch between modes, and shows the current mode if you invoke it without any argument.
The magic SysRq key combinations are meant to recover from various nasty situations. One of the key combinations is Alt+SysRq+K to kill all programs on the current virtual console; if that program put the keyboard in raw mode, then you won't be able to type at the login prompt (which will often appear, depending on your system configuration). Pressing Alt+SysRq+R restores the usual (outside X) ASCII mode where you can type characters.
| What is raw keyboard mode? |
1,303,906,768,000 |
Is it possible to display all events that are generated in Xorg? Such as keyboard pressed, mouse events...?
|
A pretty quick search would likely yield xev as a result. It will not show you everything that is pressed or typed in X ever. But rather, will allow you to see information about keycodes and mouse movements.
However, with the -root option, you might be able to get xev to monitor the whole X session. Note, if you do this, you'll make it pretty difficult to actually interact with any program since xev will be capturing all input.
xev -root comes with an implied "YMMV". Another possible solution is to use xinput to get the job done (though you need a recent version (1.6.1 or above)):
$ xinput test-xi2 --root
While the above should be able to capture all events, if your xinput doesn't support test-xi2 or --root, you can use xinput test on a particular keyboard or mouse device.
See also this other question: Record every keystroke and store in a file
| monitoring events (keyboard, mouse) in X |
1,303,906,768,000 |
I need to record every keystroke and store in a file in the user directory ~, when using my account, I am not sudoer and I cannot install programs (like logKeys) in any way. How could I do so using terminal?
NOTE: This question it's not a duplicate of the other mention question; in this question I'm asking about every keystroke, while in the other the asker asked about keystroke in terminal session.
|
xinput test can report all keyboard events to the X server. On a GNU system:
xinput list |
grep -Po 'id=\K\d+(?=.*slave\s*keyboard)' |
xargs -P0 -n1 xinput test
If you want to get key names from the key codes, you could post-process that output with:
awk 'BEGIN{while (("xmodmap -pke" | getline) > 0) k[$2]=$4}
{print $0 "[" k[$NF] "]"}'
Add > file.log to store in a log file. Or | tee file.log to both log and see it.
xinput queries the XinputExtension of the X server. That's as close as you're going to get as a standard (I am not aware of any standard that covers X utilities) or common command to do that. That also does not require root privileges.
If the X server and xinput support version 2 of the XinputExtension, you can use test-xi2 instead of test which gives more information, in particular the state of the modifiers (shift, ctrl, alt...). Example:
$ xinput test-xi2 --root
EVENT type 2 (KeyPress)
device: 11 (11)
detail: 54
flags:
root: 846.80/451.83
event: 846.80/451.83
buttons:
modifiers: locked 0 latched 0 base 0x4 effective: 0x4
group: locked 0 latched 0 base 0 effective: 0
valuators:
windows: root 0x26c event 0x26c child 0x10006e6
You can translate the keycode (in detail) to a keysym with the help of xmodmap -pke again, and the effective modifier bitmask to something more helpful with the help of xmodmap -pm. For instance:
xinput test-xi2 --root | perl -lne '
BEGIN{$"=",";
open X, "-|", "xmodmap -pke";
while (<X>) {$k{$1}=$2 if /^keycode\s+(\d+) = (\w+)/}
open X, "-|", "xmodmap -pm"; <X>;<X>;
while (<X>) {if (/^(\w+)\s+(\w*)/){($k=$2)=~s/_[LR]$//;$m[$i++]=$k||$1}}
close X;
}
if (/^EVENT type.*\((.*)\)/) {$e = $1}
elsif (/detail: (\d+)/) {$d=$1}
elsif (/modifiers:.*effective: (.*)/) {
$m=$1;
if ($e =~ /^Key/){
my @mods;
for (0..$#m) {push @mods, $m[$_] if (hex($m) & (1<<$_))}
print "$e $d [$k{$d}] $m [@mods]"
}
}'
would output:
KeyPress 24 [q] 0x19 [Shift,Alt,Num_Lock]
when I press Shift+Alt+q when num-lock is on.
Note that you don't need to have super-user privileges to install a program. If you have write access to somewhere on the file system where execute permission is granted (your home directory, /tmp, /var/tmp...) then you can copy an xinput command from a compatible system there and execute it.
| Record every keystroke and store in a file |
1,303,906,768,000 |
I have this issue with Lenovo Thinkcentre Edge. Its keyboard has Fn key, which acts in my Ubuntu (with Fluxbox) as if it is always "active/pressed".
I can't use standard F1-F12 keys unless I hold down this stupid key. You see, I'm a programmer so it's really pain to me.
So I decided to remap function keys with xev and xmodmap
I remapped F1-F3 and 'till this point everything is fine, but F4 does some kind of window minimization. When I run xev and hit F4, I don't get a reply from the program with a keycode and stuff, instead the window is minimized and when I maximize the window again there is no response from the key.
Important info: The function of Fn key can't be disabled in the BIOS.
So the question is: Do you have ANY idea how to solve my mystery?
EDIT:
# content of .fluxbox/keys
# click on the desktop to get menus
OnDesktop Mouse1 :HideMenus
OnDesktop Mouse2 :WorkspaceMenu
OnDesktop Mouse3 :RootMenu
# scroll on the desktop to change workspaces
OnDesktop Mouse4 :PrevWorkspace
OnDesktop Mouse5 :NextWorkspace
# scroll on the toolbar to change current window
OnToolbar Mouse4 :PrevWindow {static groups} (iconhidden=no)
OnToolbar Mouse5 :NextWindow {static groups} (iconhidden=no)
# alt + left/right click to move/resize a window
OnWindow Mod1 Mouse1 :MacroCmd {Raise} {Focus} {StartMoving}
OnWindowBorder Move1 :StartMoving
OnWindow Mod1 Mouse3 :MacroCmd {Raise} {Focus} {StartResizing NearestCorner}
OnLeftGrip Move1 :StartResizing bottomleft
OnRightGrip Move1 :StartResizing bottomright
# alt + middle click to lower the window
OnWindow Mod1 Mouse2 :Lower
# control-click a window's titlebar and drag to attach windows
OnTitlebar Control Mouse1 :StartTabbing
# double click on the titlebar to shade
OnTitlebar Double Mouse1 :Shade
# left click on the titlebar to move the window
OnTitlebar Mouse1 :MacroCmd {Raise} {Focus} {ActivateTab}
OnTitlebar Move1 :StartMoving
# middle click on the titlebar to lower
OnTitlebar Mouse2 :Lower
# right click on the titlebar for a menu of options
OnTitlebar Mouse3 :WindowMenu
# alt-tab
Mod1 Tab :NextWindow {groups} (workspace=[current])
Mod1 Shift Tab :PrevWindow {groups} (workspace=[current])
# cycle through tabs in the current window
Control Tab :NextTab
Control Shift Tab :PrevTab
# go to a specific tab in the current window
Mod4 1 :Tab 1
Mod4 2 :Tab 2
Mod4 3 :Tab 3
Mod4 4 :Tab 4
Mod4 5 :Tab 5
Mod4 6 :Tab 6
Mod4 7 :Tab 7
Mod4 8 :Tab 8
Mod4 9 :Tab 9
# open a terminal
Mod1 F1 :Exec x-terminal-emulator
# open a dialog to run programs
Mod1 F2 :Exec fbrun
# volume settings, using common keycodes
# if these don't work, use xev to find out your real keycodes
176 :Exec amixer sset Master,0 1+
174 :Exec amixer sset Master,0 1-
160 :Exec amixer sset Master,0 toggle
# current window commands
Mod1 F4 :Close
Mod1 F5 :Kill
# open the window menu
Mod1 space :WindowMenu
# exit fluxbox
Control Mod1 Delete :Exit
# change to previous/next workspace
Control Mod1 Left :PrevWorkspace
Control Mod1 Right :NextWorkspace
# change to a specific workspace
Control F1 :Workspace 1
Control F2 :Workspace 2
Control F3 :Workspace 3
Control F4 :Workspace 4
#osobni
Mod4 d :ShowDesktop
Mod4 m :Maximize
Mod4 f :Exec firefox
Mod4 u :Exec unison-gtk
Mod4 e :Exec eclipse
Mod4 t :Exec thunderbird
Mod4 q :Exec qutim
Mod4 s :Exec skype
Ubuntu is 12.04 LTS, kernel
3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
|
Press Fn + Num Lock to disable it.
| Switch Fn key state |
1,303,906,768,000 |
When using a tty login shell by entering Ctrl-Alt-F1 from an Ubuntu 12.04 install on a laptop the keyboard seems overly sensitive and if my finger lingers for a moment on a button I end up with repeats of the same letter. Is there a way to adjust keyboard sensitivity that would influence the keyboard response when accessing a login shell from a tty instance?
|
It is called 'keyboard auto repeat rate' and you can set it with kbdrate Mine is set to:
$ sudo kbdrate
Typematic Rate set to 10.9 cps (delay = 250 ms)
You can set same with:
$ sudo kbdrate -r 10.9 -d 250
Typematic Rate set to 10.9 cps (delay = 250 ms)
Check the manual page for exact options:
man kbdrate
Unsure where the default setting is done, but /etc/rc.local, your .bash_profile, .profile or .bashrc sounds like a good place.
| Adjusting keyboard sensitivity in a command line terminal? |
1,303,906,768,000 |
I am using Putty, Suse box and Vim 7.2 combo for editing and I want to remap Ctrl + Arrow keypresses to a particular task. But for some reason, Vim ignores the shortcut, goes into insert mode, and inserts character D (for Ctrl + ←) or character C (for Ctrl + →).
Which part of my keyboard/terminal configuration is to blame and how to fix it?
|
Figure out exactly what escape sequence your terminal sends for Ctrl+arrow by typing Ctrl+V, Ctrl+arrow in insert mode: this will insert the leading ESC character (shown as ^[ in vim) literally, followed by the rest of the escape sequence. Then tell vim about these escape sequences with something like
map <ESC>[5D <C-Left>
map <ESC>[5C <C-Right>
map! <ESC>[5D <C-Left>
map! <ESC>[5C <C-Right>
I seem to recall that Putty has a default setting for Application Cursor Keys mode that's inconvenient (I forget why), you might want to toggle this setting first.
Note that although escape sequences vary between terminals, conflicts (i.e. an escape sequence that corresponds to different keys in different terminals) are rare, so there's no particular need to try to apply the mappings only on a particular terminal type.
| How to fix Ctrl + arrows in Vim? |
1,303,906,768,000 |
This keyboard has only one super key, so I want to remap the menu key to make up for that.
|
Use xev to find the keycode for the key you want to remap. For example if I press Menu key it tells me that that is keycode 135.
Next in my ~/.xmodmaprc file, I add a line like this:
keycode 135 = Super_R
... to make it the right hand windows key. Then all that remains is to activate the key remaps. This usually happens automatically on login to your x session, but if your Desktop Environment doesn't do that you can run it manually as xmodmap ~/.xmodmaprc from a command line or whatever script gets run when you login.
| How to remap the Context Menu key to the Super key |
1,303,906,768,000 |
I regularly ssh to a centos 5 box. Somehow they keys are mapped so that control+d will log me out of my current shell. If I am sudo'ed to another use it puts me back to the previous user. If I am not sudo'ed it just disconnects me. How can I keep this from happening? I regularly use control+d to cancel out of the python interpreter and sometimes I accidentally press it more than once.
|
You're looking for the IGNOREEOF environment variable if you use bash:
IGNOREEOF
Controls the action of an interactive shell on receipt of an EOF character as the sole input.
If set, the value is the number of consecutive EOF characters which must be typed as the
first characters on an input line before bash exits. If the variable exists but does not
have a numeric value, or has no value, the default value is 10. If it does not exist, EOF
signifies the end of input to the shell.
So export IGNOREEOF=42 and you'll have to press Ctrl+D fourty-two times before it actually quits your shell.
POSIX set has an -o ignoreeof setting too. So consult your shell's documentation to see if your shell has this (it should), and to check its exact semantics.
| How can I keep control+d from disconnecting my session? |
1,303,906,768,000 |
Is there a command that exists that can simulate keypresses? I want to pipe some data to it to make it type into a GUI program for me.
|
Yes, it is xdotool.
To simulate a key press, use:
xdotool key <key>
For example, to simulate pressing F2:
xdotool key F2
To simulate pressing crtl + c:
xdotool key ctrl+c
To simulate pressing ctrl + c and then a Backspace:
xdotool key ctrl+c BackSpace
Check man xdotool to get more idea.
You might need to install the xdotool package first to use xdotool command.
| Command to simulate keyboard input |
1,303,906,768,000 |
I had a really bad lockup of my X server and had to do a Sys Rq + r to release my keyboard from X and get into a console. I was able to kill the process that was locking up my system, and continue my work in my still running X server.
Now whenever I e.g. push Alt + F4 to kill a window, my system switches to the 4th console instead of killing the active window. So it seems that my keyboard still is in released mode.
How do I undo my previous Sys Rq + r command, such that I can continue my work in my running X server?
|
I found the solution myself just after asking this question.
To switch back the console in which X is running (usually tty7), from ASCII mode to RAW mode execute the following command:
sudo kbd_mode -s -C /dev/tty7
And now everything works as expected again. :)
More information available in the question: What does raw/unraw keyboard mode mean?
| Recovering from Sys Rq + r |
1,303,906,768,000 |
How can one programmatically "freeze" the Keyboard & Mouse temporarily, so that no one could mess with the system?
There are several possibilities where this is useful. For instance, I have a laptop and I want to make sure no one uses it while I leave, even if somebody knows the password or can guess it (like wife or children), as well as depressing thieves' appetite (as it seems dis-functioning). or I'm doing something remotely so I want to make sure the user at the computer doesn't disturb.
|
Assuming your GUI is X-based (as almost all UNIX GUIs are), use xinput.
First, list your devices:
$ xinput --list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Windows mouse id=6 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Windows keyboard id=7 [slave keyboard (3)]
List the details for your mouse (id=6 in our example):
$ xinput --list-props 6
Device 'Windows mouse':
Device Enabled (112): 1
Coordinate Transformation Matrix (114): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
Device Accel Profile (222): 0
Device Accel Constant Deceleration (223): 1.000000
Device Accel Adaptive Deceleration (224): 1.000000
Device Accel Velocity Scaling (225): 10.000000
Now disable it:
$ export DISPLAY=:0
$ xinput set-int-prop 6 "Device Enabled" 8 0
To enable it do:
$ xinput set-int-prop 6 "Device Enabled" 8 1
The same goes for the keyboard, just replace the int-prop number with the proper id.
Tested and worked on cygwin.
Of course, you have to plan beforehand how will you enable your devices again. such as schedule it on cron, re-enable it remotely, or disable just one of them in first place.
| Disable Keyboard & Mouse input on unix (under X) |
1,303,906,768,000 |
What command line tools exist to list and manage X server grabs? (That's grab as in key and pointer grabs, i.e. restricting the use of a particular key or mouse button to a particular application, or constricting the mouse pointer to remain in a particular screen area.) I'm looking for a hypothetical xgrab utility that would show things like
Key 0x00f00ba5 0x123 0
Button 0x00f00ba5 2
Pointer 0x00abcdef
meaning that there has been a call to XGrabKey(display, 0x123, 0, 0x00f00ba5, ...) and so on with XGrabButton, XGrabPointer, XGrabKeyboard, XGrabServer (if possible). The display format doesn't matter, what I want is some way to see who's grabbing what, and possibly some way of revoking these grabs (if it's possible, I'm not sure if the X11 API allows that).
|
Recent versions of X (X.org server ≥1.11) support several debugging keysyms, introduced in this commit. When triggered, these perform actions related to grabs.
By default (at least in recent versions), these are disabled (absent from the default keymap).
However, if you have xdotool installed, it is possible to call them, by executing on the command-line:
xdotool key NameOfKey
where NameOfKey is the keysym you want to activate. For example, to print a list of active grabs to the X server log, use xdotool key XF86LogGrabInfo.
Relevant keysyms are:
XF86LogGrabInfo: prints a list of active grabs to the X server log
XF86Ungrab: breaks all active grabs, without killing the application that holds the grabs
XF86ClearGrab: kills all processes that hold active grabs
Note that XF86LogGrabInfo only lists active grabs, not passive grabs such as a grab on a key which isn't currently pressed. If you want to get information about a passive grab, you need to activate the grab: run xdotool key XF86LogGrabInfo while the key chord or mouse button combination you're interested in is pressed. Do something like:
Run sleep 1; xdotool key XF86LogGrabInfo
Within 1 second, press the key chord or mouse button combination.
After 1 second, release the key/button.
Check the “Active grab …” information in the X server log (often /var/log/Xorg.0.log).
| Manipulating X key and pointer grabs on the command line |
1,303,906,768,000 |
It's like this: “ (U+201C) ” (U+201D).
|
In Gnome, you would press and hold down Ctrl+Shift, then type u201c.
Of course, that won't work in Gnome Terminal if Ctrl+Shift+c is bound to Copy, in which case type it in GEdit and paste it in, or learn how to enter it in your editor of choice.
| how to type “smart quotes” (U+201C, U+201D) |
1,303,906,768,000 |
I'm trying to inject keystrokes into the input daemon so as to simulate typing from a Bash script. Is this possible, and if so, how can I make it happen?
|
If you are operating at the X level (as in Gilles' question), then use xdotool like so:
xdotool key KEYSTROKE_SPECIFIER
Where KEYSTROKE_SPECIFIER can be something like "a" or "F2" or "control+j"
EDIT: I missed your response to Gilles' question, sorry. I'll leave this response here as a solution for the X-case.
| How to inject keystrokes via a shell script? |
1,303,906,768,000 |
Sometimes, when I use synergy between my machines when one is using full-screen VirtualBox guest I get stuck with some weird key modifiers turned on. If they exist on my keyboard (like Shift_L) I can just tap it and their status is reset and I can continue typing in small letters. But some of them are not mapped to my keyboard at all (like ISO_Level3_Shift), so I have no means of turning them off at all!
How to reset them? Right now, all I can do is to reboot the computer, but it's rather embarrassing solution.
All I want is some program that can artificially "tap" all possible keyboard modifiers, so their status would be reset. Can it be done?
I use Mint 14 (a clone of Ubuntu 12.10 Quantal).
|
If you have xdotool installed, you could just simply use
xdotool keyup ISO_Level3_Shift
Which sends a key release (for ISO_Level3_Shift, of course) event to the X server.
But you wanted a program to release all modifier keys.
One could use xdotool to achieve that easily, if not for that I have no idea what modifier keysyms are defined. One possible method of finding them is to parse keysymdef.h:
grep '^#define' /usr/include/X11/keysymdef.h | sed -r 's/^#define XK_(\S*?).*$/\1/;' | grep -E '_(L|R|Level.*)$'
Which returns some keysyms that surely are modifiers. Unfortunately, I can't find any precise definition of a modifier key right now, so I don't know whether that's a complete list.
Appending | xargs xdotool keyup to the above pipeline will release all those keys. On my system, it executes the following command:
xdotool keyup Shift_L Shift_R Control_L Control_R Meta_L Meta_R Alt_L Alt_R Super_L Super_R Hyper_L Hyper_R ISO_Level2_Latch ISO_Level3_Shift ISO_Level3_Latch ISO_Level3_Lock ISO_Level5_Shift ISO_Level5_Latch ISO_Level5_Lock
| How to force release of a keyboard modifiers |
1,303,906,768,000 |
Everything on my system (that needs it) supports UTF-8 just fine.
That's all nice when you want output...
But what if you want easy input ?
At the moment the only non-ASCII chars I can easily type are chars like √© by using AtlGr.But for chars like ‚ÇÇ ¬≤ ‚âà ‚àö œÄ üòÄ at the moment I have to:
Open a browser
Surf to https://www.utf8icons.com or a similar site
Click, type and search a lot on the site to get to a page that contains the symbol i want
Copy it
Paste it in the program where I need it
(Optionally) close the browser
What I'm looking for is a program that can do something like this:
Run in the background in a modern desktop environment (in my case Cinnamon)
Jump to the foreground to show a whole list of reasonably popular UTF-8 symbols after pressing something like F1
Let me click a symbol after which it will be sent to the program I was last using as if it was a keypress
Give me the option to configure it to either stay visible after this "fake keypress" or jump back to background
In short: Are there virtual keyboard programs with support for non-ASCII UTF-8 ?
Actually... I am already happy with any method that improves mine.
Edit: For others ending up here and don't want to read all the answers themselves (or add a answer that's already given):These are the options already mentioned + links to the answers + pro's and contra's.Feel free to add extra solutions below (after providing them as detailed answer):
ibus (usually with CtrlShiftE) ‚Üí Can't get it to work on Cinnamon
onboard ‚Üí pro: Seems to do everything I need + has support for snippets, con: Only (by default) included non-latin layout is for math, other layouts with popular UTF-8 chars have to be created manually
gucharmap ‚Üí pro: Lots of chars and easy to search con: Doesn't easily jump between foreground/background (can probably be handled with a workaround in Cinnamon itself)
kcharselect‚Üí Same pro/con as gucharmap
Solutions from the programs themselves (e.g. Ctrl. for a couple of them) ‚Üí pro: Ideal for that exact program con: Most programs, including the ones where it's needed the most, don't have one + it's not uniform
https://www.unicodeit.net/ ‚Üí pro: Good for long math formula's. con: Same problem as the one I originally stated + useless for non-math symbols
Keyboard with extra symbols ‚Üí pro: Easy con: Small amount of chars + extra keyboard needed for each system
Shortcuts for the most used chars with xcompose ‚Üí pro: Easy con: Depending on your memory (as human, not as computer) it only works for a limited amount of chars
HTML entities to compose - pro/con: Too much of each, see answer
Use CtrlShiftU, Hexcode,Space: pro/con: Same as above
|
You could use Onboard Onscreen Keyboard which is available in most distros.
It allows to create a custom layout with the characters you need, e.g.
In case you don't want to create a new layout it offers a feature called "Snippets" where you have the choice of entering different characters or even text.
In order to show it just create a shortcut in your desktop environment which will simply execute onboard or dbus-send --type=method_call --dest=org.onboard.Onboard /org/onboard/Onboard/Keyboard org.onboard.Onboard.Keyboard.Show
In order to hide it create a shortcut for dbus-send --type=method_call --dest=org.onboard.Onboard /org/onboard/Onboard/Keyboard org.onboard.Onboard.Keyboard.Hide
Or you could toggle visibility with dbus-send --type=method_call --dest=org.onboard.Onboard /org/onboard/Onboard/Keyboard org.onboard.Onboard.Keyboard.ToggleVisible
| What's the best way to actually "type" special UTF-8 chars? |
1,303,906,768,000 |
I am trying to find a way to remap keyboard keys forcefully.
I tried using xmodmap and setxkbmap, but they do not work for one specific application. Such commands work for other normal windowed/applications on X tho.
I think the application may be reading the keyboard raw data and ignoring X input?
So, how to remap keys without using xmodmap and setxkbmap? if it is ever possible to be done using some software.
I also tried xkeycaps, xkbcomp, but did not try loadkeys, as it is running on X.
I found here that I could try setkeycodes, "because after assigning kernel keycode the button should work in xorg", but I also found that "you can't use 'setkeycodes' on USB keyboards", that's my case (I am interested in case someone make it work on ps2 as I think I could use an adapter).
This seemed promising "Map scancodes to keycodes", but after a few tests nothing changed, here are they:
I found keycode "36" ("j" key) at vt1 with showkey
I found scancode "7e" (keypad ".") at vt1 with showkey --scancodes
$cat >/etc/udev/hwdb.d/90-custom-keyboard.hwdb
keyboard:usb:v*p*
keyboard:dmi:bvn*:bvr*:bd*:svn*:pn*:pvr*
KEYBOARD_KEY_7e=36
$udevadm hwdb --update #updates file: /lib/udev/hwdb.bin
$udevadm trigger #should apply the changes but nothing happened
$cat /lib/udev/hwdb.bin |egrep "KEYBOARD_KEY_7e.{10}" -ao
KEYBOARD_KEY_7eleftmeta
$#that cat on hwdb.bin did not change after the commands..
Obs.: did not work either with: KEYBOARD_KEY_7e=j
Some more alternative ways (by @vinc17) to find the keys:
evtest /dev/input/by-id/... or
input-kbd 3 (put the id index found at ls -l /dev/input/by-id/* from ex. event3)
PS.: *If you are interested on testing yourself, the related thread for the application is this: http://forums.thedarkmod.com/topic/14266-keyboard-issue-in-new-version-108/ The issues I have are the same: some keys (KP_Decimal, DownArrow, UpArrow, RightArrow) are ignored and considered all with the same value there "0x00"
|
First find the scancode of the key that needs to be remapped, e.g. with the evtest utility. A line like the following one (with MSC_SCAN in it) should be output:
Event: time 1417131619.686259, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70068
followed by a second one giving the current key code. If no MSC_SCAN line is output, this is due to a kernel driver bug, but the scancode can still be found with the input-kbd utility; evtest should have given the key code, so that it should be easy to find the corresponding line in the input-kbd output (e.g. by using grep).
Once the scancodes of the keys to be remapped have been determined, create a file such as /etc/udev/hwdb.d/98-custom-keyboard.hwdb containing the remappings. The beginning of the file /lib/udev/hwdb.d/60-keyboard.hwdb gives some information. In my case (which works), I have:
evdev:input:b0003v05ACp0221*
KEYBOARD_KEY_70035=102nd # Left to z: backslash bar
KEYBOARD_KEY_70064=grave # Left to 1: grave notsign
KEYBOARD_KEY_70068=insert # F13: Insert
(Before udev 220, I had to use keyboard:usb:v05ACp0221* for the first line.)
The evdev: string must be at the beginning of the line.
Note that the letters in the vendor and product id should be capital letters.
Each KEYBOARD_KEY_ settings should have exactly one space before (note: a line with no spaces will give an error message, and a line with two spaces were silently ignored with old udev versions). KEYBOARD_KEY_ is followed by the scancode in hexadecimal (like what both evtest and input-kbd give). Valid values could be obtained from either the evtest output or the input-kbd output, or even from the /usr/include/linux/input.h file: for instance, KEY_102ND would give 102nd (by removing KEY_ and converting to lower case), which I used above.
After the file is saved, type:
udevadm hwdb --update
to (re)build the database /etc/udev/hwdb.bin (you can check its timestamp). Then,
udevadm trigger --sysname-match="event*"
will take the new settings into account. You can check with evtest.
In 2014, the released udev had incomplete/buggy information in /lib/udev/hwdb.d/60-keyboard.hwdb, but you can look at the latest development version of the file and/or my bug report and discussion concerning the documentation and spacing issues.
If this doesn't work, the problem might be found after temporarily increasing the log level of udevd with udevadm control (see the udevadm(8) man page for details).
For old udev versions such as 204, this method should still work.
| keyboard hard remap keys? |
1,303,906,768,000 |
I'm trying to achieve the following mapping
keycode 135 = <Ctrl-C>
Is it possible to achieve this in some way?
|
That's not possible with xmodmap. I don't think it's possible with XKB either, but I'm not sure.
Is your aim to have a key that's always identical to pressing Ctrl+C (e.g. in a terminal, it would interrupt the running program), or to have a clipboard copy key? If the latter, try
keycode 135 = XF86Copy
The XF86Copy keysym is intended for a copy-to-clipboard key, but I don't know how many applications have that shortcut out-of-the-box.
If you're on Ubuntu, and possibly even if you aren't, the recommended method to set up additional (“multimedia”) keys is keytouch.
If you really want the key to be equivalent to Ctrl+C, your desktop environment or window manager may let you bind the keysym to a command that generates key press and release events for that key combination. If you prefer or must use a DE/WM-agnostic method, you can use xbindkeys to bind an arbitrary shell command to a key, and xmacro to manufacture key events to send to a window. You'll still need to have a keysym associated with the key; a good choice is F13 (or wherever the numbered function keys on your keyboard leave off). Then put this in your ~/.xbindkeysrc:
"{ echo KeySymPress Control_L; echo KeySym C; echo KeySymRelease Control_L; } | xmacroplay"
F13
You'll need to start xbindkeys with your X session — from your ~/.xinitrc or ~/.xsession if you have one, or from the appropriate configuration interface in your DE/WM.
| Mapping key combination with xmodmap |
1,303,906,768,000 |
I was reading this message from the zsh mailing list about key bindings and I'd like to know which key I need to press:
^X^I (I think Ctrl-X Ctrl-I, the capital X and I)
^[^@ (I think Ctrl-Esc-@ ??)
^X^[q(I think Ctrl-X Esc-q ??)
^XQ (I think Ctrl-X and Q ??)
From the Archlinux wiki page on zsh
^[[1;3A
^[[1;3D
From bindkey
^[[1;5C
^[[A
I know that ^[ means Esc, but I'm not sure how to find others.
Is there any official reference or website that lists these?
|
^c is a common notation for Ctrl+c where c is a (uppercase) letter or one of @[\]^_. It designates the corresponding control character. The correspondence is that the numeric code of the control character is the numeric code of the printable character (letter or punctuation symbol) minus 64, which corresponds to setting a bit to 0 in base 2. In addition, ^? often means character 127.
Some keys send a control character:
Escape = Ctrl+[
Tab = Ctrl+I
Return (or Enter or ⏎) = Ctrl+M
Backspace = Ctrl+? or Ctrl+H (depending on the terminal configuration)
Alt (often called Meta because that was the name of the key at that position on historical Unix machines) plus a printable character sends ^[ (escape) followed by that character.
Most function and cursor keys send an escape sequence, i.e. the character ^[ followed by some printable characters. The details depend on the terminal and its configuration. For xterm, the defaults are documented in the manual. The manual is not beginner-friendly. Here are some tips to help:
CSI means ^[[, i.e. escape followed by open-bracket.
SS3 means ^[O, i.e. escape followed by uppercase-O.
"application mode" is something that full-screen programs usually turn on. Some keys send a different escape sequence in this mode, for historical reasons. (There are actually multiple modes but I won't go into a detailed discussion because in practice, if it matters, you can just bind the escape sequences of both modes, since there are no conflicts.)
Modifiers (Shift, Ctrl, Alt/Meta) are indicated by a numerical code. Insert a semicolon and that number just before the last character of the escape sequence. Taking the example in the documentation: F5 sends ^[[15~, and Shift+F5 sends ^[[15;2~. For cursor keys that send ^[[ and one letter X, to indicate a modifier M, the escape sequence is ^[[1;MX.
Xterm follows an ANSI standard which itself is based on historical usage dating back from physical terminals. Most modern terminal emulators follow that ANSI standard and implement some but not all of xterm's extensions. Do expect minor variations between terminals though.
Thus:
^X^I = Ctrl+X Ctrl+I = Ctrl+X Tab
^[^@ = Ctrl+Alt+@ = Escape Ctrl+@. On most terminals, Ctrl+Space also sends ^@ so ^[^@ = Ctrl+Alt+Space = Escape Ctrl+Space.
^X^[q = Ctrl+X Alt+q = Ctrl+X Escape q
^XQ = Ctrl+X Shift+q
^[[A = Up
^[[1;3A = Alt+Up (Up, with 1;M to indicate the modifier M). Note that many terminals don't actually send these escape sequences for Alt+cursor key.
^[[1;3D = Alt+Left
^[[1;5C = Ctrl+Right
There's no general, convenient way to look up the key corresponding to an escape sequence. The other way round, pressing Ctrl+V followed by a key chord at a shell prompt (or in many terminal-based editors) inserts the escape sequence literally.
See also How do keyboard input and text output work? and key bindings table?
| What does the ^ character mean in sequences like ^X^I? |
1,303,906,768,000 |
Is it possible to remap the CapsLock key system wide such that when the CapsLock button is pressed by itself it acts as the escape key and when pressed with another key it acts as the control key?
|
I have found a very good solution called xcape. From the README:
xcape runs as a daemon and intercepts the Control key. If the Control
key is pressed and released on its own, it will generate an Escape key
event.
This makes more sense if you have remapped your Caps Lock key to
Control. Future versions of this program might do that mapping for
you, but for now this is something that you have to do yourself.
| Remap CapsLock to Escape and Control System Wide |
1,303,906,768,000 |
Usually I only install open source programs on my linux box because I don't trust closed source applications. Recently I had to use Dropbox for a university project. I created a separate linux account named work and run (as work) dropbox without installation via a python script. The script also created a symbol in the system tray that provides a GUI for some of Dropbox's functions.
The other day I had to do some maintenance so I opened a virtual terminal (konsole on KDE) and entered my root password for su.
Is there a chance the Dropbox application could have captured my root password?
I use Fedora 20 with KDE 4.14.3.
|
Short answer: Yes.
In the "olden days", it was possible to effectively prevent any other X application from reading a specific input by grabbing it. While this can still be done to this day, the XI2 protocol specification seems to suggest that this can't be done any more (see the description of Raw Events around line 2220). Thus under X alone you are not safe any more - at least not in the usual simple setups. See also the discussion under my answer to How to let a daemon prompt for a password (in Xsession, keyloggersafe)? and the AskUbuntu Q&A referenced there. Needless to say, no terminals are actually doing that - which is why applications like OpenSSH or GnuPG come with their own UI helpers, that grab keyboard (although as mentioned above, it doesn't really help that much these days).
What you could do though would be running an application under a different X server, e.g. a nested X server like Xephyr or Xnest, or VNC based one like Xvnc. Wayland protocol should also provide some protection against eavesdropping.
Apart from the above, the application could have also tried to exploit an unpatched security hole in your system and thus gain elevated privileges. Or do something easier, like putting a su and sudo wrappers into your path before the system ones and thus intercepting the passwords (thanks @Joshua for the comment).
| Can another program on X capture my root password while I type it in a virtual terminal? |
1,303,906,768,000 |
To navigate to the starting and end of a command, I usually use Ctrla and Ctrle.
However, when I work within a GNU screen, those keybinding do not work becuase perhaps they are being used by the GNU screen. Is there another way to move to the starting or the end of the command?
I am on CentOS6.2
|
Ctrl-A followed by the letter 'a' will send the Ctrl-A sequence to the shell.
Or you could map the screen command key to something other than Ctrl-A
| Ctrl-a does not take me to the beginning of the prompt while I am working within a GNU screen |
1,303,906,768,000 |
I followed some post a while ago, and it said to make an ~/.xmodmap file like so:
! Swap caps lock and escape
remove Lock = Caps_Lock
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock
I did, and it now I can swap esc and caps lock by doing xmodmap ~/.xmodmap. I wanted this to be permanent, so I added that command to my ~/.bash_profile, but it doesn't seem to work; I still have to manually xmodmap. As an EEng dropout, I am tempted to just rewire my keyboard }:-) but I know there must be a better way. How can I make this work, permanently?
|
Execute xfce4-settings-manager, in Session and Startup -> Application autostart, add an entry, which executes xmodmap ~/.xmodmap
Or rename the file to ~/.Xmodmap
| How to permanently swap esc and caps lock in xfce / xubuntu? |
1,303,906,768,000 |
How can I configure a shortcut key to send a text string to the current program?
The purpose is to type common entries quicker (email address, street address, phone number, username, favorite quote, etc).
I don't need any further automation than just entering the text.
Gentoo Linux (3.2.12-gentoo)
Xfce Desktop Environment (Version 4.8)
|
One simple approach is xdotool, like
xdotool type 'text'
| Keyboard Shortcut To Send Text Strings To Program |
1,303,906,768,000 |
Some word processing programs have a menu for entering special characters, including non-breaking spaces. It is also possible to copy the character created in the word processing program and paste it into other places, such as a terminal or a website text field. However, it is inconvenient to need to use a word processing program just to generate a non-breaking space in the first place.
How can I use my keyboard directly to enter a non-breaking space?
|
Once upon a time I told my Debian fairy that I want Compose instead of Caps Lock and typing ComposeSpaceSpace now gives me the super solid unbreakable space:
compose space space ! compose space space ! compose space space ! compose space space ! compose space space ! compose space space ! compose space space ! compose space space !
For debianish systems have a look into /etc/default/keyboard, I have the following assigment there: XKBOPTIONS="compose:caps".
Alternatively, if you're using KDE, the "advanced" tab, of the kcmshell4 kcm_keyboard command lets you configure what key to map to compose.
This setting affects the text terminals too... at least in debian...
| How can I write a non-breaking space? [closed] |
1,303,906,768,000 |
Since modern PCs can use two screens at the same time I wonder if it is possible to plug in two keyboards and mouses as well to have the two screens run two (more or less) independent X-sessions at once?
|
In short, yes, this is possible. The relevant search string you are looking for is "Multi-seat X".
The Ubuntu wiki, Gentoo wiki, Debian wiki and Arch wiki all have articles related to multi-seat X. A number of other articles can be found on the Xorg wiki page on multiseat and even more can be found on google.
From what I can tell from these articles, there are two ways to do this:
Multiple X servers, or
Using Xephyr on top of Xorg.
Which of these methods will work for you will depend on the version of Xorg you are running and your hardware. Multiple X servers seem to be the easier route if your hardware setup supports it. There is also work to be done with the display manager, sound server, and other components -- much of which is covered in the various articles linked above.
Additionally, there is a multiseat display manager (MDM) to automate these configurations. It's not yet integrated in most distributions, though (the mdm package in Ubuntu is a homonym).
| Can one PC be used by two users at the same time via dual-monitor? |
1,303,906,768,000 |
Is it possible to set caps lock to switch between inserting numbers and the symbols they normally trigger when one holds shift?
e.g. when you normally press the 9 key, you get a ( unless caps lock is on.
I tried adding this line to my layout file, on /usr/share/X11/xkb/symbols:
key <AE05> { [ percent, 5 ] };
This effectively switches the 'normal' and 'shift' meanings, but it won't work on caps lock - only on shift.
|
Use the following command:
setxkbmap -option caps:shiftlock
| Switch between numbers and symbols on caps lock |
1,303,906,768,000 |
I am on Ubuntu and using a Microsoft keyboard. I want to map my Win key to a Ctrl key. How can I do that?
|
xmodmap lets you modify keymaps. Make a file to hold xmodmap commands (~/.xmodmaprc is a common choice). The Win keys are called "Super" in xmodmap (Super_L and Super_R for the left and right ones). By default they're connected to mod4, so you want to remove them from that modifier and add them to control. Add this to the command file:
remove mod4 = Super_L Super_R
add control = Super_L Super_R
Tell xmodmap to load it with:
$ xmodmap ~/.xmodmaprc
It will only last as long as your X session does, so you'll need to rerun it each time, or put it in something like ~/.xinitrc so it will be run automatically
| Map "windows" key on keyboard to "ctrl" |
1,303,906,768,000 |
I am writing a new custom keyboard layout for Xorg, but there is one particular glyph which does not exist in Unicode. It is, however, easy to create it by using a standard letter plus a combining diacritic mark.
For example, if I want the letter v with a macron below, the sequence U0073+U0331 creates the character that I want.
In my xkb layout definition, I can specify a single Unicode point (here altgr+d is bound to ḏ and altgr+shift+d to Ḏ):
key <AC03> { [ d, D, U1E0F, U1E0E ] }; // d with macron below
But I don't seem to be able to specify a 'combined' Unicode glyph for a single key:
key <AB04> { [ v, V, U0076+U0331, U0056+U0331 ] }; // v with macron below
Is it possible to create a system-wide xkb definition like this?
|
EDIT:
Still trying...
Testing shows that the keymap will ONLY take a single key in each position.
BUT, if you use a rare/never used keysym in the keymap definition, then a global Xmodmap to make THAT keysym output the various unicode characters you need, this'll work.
In the keymap:
key <AB04> { [ v, V, XF86LaunchA, XF86LaunchB ] };
In a global Xmodmap: (perhaps loaded from /etc/profile.d ?)
keysym XF86LaunchA = U0056 U0331
keysym XF86LaunchB = U0076 U0331
There are quite a few unused/special-use keysyms, I chose the LaunchA/B as an example.
| Custom xkb layout in which one key creates two unicode code points |
1,303,906,768,000 |
On my computer I have two USB keyboards plugged in. Instead of having both just type the same key, is it possible for a second keyboard to be setup to run commands instead of typing letters? And If that's not possible, can it be setup to at least type in another language like Russian for example?
|
This is my third answer when I can recommend actkbd... :)
So if you want to configure all keys of second keyboard to run commands not to type letters you can use actkbd... :)
After installing actkbd we need to find what device file is used to receive events from out keyboard:
pbm@tauri ~ $ cat /proc/bus/input/devices
[cut]
I: Bus=0003 Vendor=046d Product=c31c Version=0110
N: Name="Logitech USB Keyboard"
P: Phys=usb-0000:00:1a.0-1.1/input0
S: Sysfs=/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/input/input7
U: Uniq=
H: Handlers=sysrq kbd event5
B: PROP=0
B: EV=120013
B: KEY=1000000000007 ff9f207ac14057ff febeffdfffefffff fffffffffffffffe
B: MSC=10
B: LED=1f
I: Bus=0003 Vendor=046d Product=c31c Version=0110
N: Name="Logitech USB Keyboard"
P: Phys=usb-0000:00:1a.0-1.1/input1
S: Sysfs=/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.1/input/input8
U: Uniq=
H: Handlers=kbd event6
B: PROP=0
B: EV=1b
B: KEY=2010000 397ad801d001 1e000000000000 0
B: ABS=100000000
B: MSC=10
[cut]
On this list you should find your keyboard, and check it handlers. Use sudo actkbd -s -d /dev/input/HANDLER_NAME to check if that handler send events. If you run this command and press key on keyboard (check for keys that you want to bind to commands) you should get something like that:
pbm@tauri ~ $ sudo actkbd -s -d /dev/input/event5
Keys: 57
Keys: 35
If you have keycodes we could create actkbd config file:
pbm@tauri ~ $ sudo nano /etc/actkbd.conf
30:::sudo -u pbm DISPLAY=:0 amarok
//30 is keycode for letter a
When you save that file we should test if configuration works:
pbm@tauri ~ $ sudo actkbd -d /dev/input/event5 -D
When you press key that you have in your config file command from last column of config file will be started.
I think that there is a way to disable sending keys to applications, but I was unable to find it - check out README file.
Instead of trying to disable it using actkbd you could turn off your keyboard in X.
pbm@tauri ~ $ xinput list
[cut]
↳ Logitech USB Keyboard id=12 [slave keyboard (3)]
↳ Logitech USB Keyboard id=11 [slave keyboard (3)]
pbm@tauri ~ $ xinput set-prop 11 "Device Enabled" 0
pbm@tauri ~ $ xinput set-prop 12 "Device Enabled" 0
It should do the work... :) For more information about actkbd check out this answer.
Using actkbd (and few scripts probably) you can also configure your keyboard to change modes from command mode to input mode with Russian letters. For this read Ulrich Schwarz's answer.
| second keyboard to run commands |
1,416,950,169,000 |
I frequently work on pairing stations where there are multiple keyboards installed. I can use setxkbmap with -device <ID> to set the layout for a specific keyboard (using an ID from xinput), but often it's not obvious which keyboard I'm at. It would be better to avoid the back-and-forth of trying both keyboards, so I'd like to write a quick tool to get this information for setxkbmap. I'd expect a typical use case like the following:
$ setxkbmap -device "$(get-keyboard-id)" -layout gb
Press Enter to detect keyboard ID
Which interface provides this information on Linux? Ideally it should work without X, but that's not a requirement (there doesn't seem to be many tools which support this without X).
Findings so far:
Linux must know which keyboard I'm typing on to support different layouts for multiple keyboards simultaneously.
xinput → list.c → list_xi2 → XIQueryDevice provides device IDs usable by setxkbmap.
showkey and xev don't print keyboard IDs.
xinput list-props $ID shows where keyboard events are sent. However, using code from another answer it seems this device doesn't print anything to identify the keyboard.
One almost possible solution is to run xinput --test <ID> & for each keyboard ID and see which one returns something first. The problem with that is figuring out which "keyboards" are actually keyboards:
$ xinput | grep keyboard
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Power Button id=8 [slave keyboard (3)]
↳ Sleep Button id=9 [slave keyboard (3)]
↳ WebCam SC-13HDL10931N id=10 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=11 [slave keyboard (3)]
|
More digging revealed another solution using plain Bash and a normal user account. Script:
#!/usr/bin/env bash
set -o errexit -o nounset -o noclobber -o pipefail
# Remove leftover files and processes on exit
trap 'rm --recursive -- "$dir"; kill -- -$$' EXIT
dir="$(mktemp --directory)"
cd "$dir"
# Log key presses to file
xinput --list --id-only | while read id
do
# Only check devices linked to an event source
if xinput --list-props "$id" | grep --quiet --extended-regexp '^\s+Device Node.*/dev/input/event'
then
xinput test "$id" > "$id" &
fi
done
# Check for key presses
while sleep 0.1
do
for file in *
do
if [[ -s "$file" ]]
then
echo "$file"
exit
fi
done
done
| How to tell which keyboard was used to press a key? |
1,416,950,169,000 |
I recently switched to Ubuntu on my laptop and one thing that almost got me to switch back to Windows is the fact that I can't make Ctrl+Alt to act like Alt Gr.
I have programmed for several years and for example I'm used to make the symbol $ by pressing Ctrl+Alt+4. Here in Ubuntu I have to use Alt Gr+4 which almost makes me insane...
Is there a fix for this?
|
I only use the special signs when I write code so I managed to fix this is Sublime Text.
In Preferences -> Key bindings - User
insert the following:
[
{ "keys": ["ctrl+alt+2"], "command": "insert", "args": {"characters": "@"} },
{ "keys": ["ctrl+alt+3"], "command": "insert", "args": {"characters": "£"} },
{ "keys": ["ctrl+alt+4"], "command": "insert", "args": {"characters": "$"} },
{ "keys": ["ctrl+alt+5"], "command": "insert", "args": {"characters": "€"} },
{ "keys": ["ctrl+alt+7"], "command": "insert", "args": {"characters": "{"} },
{ "keys": ["ctrl+alt+8"], "command": "insert", "args": {"characters": "["} },
{ "keys": ["ctrl+alt+9"], "command": "insert", "args": {"characters": "]"} },
{ "keys": ["ctrl+alt+0"], "command": "insert", "args": {"characters": "}"} },
{ "keys": ["ctrl+alt++"], "command": "insert", "args": {"characters": "\\"} },
{ "keys": ["ctrl+alt+<"], "command": "insert", "args": {"characters": "|"} }
]
| How can I make Ctrl + Alt act like Alt gr in Ubuntu? |
1,416,950,169,000 |
Situation:
When I turn on my Linux Mint 20/19/18/17 Cinnamon the NumLock is Off in the Login window.
Objective:
Turn on NumLock automatically at startup in the Login window.
|
For all versions of Linux Mint
You need to install a program needed for this purpose - numlockx; man page:
sudo apt-get install numlockx
Choose if you wish to achieve the goal through CLI or GUI below.
Linux Mint 20.x / 19.x (LightDM)
GUI; probably most convenient under normal operation:
Once numlockx is installed, the following menu item in Login Window -> Settings called:
Activate numlock
becomes available; as you can see:
This will add the line:
activate-numlock=true
to the following file:
/etc/lightdm/slick-greeter.conf
Linux Mint 18.x / 17.x (MDM)
GUI; probably most convenient under normal operation:
Once numlockx is installed, the following menu item in Login Window -> Options called:
Enable NumLock
becomes available; as you can see:
As pointed out in the other answer, this will add the following line to /etc/mdm/mdm.conf:
EnableNumLock=true
CLI; suitable if you are setting other computers up through SSH, for instance:
Open a text editor you are skilled in with this file, e.g. nano if unsure:
sudoedit /etc/mdm/Init/Default
Add these lines at the beginning of the file:
if [ -x /usr/bin/numlockx ]; then
/usr/bin/numlockx on
fi
As pointed out by Gilles, don't put exec in front of the command.
| Turn on NumLock on startup in Linux Mint in the Login window |
1,416,950,169,000 |
Suppose I have an X application, which grabs keyboard and mouse as its normal mode of operation (e.g. QEMU), but which, due to a bug somewhere, hangs really hard (e.g. gets stuck in Disk sleep). Normally I'd kill an app using kill(1) from a remote terminal, but if the app is in Disk sleep mode, it can't really be killed. I could kill this app's connection to X server by the xkill utility, but this time I can't do this because mouse is grabbed, so xkill will fail to run.
So, how do I release my keyboard and mouse from grab by an X client, if I'm willing to sacrifice this client, but am unable to kill it by the OS means?
|
Although the most well-known use mode of xkill is "click to kill", there's an option -id, which can be supplied with Window Id of the client you want to disconnect from X server. Then, if you can access your X session from a remote terminal/VT, you can use xprop or some other means to get the Id, and pass it to xkill.
Suppose that current active window belongs to the X client who grabbed the keys&mouse. Then the following will kill this client's connection to the X server and thus release keyboard and mouse from the grab:
winid=$(xprop -root _NET_ACTIVE_WINDOW | cut -d# -f2)
xkill -id $winid
This actually worked for me when I tried to get rid of QEMU's grab when QEMU was stuck in Disk sleep.
| How to release keyboard and mouse from grab by a hung unkillable app? [duplicate] |
1,416,950,169,000 |
I've moved from Gnome to i3 on Manjaro, and I'm almost done with configuring the window manager, and terminal colors and whatnot. After some time I just decided to listen to some music, and after a couple of minutes I realized that the volume keys and playback keys don't work.
I have a Razer Blackwidow Stealth 2014 keyboard, so those media keys are actually together with the Function keys. For example: Play/Pause is on F6, and it acts as a media key when I press the Fn key, like in Fn + F6.
|
The search for the answer
After some time messing around with the controls, I've found a post on the old i3 FAQ board: https://faq.i3wm.org/question/3747/enabling-multimedia-keys.1.html
It says to paste the following into i3's .config file (bellow is a lightly modified version, with some lines removed, which are not relevant to this particular question):
# Pulse Audio controls
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +5% #increase sound volume
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -5% #decrease sound volume
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle # mute sound
# Sreen brightness controls
bindsym XF86MonBrightnessUp exec xbacklight -inc 20 # increase screen brightness
bindsym XF86MonBrightnessDown exec xbacklight -dec 20 # decrease screen brightness
# Media player controls
bindsym XF86AudioPlay exec playerctl play-pause
bindsym XF86AudioPause exec playerctl play-pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous
And it didn't work either, however the process of finding the answer is correct.
The real answer
To me, at least, the problem was that after copying those lines, the keys would not work. After some more research, I found out that the volume commands could be a little different, using amixer instead of PulseAudio's pactl.
At the end, those were left like this:
# Media volume controls
bindsym XF86AudioMute exec amixer sset 'Master' toggle
bindsym XF86AudioLowerVolume exec amixer sset 'Master' 5%-
bindsym XF86AudioRaiseVolume exec amixer sset 'Master' 5%+
and they started working.
The playback keys were a little more trickier. I deduced that the .config tells which command is executed to do the action. Then I proceeded to try playerctl play-pause on my terminal. Of course it didn't work, because playerctl was not installed. After installing it (using sudo pacman -S playerctl) those keyboard commands worked just fine too.
| How can I make media keys work with i3? |
1,416,950,169,000 |
I have a mechanical keyboard (Noppoo Choc Mini with Cherry MX Blue switches) and after a few weeks, some key presses are getting sent two times even though I press a single time. I found out that this is a common problem on mechanical keyboards and is called 'chattering' (or 'bouncing').
This comes likely from a hair inside the mechanics of the switch, so my posssibilities are limited here:
Replace the switch manually (soldering, reordering single parts from beyond, ...)
Buy a new one
... or fix it on the software side.
So my question: is there a simple (or complicated, I'll take it all) way to fix this? Is there a kernel-patch, keyboard driver option, smart tool or a hidden settings in X11 to prevent my OS from registering the same key in a very short period of time?
|
Its not a common problem for mech keyboards, and the cherry MX switch was made to stop this problem, because of the way the switch works you have to come back off the contact past the latching point to make another contact its not like a 'dome board.
That said after many years of using most types of mech 'board without ever seeing a problem, I thought I would try a diff *nix distro (arch, I'm a slackware user) on a spare box, as soon as I hit the cli I started to get multiple key presses.
I checked it with another Filco, no change, and then an older ALPS blue switched, then an g80-3000 board with diodes, but nothing stopped it until I changed the BIOS kbrd speed down to normal, it was a problem for all of the boards I used.
From what I have read the above bounce delay setting is often not perfect for cherry switched boards, but as I dont leave the cli I doubt it really matters to me, but might help other users.
It could be a controller problem, I dont use my Noshist's (Noppoos) as I call them, but I did get one of the first batch of the Filco Zero board a few years back and that had a problem with the direction and speed of scan rate so you got lots of transposition errors (like teh) and there is a trick you can do by pressing a credit card (or something like) down at a slight angle into 4 or 5 keys a few times into a basic text editor and checking the results are correct.
The main point of this post is to say that I have never seen a bad cherry switch that was not damaged by some outside force, most often spillage or force from something being dropped onto the board. I have some 30+ cherry switched boards (yeah, its not, er, cough, sniff a problem or anything man ;) going back to a 1984 g80-1000 that works as good as it was new, and never given more than a brush out with a clean paint brush every few months.
Something I have seen (in the last 5-6 years) as mech boards have moved into the realms of a fashion object, is that new users bash the keys too hard, if you do bottom out the keys it should hardly make a sound, and when you dont bottom out you will start to get the best from the board.
The blue switch is the best for a new user to learn with, never start with a red switch.
That said if you type less than a few 1000 words a day or are a gamer there is not really any point in getting a mech board.
/ramble
May 02,
The more I think about this, the more I seem to remember there being some talk that in the Noppoo T&C's or advert it was only guaranteed to work on windows boxes.
They did some trick in the USB/controller to get past the 6KRO (6 key roll over) hard limit that USB has. So they could say it had full, or nKRO, which you only have over PS/2.
ISTR there were people using the Teensy USB to over come this fake USB thing.
Might have just been random key press and no LEDs in Linux and *BSD, apple mac that had the bigger problems.
edit aug'16
I have found this setting in bash that stops the multi key press on the cli. It changes the repeat rate of your keys.
This seems to often be set to
kbdrate -r 32 -d 250
which is the fastest a PC can go.
I found using..
kbdrate -r 9 -d 500
Will even allow a keyboard with problems to work fine
kbdrate -r <chars-per-second> -d <repeat-delay>
| Fix keyboard chattering/bouncing on the software side |
1,416,950,169,000 |
I'm working on an embedded Linux project where I will be developing a program that will run automatically on bootup and interact with the user via a character display and some sort of button array. If we go with a simple GPIO button array, I can easily write program that will look for keypresses on those GPIO lines. However, one of our thoughts was to use a USB number pad device instead for user input. My understanding is that those devices will present themselves to the OS as a USB keyboard. If go down this path, is there a way for my program to look for input on this USB keyboard from within Linux, keeping in mind that there is no virtual terminal or VGA display. When a USB keyboard is plugged in, is there an entity in '/dev' that appears that I can open a file descriptor for?
|
Devices most likely get a file in /dev/input/ named eventN where N is the various devices like mouse, keyboard, jack, power-buttons etc.
ls -l /dev/input/by-{path,id}/
should give you a hint.
Also look at:
cat /proc/bus/input/devices
Where Sysfs value is path under /sys.
You can test by e.g.
cat /dev/input/event2 # if 2 is kbd.
To implement use ioctl and check devices + monitor.
EDIT 2:
OK. I'm expanding on this answer based on the assumption /dev/input/eventN is used.
One way could be:
At startup loop all event files found in /dev/input/. Use ioctl() to request event bits:
ioctl(fd, EVIOCGBIT(0, sizeof(evbit)), &evbit);
then check if EV_KEY-bit is set.
IFF set then check for keys:
ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), &keybit);
E.g. if number-keys are interesting, then check if bits for KEY_0 - KEY9 and KEY_KP0 to KEY_KP9.
IFF keys found then start monitoring event file in thread.
Back to 1.
This way you should get to monitor all devices that meet the wanted criteria. You can't only check for EV_KEY as e.g. power-button will have this bit set, but it obviously won't have KEY_A etc. set.
Have seen false positives for exotic keys, but for normal keys this should suffice. There is no direct harm in monitoring e.g. event file for power button or a jack, but you those won't emit events in question (aka. bad code).
More in detail below.
EDIT 1:
In regards to "Explain that last statement …". Going over in stackoverflow land here … but:
A quick and dirty sample in C. You'll have to implement various code to check that you actually get correct device, translate event type, code and value. Typically key-down, key-up, key-repeat, key-code, etc.
Haven't time, (and is too much here), to add the rest.
Check out linux/input.h, programs like dumpkeys, kernel code etc. for mapping codes. E.g. dumpkeys -l
Anyhow:
Run as e.g.:
# ./testprog /dev/input/event2
Code:
#include <stdio.h>
#include <string.h> /* strerror() */
#include <errno.h> /* errno */
#include <fcntl.h> /* open() */
#include <unistd.h> /* close() */
#include <sys/ioctl.h> /* ioctl() */
#include <linux/input.h> /* EVIOCGVERSION ++ */
#define EV_BUF_SIZE 16
int main(int argc, char *argv[])
{
int fd, sz;
unsigned i;
/* A few examples of information to gather */
unsigned version;
unsigned short id[4]; /* or use struct input_id */
char name[256] = "N/A";
struct input_event ev[EV_BUF_SIZE]; /* Read up to N events ata time */
if (argc < 2) {
fprintf(stderr,
"Usage: %s /dev/input/eventN\n"
"Where X = input device number\n",
argv[0]
);
return EINVAL;
}
if ((fd = open(argv[1], O_RDONLY)) < 0) {
fprintf(stderr,
"ERR %d:\n"
"Unable to open `%s'\n"
"%s\n",
errno, argv[1], strerror(errno)
);
}
/* Error check here as well. */
ioctl(fd, EVIOCGVERSION, &version);
ioctl(fd, EVIOCGID, id);
ioctl(fd, EVIOCGNAME(sizeof(name)), name);
fprintf(stderr,
"Name : %s\n"
"Version : %d.%d.%d\n"
"ID : Bus=%04x Vendor=%04x Product=%04x Version=%04x\n"
"----------\n"
,
name,
version >> 16,
(version >> 8) & 0xff,
version & 0xff,
id[ID_BUS],
id[ID_VENDOR],
id[ID_PRODUCT],
id[ID_VERSION]
);
/* Loop. Read event file and parse result. */
for (;;) {
sz = read(fd, ev, sizeof(struct input_event) * EV_BUF_SIZE);
if (sz < (int) sizeof(struct input_event)) {
fprintf(stderr,
"ERR %d:\n"
"Reading of `%s' failed\n"
"%s\n",
errno, argv[1], strerror(errno)
);
goto fine;
}
/* Implement code to translate type, code and value */
for (i = 0; i < sz / sizeof(struct input_event); ++i) {
fprintf(stderr,
"%ld.%06ld: "
"type=%02x "
"code=%02x "
"value=%02x\n",
ev[i].time.tv_sec,
ev[i].time.tv_usec,
ev[i].type,
ev[i].code,
ev[i].value
);
}
}
fine:
close(fd);
return errno;
}
EDIT 2 (continued):
Note that if you look at /proc/bus/input/devices you have a letter at start of each line. Here B means bit-map. That is for example:
B: PROP=0
B: EV=120013
B: KEY=20000 200 20 0 0 0 0 500f 2100002 3803078 f900d401 feffffdf ffefffff ffffffff fffffffe
B: MSC=10
B: LED=7
Each of those bits correspond to a property of the device. Which by bit-map means, 1 indicate a property is present, as defined in linux/input.h. :
B: PROP=0 => 0000 0000
B: EV=120013 => 0001 0010 0000 0000 0001 0011 (Event types sup. in this device.)
| | | ||
| | | |+-- EV_SYN (0x00)
| | | +--- EV_KEY (0x01)
| | +------- EV_MSC (0x04)
| +----------------------- EV_LED (0x11)
+--------------------------- EV_REP (0x14)
B: KEY=20... => OK, I'm not writing out this one as it is a bit huge.
B: MSC=10 => 0001 0000
|
+------- MSC_SCAN
B: LED=7 => 0000 0111 , indicates what LED's are present
|||
||+-- LED_NUML
|+--- LED_CAPSL
+---- LED_SCROLL
Have a look at /drivers/input/input.{h,c} in the kernel source tree. A lot of good code there. (E.g. the devices properties are produced by this function.)
Each of these property maps can be attained by ioctl. For example, if you want to check what LED properties are available say:
ioctl(fd, EVIOCGBIT(EV_LED, sizeof(ledbit)), &ledbit);
Look at definition of struct input_dev in input.h for how ledbit are defined.
To check status for LED's say:
ioctl(fd, EVIOCGLED(sizeof(ledbit)), &ledbit);
If bit 1 in ledbit are 1 then num-lock are lit. If bit 2 is 1 then caps lock is lit etc.
input.h has the various defines.
Notes when it comes to event monitoring:
Pseudo-code for monitoring could be something in the direction of:
WHILE TRUE
READ input_event
IF event->type == EV_SYN THEN
IF event->code == SYN_DROPPED THEN
Discard all events including next EV_SYN
ELSE
This marks EOF current event.
FI
ELSE IF event->type == EV_KEY THEN
SWITCH ev->value
CASE 0: Key Release (act accordingly)
CASE 1: Key Press (act accordingly)
CASE 2: Key Autorepeat (act accordingly)
END SWITCH
FI
END WHILE
Some related documents:
Documentation/input/input.txt, esp. note section 5.
Documentation/input/event-codes.txt, description of various events etc. Take note to what is mentioned under e.g. EV_SYN about SYN_DROPPED
Documentation/input ... read up on the rest if you want.
| Is it possible for a daemon (i.e. background) process to look for key-presses from a USB keyboard? |
1,416,950,169,000 |
I've written a script to change the brightness of my screen.
It's useful when I am working on text mode and shortcut keys of my keyboard to change brightness doesn't work.
Is it possible to run this script, just by pressing some keys on the keyboard as shortcut, for example Ctrl+Alt+F7?
|
Try xbindkeys.
Your ~/.xbindkeysrc would look something like
"myscript"
Control + Alt + F7
| assign shortcut key to run a script |
1,416,950,169,000 |
I want to write an application in Python that you can use with your default keyboard and a specially designed one for the application. I will design it simply by using a small numerical keyboard with stickers to give actions to the different keys. Both keyboards will be attached by USB.
However, when these keys are pressed, just their regular signals (numbers, operators and enters), will be send to Python and it will not be able to distinguish between the signals from the main keyboard and the special keyboard.
Because Python has (as far as I could find) no method for making this distinguishment, I want to do it on the OS itself. I will be programming it for the Raspberry Pi, so it will be Linux.
So, the main question: How can I remap the keys of a specific keyboard to other keycodes. I thought about using the F-keys which I won't use for other purposes; or just some characters that are not present on any keyboard (supposing that there are such).
Is this possible in Linux/Unix? And if so, how can I do it?
|
If you're using Linux, the best way to distinguish between input devices is to use the Linux Event Interface. After a device's hardware-specific input is decoded, it's converted to an intermediate Linux-specific event structure and made available by reading one or more of the character devices under /dev/input/. This is completely independent of the programming language you use, by the way.
Each hardware device gets its own /dev/input/eventX device, and there are also aggregates (e.g. /dev/input/mice which represents the motion of all mice in the system). Your system may also have /dev/input/by-path and /dev/input/by-id.
There's an ioctl called EVIOCGNAME which returns the name of the device as a humanly-readable string, or you can use something like /dev/input/by-id/usb-Logitech_USB_Gaming_Mouse-mouse.
You open the device, and every time an event arrives from the input hardware, you'll get a packet of data. If you can read C, you can study the file /usr/include/linux/input.h which shows exactly how this stuff works. If you don't, you could read this question which provides all the information you need.
The good thing about the event interface is that you just find out what device you need, and you can read input from that input device only, ignoring all others. You'll also get notifications about keys, buttons and controls you normally wouldn't by just reading the ‘cooked’ character stream from a terminal: even dead keys like Shift, etc.
The bad thing is that the event interface doesn't return ‘cooked’ characters, it just uses numeric codes for keys (the codes corresponding to each key are found in the aforementioned header file — but also in the Python source of event.py. If your input device has unusual keys/buttons, you may need to experiment a bit till you get the right numbers.
| How to distinguish input from different keyboards? |
1,416,950,169,000 |
I have my keyboard layouts (two of them) and switching between them configured via the following command:
setxkbmap -layout us,ru -option -option "grp:lctrl_lshift_toggle,ctrl:nocaps"
Now I want to switch to us layout, using some command line command. Is that possible?
|
You could use xkb-switch (-n switches to next layout):
xkb-switch -n
or xkblayout-state (with set +1 to wrap around, in your case) :
xkblayout-state set +1
or xte from xautomation to simulate Control_L+Shift_L key press/release:
xte 'keydown Control_L' 'keydown Shift_L' 'keyup Shift_L' 'keyup Control_L'
| How do I change currently selected keyboard layout from command line? |
1,416,950,169,000 |
Without unplugging my keyboard I'd like to disable it from the terminal; I was hoping that this could be done using rmmod but based on my currently loaded modules it doesn't look like it is possible.
Does anyone have any ideas?
|
There are pretty good directions on doing it here, titled: Disable / enable keyboard and mouse in Linux.
Example
You can list the devices with this command.
$ xinput --list
"Virtual core pointer" id=0 [XPointer]
"Virtual core keyboard" id=1 [XKeyboard]
"Keyboard2" id=2 [XExtensionKeyboard]
"Mouse2" id=3 [XExtensionKeyboard]
And disable the keyboard with this:
$ xinput set-int-prop 2 "Device Enabled" 8 0
And enable it with this one:
$ xinput set-int-prop 2 "Device Enabled" 8 1
This only works for disabling the keyboard through X. So if you're on a system that isn't running X this won't work.
List of properties
You can use this command to get a list of all the properties for a given device:
$ xinput --list-props 2
Device 'Virtual core keyboard':
Device Enabled (124): 1
Coordinate Transformation Matrix (126): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
| How to disable keyboard? |
1,416,950,169,000 |
I miss using a clicky keyboard at work. It's a fairly quiet office, so I'm stuck using a nearly silent keyboard. The upshot is that I can wear headphones. Is there something in Linux or X that can respond to all keyboard events with a nice, sharp click, giving me that audio feedback? Before you think I'm crazy, I know some high-end keyboards even have speakers in them to reproduce this click for those who like the audio feedback. I'm looking for something at the operating system level.
|
after saying "why not to check out the apt cache?", i come out with a great solution !
[0][~]apt search key sound
bucklespring - Nostalgia bucklespring keyboard sound
bucklespring-data - Nostalgia bucklespring keyboard sound - sound files
soundkonverter - audio converter frontend for KDE
[0][~]sudo apt install bucklespring
[0][~]apropos bucklespring
buckle (1) - Nostalgia bucklespring keyboard sound
[0][~]which buckle
/usr/games/buckle
[0][272][~]buckle -h
bucklespring version 1.4.0
usage: buckle [options]
options:
-d DEVICE use OpenAL audio device DEVICE
-f use a fallback sound for unknown keys
-g GAIN set playback gain [0..100]
-m CODE use CODE as mute key (default 0x46 for scroll lock)
-h show help
-l list available openAL audio devices
-p PATH load .wav files from directory PATH
-s WIDTH set stereo width [0..100]
-v increase verbosity / debugging
as you see in the help message only optional stuff!
so you can just fork it in backgroud as i did (zeroConf).
[0][~]buckle&
[4] 1522
[0][~]Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
it's working!
| Is there something that will generate keyboard's click sounds? |
1,416,950,169,000 |
I need to check some notebooks for bad keyboard keys, and so I'd like to speed that up as much as possible.
I found nothing for this specific task, so my idea is a script that reads the pressed keys and knows all the keyboard keys, so I can bash them quickly and it reports which ones are not pressed yet. I suppose I could accomplish that with either showkey or xev, grepping the output:
xev | grep keysym
Sample output:
state 0x10, keycode 46 (keysym 0x6c, l), same_screen YES,
state 0x10, keycode 33 (keysym 0x70, p), same_screen YES,
state 0x11, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
state 0x10, keycode 51 (keysym 0x5d, bracketright), same_screen YES,
state 0x10, keycode 36 (keysym 0xff0d, Return), same_screen YES,
The readable keysym is quite useful, but I keed to test keycodes, as they do not change as modifier keys are switched on/off (caps lock, num lock). I'm new to bash, so I'm putting something together. This is best result so far:
#!/bin/bash
function findInArray() {
local n=$#
local value=${!n}
for ((i=1;i < $#;i++)) {
if [[ ${!i} == ${value}* ]]; then
echo "${!i}"
return 0
fi
}
echo
return 1
}
list=( 38:a 56:b 54:c 40:d 26:e 36:Return 50:Shift_L )
xev | \
# old grep solution
# grep -Po '(?<=keycode )[0-9]+(?= \(keysym 0x)' | \
# 200_success' suggestion
awk '/state 0x.*, keycode / { print $4; fflush() }' | \
while read keycode ;
do
found=$(findInArray "${list[@]}" ${keycode})
if [[ $found ]]; then
echo Pressed $found
list=(${list[@]/${keycode}\:*/})
echo 'Remaining ===>' ${list[@]}
if [[ ${#list[@]} == 0 ]]; then
echo All keys successfully tested!
pkill xev
exit 0
fi
fi
done
While I used grep it was only printing the output when I closed xev and it wouldn't kill it at the end too. The awk suggestion from @200_success solved these issues, but it does not print the output immediatelly: it takes 5-6 keystrokes for the output to be "flushed". How can I fix that?
Note: I know that this script would require a different list of keys for each different model of keyboard, but this is OK, as I only have a couple models to test.
Edit 1: I edited the question with my latest script code.
Edit 2: script updated according to @200_success suggestion.
|
Try replacing your grep line with an awk script that flushes its output.
xev | \
awk '/state 0x.*, keycode / { print $4; fflush() }' | \
while read keycode ; do
# etc.
done
| Script to quickly test all keyboard keys |
1,416,950,169,000 |
Currently I have an .Xmodmap file that changes my Command to Ctrl, then changes my Ctrl to Super (I'm running Linux on a Mac).
It works quite well, when only run once but on successive runs (for example when I restart my desktop environment (Cinnamon) it reloads the .Xmodmap file) it basically resets the settings by reverting the changes. Effectively toggling between my desired setup and the original setup.
How can I write an .Xmodmap file that only sets the settings one time, but doesn't change them back on successive runs? Here is my existing .Xmodmap file:
clear control
clear mod4
keycode 105 =
keycode 206 =
keycode 133 = Control_L NoSymbol Control_L
keycode 134 = Control_R NoSymbol Control_R
keycode 37 = Super_L NoSymbol Super_L
add control = Control_L
add control = Control_R
|
Reset the map to its original state before applying your mods. A full reset takes forever, so best I can come up with is diffing.
This code uses .Xmodmap{.orig,.reset,.mods} where if .orig doesn't exist it's set to the current state, and calculates .reset to restore that state from wherever it's got to. before applying .mods.
#!/bin/sh
# file xmodmap-reset
# rm ~/.Xmodmap.orig
# beforehand to take current setup as baseline for Xmodmap.mods changes
stem=~/.Xmodmap
orig=${stem}.orig
reset=${stem}.reset
mods=${stem}.mods
# implement -pme like -pke
#
xmodmap-pme () {
xmodmap -pm \
| sed '
1d
/ [^ ]/!d
s/^[^ ][^ ]*/clear &\nadd & =/
s/([^ ]*//g
'
}
# save baseline if none atm
test -a $orig || {
xmodmap -pke
xmodmap-pme
} > $orig
# payload, diff for commands to reset to baseline from current
{
xmodmap -pke
xmodmap-pme
} \
| {
diff -u0 $orig - \
| sed -n '
1,/^@@/d
s/^[^+]clear/clear/p
s/^-//p
'
} > $reset
xmodmap $reset
# finally ready to apply the mods
test -a $mods && xmodmap $mods
(edit: cleanup)
| How can I write a "idempotent" .Xmodmap |
1,416,950,169,000 |
I'm trying to transform a Minitel to a computer with a Raspberry Pi.
This is a minitel:
So I soldered the matrix of the minitel keyboard to a usb keyboard pcb, like this:
Everything is working ok, I recieve some keys from my custom keyboard. I just need to remap the keys appropriately.
So I'm trying to create a program that will ask me to press a and trap the corresponding keycode, and then with all keys of my custom keyboard, to finaly produce a xmodmap file.
The only problem I have is that I can't figure out on how can I get that keycode (and only that!). I tried xev but there's too much data displayed to filter it out.
I know I could track all the keycodes by hand, but I'll transform 10 Minitels, so I would prefer a quicker way!
|
I assume you're trying to do this in shell or similar (else, you'd just use the X libraries directly). If so, you may find xinput --test «device-name» much easier to parse.
Unfortunately, it really isn't shell-scripting friendly. But you can make it work with stdbuf. It runs until you kill it, but your shell script could pipe it to read.
So, you can do something like this:
stty -echo
stdbuf -oL xinput test 'AT Translated Set 2 keyboard' \
| perl -nE 'BEGIN {$| = 1} m/^key press\s+(\d+)/ and say $1' \
| for key in q w e r t y; do
echo -n "Please press $key: "
read -r keycode
echo "key $key = $keycode"
done
stty echo
You will need to use the correct keyboard name in place of "AT Translated Set 2 keyboard". You can find it with xinput list:
anthony@Zia:~$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Logitech USB-PS/2 Optical Mouse id=8 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Power Button id=7 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=9 [slave keyboard (3)]
Unfortunately, you have to use a specific device—you can't use the core keyboard.
(Also, you'll need to find a way to kill the xinput in the above, or just content yourself to hit Control-C when you've entered all the keys. And you'll probably want to list more keys than qwerty.)
| Get the keycode of a key, from a custom made keyboard |
1,416,950,169,000 |
I'm ssh-ing to my machine using my iPhone with an app called ServerAuditior. It doesn't have tab key. See screenshot.
How do I trigger autocomplete without the tab key? I don't want to type a lot of characters for cd-ing.
I have arrow keys in this app. I can swipe down left right to use arrow keys. It would be amazing if I can bind it to forward arrow key when blinker in at end of my command
|
You can bind the completion command to any key sequence. Pick something that's easy to type but unlikely to appear in a normal command, like say capital A. Put bind "A":complete in ~/.bashrc, and new bash instances will use capital A as well as TAB to invoke completion.
| How do I trigger autocomplete without a tab key? |
1,416,950,169,000 |
I'm using Xubuntu. Before login I can choose a keyboard layout. I'm using xmodmap for remapping some keys.
I'm interested in two things:
How the state of keyboard mapping changes (a) when I turn the laptop on, (b) during the boot process and (c) login to the system (in these three phases) and when working with the system (logged in).
What causes which symbols will be displayed on the screen (and control keys sent) during the individual phases. When I press some key, it sends some signal to the keyboard driver(?) and then there must be some decision process (applications and configuration files) determining what symbols will be displayed. Answer to this question should be the list of applications and paths to those configuration files (I'm especially interested in Ubuntu (Debian based system), but you can describe some other system, but Ubuntu is preferred).
|
There are two layers here, KEYCODE to KEYSYM mapping and KEYSYM to text mapping. There are more layers if you count the kernel, which has to map AT Keyboard scancodes to a XT-style KEYCODE or a USB Keyboard HID code to a KEYCODE. A KEYCODE is simply an 8-bit unsigned integer which the kernel of an Operating System passes to the X11 server. It can vary between Operating Systems such as Linux and Solaris. On Linux, these KEYCODEs are typically the same number used on old XT PC Keyboards. Newer computers with AT, PS/2, or USB keyboards typically just map those keyboards to the old XT code for the key to keep life simple.
Raw keyboard codes, whether they be XT, AT, PS/2, or USB represent a physical location on a keyboard. The XT keyboard only sends a single 8-bit number on press or release of a key. The q key on an US/British XT keyboard sends the number 16. On a French keyboard that same physical key is labeled a, but it still sends 16. It's the higher layers in the operating system that assign it a real meaning. When a key is released on an XT keyboard, the same keycode is sent plus 128. For this example, when q is pressed, a 16 is sent, but on release, the number 142 (16+128) is sent. AT Keyboards use scancodes which are a series of numbers and can get quite long. Key releases add additional codes. For example, the scancode for Pause is E1, 1D, 45, E1, 9D, C5. Most Operating Systems including DOS, Windows, Linux, FreeBSD, and the BIOS all map scancodes into much simpler XT-style scancodes. It also keeps it easier to support newer keyboards which use different codes such as USB Keyboards which send HID codes. All codes get mapped to the same consistent set of codes by the Operating System before X11 or the application sees them.
X11 is ignorant of this part of the process, it just gets the KEYCODE from the kernel and applies its own mapping to convert that KEYCODE to a KEYSYM. Xmodmap is the standard tool for controlling that mapping. Much of the behavior of the keyboard mapping is configurable, but there are several special cases such as Num Lock, Mode Switch, and Caps Lock/Shift Lock that are hard coded into X11. Other aspects like Shift are actually configurable. Any key can be mapped to act as shift, unlike Mode Switch or Num Lock.
KEYCODEs represent physical keys sent by the Operating System's kernel. Every KEYCODE can map to 8 possible KEYSYMs. Only 4 are used and are sometimes called levels 1-4. Level 1 specifies the KEYSYM that gets printed when no modifiers are active. These are often lowercase letters and digits. Modifiers are KEYCODEs that modify the KEYSYM generated by other KEYCODEs when the modifier is active (pressed or toggled on.) Modifier keycodes are also controlled through Xmodmap. Level 2 specifies a KEYSYM to be sent when the shift modifier is pressed. Level 3 is activated whenever the Mode Switch KEYSYM has been pressed. Level 4 is activated when both a shift key and Mode Switch are active.
Once a KEYSYM has been generated, this may be interpreted directly, but most often will be converted to text. Not all KEYSYMs turn into text or may only affect a future KEYSYM. One example is Shift_L, of course, which has no textual representation, but there are also a number of KEYSYMs that are used to Compose another character. A list of them on my system is under /usr/share/X11/locale/en_US.UTF-8/Compose. One such example is the dead_acute KEYSYM which, when pressed, will attempt to convert the next KEYSYM into an acute accented letter. There is a standard mapping for turning KEYSYMs into Unicode.
Now that all this has been said, note that Xmodmap is obsolete and replaced by XKB which is much more sophisticated. This affects how KEYCODEs are mapped to KEYSYMs, but not how the kernel generates KEYCODEs nor how KEYSYMs are converted into text or composed which is still the same. XKB can be disabled restoring Xmodmap behavior. It also has a compatibility layer to support Xmodmap, but it can have issues as it's not completely compatible. XKB rules are under /usr/share/X11/xkb/ and are much more sophisticated. There is some good documentation elsewhere on how it generates keyboard layouts for mapping KEYCODEs to KEYSYMs.
As for the Linux console, it has its own keyboard layouts which are stored in /usr/share/keymaps and loaded with the loadkeys command. When in the BIOS and earlier boot loader stages, including GRUB2, the keyboard mapping is whatever the number the BIOS decides to map the key to.
| Relationship of keyboard layout and xmodmap |
1,416,950,169,000 |
I have a small numpad keyboard which I would like to use for launching macros and shortcuts, along side my regular keyboard. I can attach macros and shortcuts to these keys (i.e, numpad 1 minimises the active window), but my primary keyboard numpad also activates the shortcut.
I would like a way to have the secondary keyboard act completely separately and to then attach shortcuts to it.
Here is the output I get from xinput.
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ LVT Recon gaming mouse id=10 [slave pointer (2)]
⎜ ↳ LVT Recon gaming mouse id=11 [slave pointer (2)]
⎜ ↳ Corsair Corsair K30A Gaming Keyboard id=13 [slave pointer (2)]
⎜ ↳ SIGMACHIP USB Keyboard id=18 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Power Button id=8 [slave keyboard (3)]
↳ Sleep Button id=9 [slave keyboard (3)]
↳ Corsair Corsair K30A Gaming Keyboard id=12 [slave keyboard (3)]
↳ Corsair Corsair K30A Gaming Keyboard id=14 [slave keyboard (3)]
↳ LVT Recon gaming mouse id=15 [slave keyboard (3)]
↳ Corsair Corsair K30A Gaming Keyboard id=16 [slave keyboard (3)]
↳ SIGMACHIP USB Keyboard id=17 [slave keyboard (3)]
↳ SIGMACHIP USB Keyboard id=19 [slave keyboard (3)]
|
While my other answer will probably work on most Linuxes, even if they're many years old, SystemD and udev actually makes things easier:
use lsusb to find the vendor and product code of your additional keyboard. (In my case, it's Vendor 145F, Product 0177. Make sure to have the letters in uppercase.)
create a file /etc/udev/hwdb.d/90-extra-keyboard.hwdb, with contents similar to this:
evdev:input:b0003v145Fp0177*
KEYBOARD_KEY_7005b=stopcd
The first line identifies the device: the four letters after the v is the vendor code, after the p, it's the product code, from the previous step. Every further line maps a scancode to a symbolic name. To get the scancode, run evtest:
Event: time 1553711252.888538, -------------- SYN_REPORT ------------
Event: time 1553711257.656558, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70059
Event: time 1553711257.656558, type 1 (EV_KEY), code 79 (KEY_KP1), value 1
To find out what to use for the symbolic name, look at the list of #define KEY_… lines in /usr/include/linux/input-event-codes.h:
#define KEY_PLAYPAUSE 164
#define KEY_PREVIOUSSONG 165
#define KEY_STOPCD 166
#define KEY_RECORD 167
re-build and load internal databases by running systemd-hwdb update; udevadm trigger
verify the new settings work by running evtest again, or by assigning shortcuts in your settings.
When trying this out in applications, just remember that if your desktop environment already uses that shortcut, the application won't even see the keypress.
| Can I launch macros and shortcuts from a second keyboard on Linux? |
1,416,950,169,000 |
I am developer and currently I am using Ubuntu Linux with PyCharm IDE for development of website. In order to improve typing performance I consider change CapsLock to Hyper_L and assign it to mod3 using xmodmap. After this I want to map mod3 for 'i' key to 'Up'. So far what I did is:
xmodmap -e "keysym Caps_Lock = Hyper_L"
output is like this:
shift Shift_L (0x32), Shift_R (0x3e)
lock Hyper_L (0x42)
control Control_L (0x25), Control_R (0x69)
mod1 Alt_L (0x40), Alt_R (0x6c), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
then I remove Hyper_L from mod4
xmodmap -e "remove Mod4 = Hyper_L"
Afterwards I tried assign Hyper_L to mod3
xmodmap -e "add Mod3 = Hyper_L"
However I got error as following:
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 118 (X_SetModifierMapping)
Value in failed request: 0x17
Serial number of failed request: 11
Current serial number in output stream: 11
So, what was the problem here? How I can make it work? Does my approach is right? Or I should use different approach in order to use mod3 for custom keys?
P.S. I am using Microsoft Natural Ergonomic 7000 keyboard
|
There are a bajillion answers on the internet, most of them confusing.
The key is you need to map 'keycode 66' to your hyper key, remove the mapping of that key from other mod{1,2,4,5}'s (only if present), and then set mod3.
Open ~/.Xmodmap and put the following:
! Unmap capslock
clear Lock
keycode 66 = Hyper_L
! Leave mod4 as windows key _only_
remove mod4 = Hyper_L
! Set mod3 to capslock
add mod3 = Hyper_L
Run this
xmodmap ~/.Xmodmap
If something goes wrong, you can reset your keyboard with:
setxkbmap -layout us
Likely causes of something exploding are that Hyper_L is mapped someplace else. Fix this by running xmodmap without args to figure out what else is bound to Hyper_L. When you know what you need to remove, chuck a 'remove BINDING = Hyper_L' in your .Xmodmap file.
The .Xmodmap file will be loaded in when you open X11 sessions, you should have this mapping in place next time you login or reboot.
This configuration works for my ubuntu 14.04 setup. If you have a different *nix and this doesn't work, please post what you did to get around it here and I'll incorporate it into the answer.
| CapsLock as modifier key for application keymaps |
1,416,950,169,000 |
The Insert is located right next to Backspace.
So when I am using Leafpad, Gedit, etc., I hit Insert by accident often, which causes the cursor to turn into a bold box which
over-writes text as I type.
How do I disable it?
|
First, find the keysym which corresponds to Insert
$ xmodmap -pke | grep -i insert
This is probably key 118. To disable it globally run
$ xmodmap -e "keycode 118 ="
which causes that key to map to nothing at all.
Running this command every time your Xserver starts is very dependent upon which distribution and session manager you are using.
| How to permanently disable the Insert key on Linux? |
1,416,950,169,000 |
I have an Asus laptop that has a special key that can be configured to launch any software (at least on Windows).
The general question is: how can I detect any key press (globally)?
Then, how can I detect when the user press this key?
|
I typically will use xev to determine the key's scancode and then map it to whatever action I want using either xdotool or XBindKeys.
xev
$ xev | grep -A2 --line-buffered '^KeyRelease' \
| sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'
After running the above xev command you'll get a little white window that'll pop up. You'll want to put the mouse over this window and then press the problem key. The name of the key should be showing up in the terminal as you press the various keys.
Screenshot
mapping the key to something useful
You can create shortcut key combinations that will launch commands using xbindkeys, for example. I've successfully been using XBindKeys on GNOME 3.8.4 for this very purpose.
My use has been modest but I like to create keyboard shortcuts for Nautilus to launch with certain directories opened.
Example
You'll need to first make sure the packages xbindkeys is installed.
Then you'll need to run the following command, one time only, to create a template xbindkeys configuration file.
$ xbindkeys --defaults > /home/saml/.xbindkeysrc
With the file created you can open it in a text editor and add a rule like this:
"nautilus --browser /home/saml/projects/path/to/some/dir"
Mod4+shift + q
With the above change made we need to kill xbindkeys if it's already running and then restart it.
$ killall xbindkeys
$ xbindkeys
Now with this running any time I type Mod+Shift+Q Nautilus will open with the corresponding folder opened.
Using GNOME's Keyboard Applet
If you go through the settings (System Settings → Keyboard, select Shortcuts tab and add a new custom shortcut for your browser.
Using the steps 1-5 as in the diagram you could map a command to your special key as well.
| How to detect global key presses |
1,416,950,169,000 |
I am attempting to remap my keyboard in order to make emacs usable. My ergonomic keyboard puts its single Control key in an isolated 4-key island way off to the left.
The OS is Debian squeeze.
Here are the lines I am attempting to feed to xmodmap, I place them into a file ~/.Xmodmap:
clear Control
clear Mod1
! The Alt keys are labled 'Option' on my keyboard,
! using xev shows them to send Alt_L and Alt_R keysym's respectively
keysym Alt_L = Control_L
keysym Alt_R = Control_R
! The Super_L and Super_R keys are the Windows keys
keysym Super_L = Alt_L
keysym Super_R = Alt_R
add Control = Control_L Control_R
add Mod1 = Alt_L Alt_R
My goal is to make my Option (a.k.a. Alt) keys behave like Control keys, and to get my Windows (a.k.a. Super) keys to behave like Alt.
Here are the keycodes and keysms output by xev for the keys in question. Note, my keyboard (a Goldtouch ergonomic keyboard) has only one control key.
keycode 37 (keysym 0xffe3, Control_L)
keycode 64 (keysym 0xffe9, Alt_L)
keycode 133 (keysym 0xffeb, Super_L)
keycode 134 (keysym 0xffec, Super_R)
keycode 108 (keysym 0xffea, Alt_R)
Here is what xev displays while running xmodmap .Xmodmap
MappingNotify event, serial 34, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 204, count 1
MappingNotify event, serial 34, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 64, count 1
MappingNotify event, serial 34, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 108, count 1
MappingNotify event, serial 34, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 206, count 1
MappingNotify event, serial 34, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 133, count 1
MappingNotify event, serial 34, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 134, count 1
And here is the error returned by xmodmap:
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 118 (X_SetModifierMapping)
Value in failed request: 0x17
Serial number of failed request: 17
Current serial number in output stream: 17
any suggestions about how I can resolve this?
|
This has already been reported as Debian bug #564327, Debian bug #565279, Ubuntu bug #524774, and FreeDesktop bug 20145. There is a source patch attached to the FreeDesktop bug discussion. There are several workaround proposals in the Ubuntu bug discussion, in particular a .Xmodmap workaround.
| Reassign Ctrl and Alt keys - xmodmap 'BadValue' error |
1,416,950,169,000 |
How do I map key "Super" so, when combined with Left/Right, it produces keycode Home/End?
My current setxkbmap:
setxkbmap \
-model pc105 \
-layout 'us(dvorak-intl),us(alt-intl)' \
-option \
-option grp:lctrl_lshift_toggle \
-option compose:rwin
|
You can't do it with just a setkxbmap option, as no default option does what you want.
But you can do it by defining key behaviour at a lower level.
The page http://madduck.net/docs/extending-xkb/ helped me to understand and find a way to do it.
Create a file ~/.xkb/keymap/mykbd where you put the output of setxkbmap, it will be your base keyboard definition; eg:
setxkbmap -print > ~/.xkb/keymap/mykbd
then we will create a ~/.xkb/types/mytypes file and put the following in:
partial
xkb_types "super_level2" {
Virtual_modifiers Super;
type "SUPER_LEVEL2" {
modifiers= Super;
map[Super]= Level2;
level_name[Level1]= "Base";
level_name[Level2]= "Super";
};
};
it defines a type SUPER_LEVEL2 that will allow to easily define symbols sent when a key is pressed with Super.
then, in the ~/.xkb/symbols/mysymbols put the following lines:
partial modifier_keys
xkb_symbols "super_arrows_home_end" {
key <LEFT> {
type[Group1] = "SUPER_LEVEL2",
symbols[Group1] = [ Left, Home ]
};
key <RGHT> {
type[Group1] = "SUPER_LEVEL2",
symbols[Group1] = [ Right, End ]
};
};
(note the use of the "SUPER_LEVEL2 type we defined, it means that the second (level 2) symbol on the symbols line is triggered when pressing Super key (instead of Shift key).
Finally, edit the ~/.xkb/keymap/mykbd file to load the snippets we wrote:
in the xkb_types line add +mytypes(super_level2) inside the quotes
in the xkb_symbols line add +mysymbols(super_arrows_home_end) in the quotes.
Now you can load it with
xkbcomp -I$HOME/.xkb ~/.xkb/keymap/mykbd $DISPLAY
Test your left/right keys, they should work as you wanted.
| Map Super+[Left|Right] to Home/End |
1,416,950,169,000 |
I know I can change keyboard autorepeat settings with xset r rate <delay> <rate>.
Can anyone tell me the default values on Ubuntu? I've checked the man page and tried googling, to no avail.
|
You can display current settings with
xset -q
where among other useful information one can find:
Keyboard Control:
auto repeat: on
...
auto repeat delay: 660 repeat rate: 25
...
Delay is given in milliseconds and rate is the number of repeats per second.
| What is the default keyboard autorepeat rate? |
1,416,950,169,000 |
I'd like to use UTF8 math symbols, when typing one list, another list.
I've found something called ComposeKey. Unfortunately it's not covering omega, theta, right arrow etc.
I am using KDE, I've tried global shortcuts, but does not seem to work.
How to setup typing utf8 symbols (like: Θ, Ω,∃, ∀,⇒,→) with keyboard combinations (like Meta+S) ?
|
You can define your own table for the Compose key: create a file called .XCompose in your home directory. You'll need to define the whole table (you can't just add your definitions to the system default, you have to copy the system default into your file if you want it).
You'll find the system default table in /usr/share/X11/locale/en_US.UTF-8/Compose on Debian and Ubuntu and in a similar location on other unices. The format should be reasonably straightforward; a typical definition looks like these:
<dead_acute> <a> : "√°" aacute # a dead key: press Dead_acute then A to insert "√°"
<Multi_key> <acute> <a> : "√°" aacute # Press Compose, ', A to insert "√°"
<Multi_key> <g> <a> : "α" U03B1 # 03B1 is the hexadecimal code of "α"
<Multi_key> <M> <A> : "∀" U2200 # 2200 is the hexadecimal code of "∀"
<Multi_key> <minus> <greater> : "‚Üí" U2192
<Multi_key> <bar> <minus> <greater> : "↦" U21A6
ASCII characters and a few others have symbolic names; you'll find these names in /usr/include/X11/keysymdef.h. For example, - is minus because keysymdef.h contains the line #define XK_minus 0x002d and 2d is the hexadecimal code of -.
You can have sequences of more than two characters, like |-> in the example above. Note that if you define a compose sequence for |->, you can't have another for |-.
If you prefer AltGr+key‚ÇÅ π, key‚ÇÇ to Compose, key‚ÇÅ, key‚ÇÇ then you can bind AltGr+key‚ÇÅ π to a dead key with xmodmap. It's not necessarily a blessing, and note that you are limited to the dead key names listed in /usr/include/X11/keysymdef.h.
For characters that you don't use often enough to remember a key sequence anyway, you can use KCharSelect (or its Gnome equivalet GUCharMap). Or do what mathematicians are used to doing, which is type in \LaTeX.
| UTF8 math symbols & keyboard layout / input |
1,416,950,169,000 |
There has been a similar question - but IMHO there has to be a simpler solution. If num-lock is on in the BIOS - why is it turned off during linux boot and/or KDE/Gnome/whatever startup?
|
Linux initializes most peripherals so that they'll be in a known state. This includes the keyboard: Linux's internal data about the keyboard had better match the LEDs, so what Linux does is to turn off the LEDs (as far as I recall, the CPU can't read the state of the LEDs on a PC keyboard) and declare all *Lock to be off.
I like to have NumLock on by default. For Linux text consoles, what I used to do¹ is to run
for t in /dev/tty[0-9]*; do setleds -D +num <$t; done
from a boot script (/etc/rc.local or /etc/init.d/50_local_setleds or wherever the distribution likes to put those).
Nowadays, at least on some distributions such as Debian, you can add LEDS=+num to /etc/console-tools/config (or /etc/kbd/config depending on which one you have).
The X window system has its own keyboard handling, so you need to deal with it separately. What I do is to switch caps lock permanently off (I don't have a Caps Lock key in my layout) and switch num lock permanently on (I don't have a Num Lock key in my layout, and the keypad keys send KP_1 and so on). If you want to retain the modifiers but make Num Lock default on, you can write a small program to call XKbLockModifiers to set the modifier inside X and XChangeKeyboardControl to set the physical LED.
¹ Used to, because I haven't bothered with text consoles in a while.
| Enable num-lock as default in Linux |
1,416,950,169,000 |
My language, Guarani, uses G̃/g̃ to denote the nasalized velar approximant. I thought I'd be able to type it by combining a dead tilde with g, but this does not work. Why doesn't it, and how can I fix it?
My main suspicion is that this has to do with the fact that there is no separate Unicode character for g̃, just g with the combining tilde. I can type ỹ and ṽ just fine, but not j̃, r̃, m̃, which seems like good evidence that therein lies the problem.
So one way I could get around this would be to map a key to 0x1000303 (which is U+0303, or ◌̃ ), the combining tilde, instead of to dead_tilde. However, this creates several problems:
If I switch to using the combining tilde in all cases:
I end up typing e.g. n + ◌̃ in many cases where the single character ñ is expected, and they have different results. For example, I've noticed that certain websites won't display the same search results if I type one vs. the other (obviously that's on them, but I want a keyboard layout that works with the world as it exists now).
It's annoying that I have to backspace twice to delete characters with the combining tilde, which I can accept if it's only for the g̃, but it's a little much with every nasalized character.
If I add both, which is what I'm currently doing, this becomes really hard for usability, because:
I have to think in each case about which key to use, when my brain thinks of them as the same
The mechanics of typing the two are different, since dead_tilde is pressed before a character, whereas ◌̃ goes after. My poor little brain will never get used to that.
It seems like in the ideal scenario I'd have X notice that dead_tilde + g doesn't work and just process it as if I'm typing g + ◌̃, and enter the two characters for me together, as it does for ñ, ã, ẽ, ĩ, õ, ũ, ỹ, etc.
It's worth noting that it's not possible to get around this by adding the g̃ directly to my keyboard layout, as xkb doesn't seem to support mapping a key to a combined Unicode glyph (though see the answer to Custom xkb layout in which one key creates two unicode code points for a hacky workaround). If I could fix that, I suppose this would be much less of a problem.
I'm running Ubuntu 18.04, not sure what other background info would be helpful, but I assume this is a problem for anyone running X.
Edit 1: Editing Compose mappings doesn't work
Another thing I've tried, which also did not work, is editing the Compose mappings to add a composed g̃. I wrote an .XCompose file as follows:
include "%L"
<dead_tilde> <g> : "g̃" gtilde
<dead_tilde> <G> : "G̃" Gtilde
But this also did not work, I assume for the same reason above: X expects a single character, and g̃ is technically two. Incidentally, I noticed a number of mappings shipped in my locale's default Compose file also don't work, presumably for the same reason. The following mappings for en_US.UTF-8, and perhaps many more, actually do nothing:
<dead_acute> <dead_tilde> <a> : "ã́" # LATIN SMALL LETTER A WITH TILDE AND ACUTE
<dead_grave> <dead_tilde> <a> : "ã̀" # LATIN SMALL LETTER A WITH TILDE AND GRAVE
<dead_acute> <dead_tilde> <A> : "Ã́" # LATIN CAPITAL LETTER A WITH TILDE AND ACUTE
<dead_grave> <dead_tilde> <A> : "Ã̀" # LATIN CAPITAL LETTER A WITH TILDE AND GRAVE
<dead_acute> <dead_tilde> <e> : "ẽ́" # LATIN SMALL LETTER E WITH TILDE AND ACUTE
<dead_grave> <dead_tilde> <e> : "ẽ̀" # LATIN SMALL LETTER E WITH TILDE AND GRAVE
<dead_acute> <dead_tilde> <E> : "Ẽ́" # LATIN CAPITAL LETTER E WITH TILDE AND ACUTE
<dead_grave> <dead_tilde> <E> : "Ẽ̀" # LATIN CAPITAL LETTER E WITH TILDE AND GRAVE
<dead_acute> <dead_tilde> <i> : "ĩ́" # LATIN SMALL LETTER I WITH TILDE AND ACUTE
<dead_grave> <dead_tilde> <i> : "ĩ̀" # LATIN SMALL LETTER I WITH TILDE AND GRAVE
<dead_acute> <dead_tilde> <I> : "Ĩ́" # LATIN CAPITAL LETTER I WITH TILDE AND ACUTE
<dead_grave> <dead_tilde> <I> : "Ĩ̀" # LATIN CAPITAL LETTER I WITH TILDE AND GRAVE
<dead_grave> <dead_tilde> <o> : "õ̀" # LATIN SMALL LETTER O WITH TILDE AND GRAVE
<dead_grave> <dead_tilde> <O> : "Õ̀" # LATIN CAPITAL LETTER O WITH TILDE AND GRAVE
<dead_grave> <dead_tilde> <u> : "ũ̀" # LATIN SMALL LETTER U WITH TILDE AND GRAVE
<dead_grave> <dead_tilde> <U> : "Ũ̀" # LATIN CAPITAL LETTER U WITH TILDE AND GRAVE
<dead_grave> <m> : "m̀" # LATIN SMALL LETTER M WITH GRAVE
<dead_grave> <M> : "M̀" # LATIN CAPITAL LETTER M WITH GRAVE
As a matter of opinion, I do not think this is what we should fix: adding an extra line to Compose files for every possible diacritic just seems wasteful, and is not taking advantage of the simplicity of the nice combining diacritics Unicode wants us to use.
An interesting thing I noticed before I removed this .XCompose is that launching GTK programs from the terminal would result in the following errors:
(gedit:7229): Gtk-WARNING **: 23:03:04.848: GTK+ supports to output one char only: "g̃" gtilde: <dead_tilde> <g> : "g̃" gtilde
So presumably this is a GTK issue? I'll continue trying to track it down, but would appreciate any help.
Edit 2: Relevant GTK issue
It seems like my solution would be to fix this: https://gitlab.gnome.org/GNOME/gtk/-/issues/186
|
I just upgraded to Ubuntu 20.04, and now the .XCompose solution works perfectly! So that should be the best solution. You just need to make an .XCompose file in your home directory as follows, or add to your existing one:
include "%L"
<dead_tilde> <g> : "g̃" gtilde
<dead_tilde> <G> : "G̃" Gtilde
| Why can't I type a g̃ the same way I type ñ? |
1,416,950,169,000 |
Edit: I realized that the "problem" was not only in Ubuntu but in Debian itself and Ubuntu just inherited it, so I had this migrated from Ask Ubuntu
I have been using Linux on and off for 10 years, and more recently I have spent more time with OSX.
But, I still remember that in the beginning I'd choose the US international keyboard layout and it would have exactly the same output as the Windows keyboard layout (and most recently, the OSX US international layout).
However, a few years ago when I installed Ubuntu, I noticed that the cedilla wasn't printed anymore (ç or Ç). This is a combination of the following keys: ' + c. Instead, what I get is the ć letter.
When did it start to happen, and why the difference to the behavior on the other OSes? What puzzles me even more is that there is even an "US International alternative" keyboard layout, which prints exactly the same keys! So, what's it alternative to?
This has been reported as a bug back to Canonical (can't find the link now), but the keyboard layout has never changed back to what I'd expect. I know the workarounds to fix it to what I need, but I just would like to know why/when it has become different.
|
Summary
If you are using Ubuntu, it probably changed around 2005, when the default character set changed from ISO 8859-1 to UTF-8.
US Alternative International adds some dead keys.
The dead key settings depend on your locale and character set.
For example:
en_US.UTF-8 is defined in /usr/share/X11/locale/en_US.UTF-8/Compose
ISO 8859-1 is defined in /usr/share/X11/locale/iso8859-1/Compose
If you look in them using grep, you can see there is a difference:
$ grep '<dead_acute> <c>' /usr/share/X11/locale/en_US.UTF-8/Compose
<dead_acute> <c> : "ć" U0107 # LATIN SMALL LETTER C WITH ACUTE
$ grep '<dead_acute> <c>' /usr/share/X11/locale/iso8859-1/Compose
<dead_acute> <c> : "\347" ccedilla
Namely:
Latin1 encoding: ', c = ç
UTF-8 encoding: ', c = ć
The git logs ((en_US.UTF-8) (iso8859-1)) show it has been this way since at least 2004.
The difference between US International and US Alternative International is defined in /usr/share/X11/xkb/symbols/us.
Namely, the US Alternative International layout adds these extra AltGr dead keys:
dead_macron: on AltGr-minus
dead_breve: on AltGr-parenleft
dead_abovedot: on AltGr-period
dead_abovering: on AltGr-0
dead_doubleacute: on AltGr-equal (as quotedbl is already used)
dead_caron: on AltGr-less (AltGr-shift-comma)
dead_cedilla: on AltGr-comma
dead_ogonek: on AltGr-semicolon
dead_belowdot: on AltGr-underscore (AltGr-shift-minus)
dead_hook: on AltGr-question
dead_horn: on AltGr-plus (AltGr-shift-equal)
dead_diaeresis: on AltGr-colon (Alt-shift-semicolon)
For example:
US International: AltGr+- = ¥
US Alternative International: AltGr+-, a = ā
UTF-8 became the default encoding:
Red Hat 8.0 "Psyche", released September 30, 2002 reference
Ubuntu 5.04 "hoary", released April 8, 2005 reference
Debian 4.0 "etch", released as "stable" April 8, 2007 reference 1 reference 2
| Why is the US international keyboard layout on Debian different? |
1,416,950,169,000 |
I was using a small Linux distro that was running X11 with JWM as its window manager. I was browsing a directory when all of a sudden the mouse froze and the keyboard became unresponsive. The caps lock and scroll lock lights are flashing.
What does this mean... and is there anything I can do about it?
|
The kernel has crashed your pc, the reason could be anything...
Good question is how you collect the crash data, so you know what crashed it.
But the only thing to do is to reboot the pc.
| The caps lock and scroll lock lights are flashing and everything is frozen |
1,416,950,169,000 |
When I program I like to swap these keys:
Esc ↔ Tab
Ctrl ↔ CapsLock
In ~/.xmodmap, I have specified these re-mappings:
keycode 66 = Control_L
keycode 37 = Caps_Lock
keycode 23 = Escape
keycode 9 = Tab
The Escape and Tab keys swaps, no problem, but instead of Caps_Lock and Control_L swapping, both those keys becomes Caps_Lock.
Whatever I try to do, the Control keys doesn't get assigned to Caps_Lock (keycode 66). If I leave the keycode 66 =, the key is un-assigned, but when I assign Control_L or Control_R, it just doesn't work. But, if I assign some other key, for example, keycode 66 = Tab, it gets assigned, no problem.
Its like xmodmap just doesn't want Caps Lock and Control keys to be swapped. Really frustrating. Any help/pointers would be really helpful.
P.S: I am using Archlinux.
|
The xmodmap(1) man page has an example for exactly this
!
! Swap Caps_Lock and Control_L
!
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L
but if you want to finish doing it the way you started, I think you need to add at least the remove and add lines
remove Lock = Caps_Lock
remove Control = Control_L
keycode 37 = Caps_Lock
keycode 66 = Control_L
add Lock = Caps_Lock
add Control = Control_L
I'm guessing that's the case based on this paragraph
add MODIFIERNAME = KEYSYMNAME ...
This adds all keys containing the given keysyms to the indi‐
cated modifier map. The keysym names are evaluated after all
input expressions are read to make it easy to write expressions
to swap keys (see the EXAMPLES section).
which makes it sound like modifier changes (shift, control, etc.) don't get applied until you run that too.
(And logically the same with remove)
The keycode version has the advantage of being idempotent, meaning that the effect won't change if xmodmap is run multiple times.
| Remapping Caps Lock with xmodmap doesn't work |
1,416,950,169,000 |
I sometimes need to type "alt codes" to get symbols and on linux, it can be inefficient to use shift+ctrl+u then type the code, for example shift+ctrl+u+00a7 for § when on Windows it's alt+21.
So what I'm asking is, is there any way to basically use alt+... for these symbols as I don't really like using shift+ctrl+u and it doesn't work in some places.
I use xfce4 as my desktop environment and under the keyboard settings, I've seen something called a "compose key." As I didn't know what this was, I looked it up and saw it kind of had something to do with these unicode characters.
I've also seen somethings along the lines of level 1, 2, 3 and 4 keys but I don't really understand how these work, so if someone could explain these as well, that would be great.
(I use arch (manjaro more specifically) if this helps)
|
You can use Compose s o (as well as a few other synonymous sequences) to obtain the character §. This is both shorter and more mnemonic than Shift+Ctrl+u a7 enter (you didn't mention pressing Enter but I had to do that do get it to work for me). The compose sequences are meant to be easy to remember, such as + - for ± or e ' for é. IMHO that's certainly better than having to remember Unicode code point numbers!
You can find the list of compose sequences in the various Compose files in /usr/share/X11/locale. Check out /usr/share/X11/locale/en_US.UTF-8/Compose in particular which appears to contain one of the biggest collections. Note that you will see Multi_key in that file, which is the "official" X11 name of the key more commonly known as Compose.
Sorry, I don't know anything about alt+... which you mention. Personally, compose sequences meet all my needs for typing English, French, and occasional special symbols (but not Japanese, of course).
I've also seen somethings along the lines of level 1, 2, 3 and 4
I don't know what that means, but maybe it refers to the length of the compose key sequence? Not all of the sequences are two characters. Some are 3 characters long: Compose - - - results in — (mnemonic: 3 hyphens because an em-dash is very wide) and I guess some are even longer (though I don't know any of those offhand).
| Linux alternative to alt+numpad codes |
1,416,950,169,000 |
How can I map Ctrl+Backspace to behave as Delete key with xkb? I can remap a single key on /usr/share/X11/xkb/symbols/pc but can't figure out how to do the combination. My OS is Ubuntu 15.04
|
As Gilles pointed out in a comment, you can do it with xkb if you change the type of BKSP key to control-modifiable.
Example: if I edit /usr/share/X11/xkb/symbols/pc and under:
include "pc(editing)"
include "keypad(x11)"
change this line:
key <BKSP> { [ BackSpace, BackSpace ] };
to:
key <BKSP> {
type="PC_CONTROL_LEVEL2",
symbols[Group1]= [ BackSpace, Delete ]
};
then Ctrl+Backspace behaves as Delete.
| xkb: make ctrl+backspace behave as delete |
1,416,950,169,000 |
I don't think that title probably helps very much, but here's my issue:
I'm using the awesome window manager and am trying to make my key bindings to be similar in flavor to OSX for special keys. I'm learning German, so I somewhat regularly need to type vowels with umlauts (double dots) above them. In OSX, to do this, you type Alt+U, then the vowel you want.
Obviously, that won't be feasible in awesome, but what I do want is modkey+ to send a keyboard event that gives it the impression I had hit an umlaut-ed key.
Would I have to change the keyboard layout first? Such that the code changes the layout, sends the corresponding event, then changes it back? Or can I send the event without changing the layout?
And how do I send the event in the first place, if that's possible?
|
You would do this via Xmodmap and not via your window manager. This is directly related to your keyboard layout/keymap and not your window manager.
To change your xmodmap create a file named ~/.Xmodmap and add the following content. This should allow you to to type üäöß directly with altgr+u
keysym a = a A adiaeresis Adiaeresis
keysym o = o O odiaeresis Odiaeresis
keysym u = u U udiaeresis Udiaeresis
keysym s = s S ssharp section
Afterwards you have to apply the content from this file with xmodmap ~/.Xmodmap
Another way to input umlauts is to use the us international layout. This allows you to enter umlauts with " + char. To enter ä you would need to enter "a. The international layout is also available in Windows and as far as i know in OSX.
setxkbmap -layout us -variant intl
| In awesome window manager, how can I make key bindings send keyboard events? |
1,416,950,169,000 |
Aim:
I would like to assign Alt to CapsLock-key, and Meta to Alt-key. But in such way, Alt-key would no longer be recognized as Alt, and CapsLock-key would no longer be recognized as CapsLock.
openSUSE 11.4
Previously:
openSUSE 11.1 -- since I am the only user of my computer I "simply" edited the /usr/share/X11/xkb/keycodes/xfree86 file and it worked without problem. Keys were wired to their symbols at the lowest level.
Problems:
xkb
I created a variant of Polish layout (pl_ext) which (for test) consists of such entries:
key <CAPS> { [ Alt_L ] };
modifier_map Mod1 { Alt_L, Alt_R };
However this does simply nothing, CapsLock-key in xev is recognized (symbol) as Alt_L, but when I press CapsLock-key it behaves like CapsLock (e.g. assuming you have File in menu, Alt+F should open this menu, it does not).
Question: How to define a layout file to set CapsLock-key as Alt, and Alt-key as Meta?
Edit: Half of success here! Now I have such entries:
key <CAPS> { [ Alt_L ] };
modifier_map Mod1 { <CAPS> }; // this is a difference
and this works as desired. This does not:
key <LALT> { [ Meta_L ] } ;
key <RALT> { [ Meta_R ] } ;
modifier_map Mod5 { <LALT>,<RALT> };
Alt-keys are recognized as Meta by xev, but I still can open the menus with Alt+F, switch windows, and I shouldn't. And on the other hand I cannot enter any national character, and I should.
xfree86
But now this does not work, I guess other file table is read instead of xfree86.
Question: How to find out which keycode table file is used by system (X/Gnome)?
Edit: The best option for me -- editing keycode tables -- was solved by macias's answer!
xmodmap
Half of success here. This part works as desired:
remove Lock = Caps_Lock
keysym Caps_Lock = Alt_L
Now, I have trully CapsLock-key which is mapped to Alt. But this:
keysym Alt_L = Meta_L
...does strange thing. xev shows that Alt-key is mapped to Meta, but when I press Alt+F (this should be mapped to Meta+F --> doing nothing) the File menu is opened. What's more, when I press Alt+Tab, I get window-switcher (I should not -- Alt is Meta now).
Question: How to "delete" old behavior for Alt-key?
Edit: This part is solved by Gilles's answer.
Summary:
Answering any question would (hopefully) solve my problem, however I prefer using xkb entirely because I could then pack all the files for xkb and change layout in one place. Thank you in advance for any help!
|
(This answer is about xmodmap only. I'm sure it's possible to do this with XKB, I just don't know how.)
Modifiers and keysyms are assigned independently. But you get strange effects if you don't set them consistently. I think all you're missing is the add command to assign a modifier to Meta_L, though you may also need to clear and reassign the modifier keys. You may replace Mod1 and Mod2 by Mod3, Mod4 and Mod5: they are interchangeable, just make sure you don't use one for two different purposes.
clear Mod1
clear Mod2
remove Lock = Caps_Lock
keysym Caps_Lock = Alt_L
keysym Alt_L = Meta_L
add Mod1 = Alt_L Alt_R
add Mod2 = Meta_L Meta_R
| how to assign another modifier to Alt key for X11? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.