date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,416,950,169,000 |
I've been able to change the keyboard layout/mapping when the X Window System is running using ~/.Xmodmap (and I suppose you could also do it through the X protocol directly, eg. using libxcb as a wrapper around X protocol calls).
I've been able to do the same (somewhat) on the console/tty (ie. when X is not running) using loadkeys.
Is there a way to customize the keyboard layout similarly, but from a single source, in such a way that it affects both X and the console, ie. in a way that is "X-and-console agnostic"?
(The only way I can think of is by writing a "keyboard driver" that talks to the kernel's input interface, evdev, and sends the input you want (through uinput?), or something, but I don't know if this even makes sense, or if there's an easier way.)
|
Yes, there is a way, and this is indeed how Debian's console-setup package does it.
Keyboard layouts are specified in XKB terms (model, layout, variant, and options) by the administrator in a file named keyboard, usually /etc/default/keyboard. This is the single source. It can be edited with a text editor.
The setxkbmap program is given these same XKB settings and configures an X11 server accordingly.
The keyboard-configuration package's post-installation maintainer script runs setxkbmap directly, with the /etc/default/keyboard settings, if it finds itself with an X11 display. Thus dpkg-reconfigure keyboard-configuration run from an X11 GUI terminal emulator will affect the X11 keyboard layout.
The setupcon script takes these XKB settings, passes them through the ckbcomp utility to generate a keyboard map, and loads that keyboard map into the kernel virtual terminals with loadkeys/kbdcontrol.
This script is run at system bootstrap by a service.
It can also be run manually elsewhen.
Other systemd operating systems work differently but also have a single source.
The XKB layout, variant, and options are stored in in /etc/X11/xorg.conf.d/00-keyboard.conf. This is the single source.
This file is directly read by the X11 server at startup and sets the X11 keyboard map directly.
This file is parsed by systemd-localed at startup. The file cannot be usefully edited with a text editor whilst systemd-localed is running, because the service will blithely overwrite it with its own in-memory information.
To change the XKB information, one runs localectl, which talks to another server which in turn talks to systemd-localed.
systemd-localed converts the XKB settings to a virtual terminal keyboard map name using the mappings in /usr/share/systemd/kbd-model-map, which it then writes out to /etc/vconsole.conf. Unlike the Debian system, it does not generate maps on the fly from the XKB information, but selects only pre-supplied static maps listed in the map file.
systemd-vconsole-setup runs at bootstrap, reads /etc/vconsole.conf, and loads the keyboard map into the kernel virtual terminals by running loadkeys.
Further reading
keyboard. console-setup User's Manual. Debian.
ckbcomp. console-setup User's Manual. Debian.
Andrew T. Young (2011). Keyboard Configuration.
Where is Xkb getting its configuration?
https://unix.stackexchange.com/a/326804/5132
| Changing the keyboard layout/mapping on both the console (tty) and X in an X/console agnostic way? |
1,416,950,169,000 |
Setting a Compose key, in KDE Plasma keyboard settings, Advanced > Configure keyboard options I am seeing this :
What is a level?
And what does it mean something like "third level of Left Ctrl"? What does it mean to "choose a level"?
(I know how to set the Compose key, that's not my problem here: I'm asking about that terminology.)
|
Level 1: no modifications (e.g. pure a)
Level 2: usually Shift (e.g. shift+a -> A, so the character A is level 2 of the a-key)
Level 3: usually AltGr (e.g. AltGr+a -> æ, so character æ is level 3 of a as a key .. and so on)
Level 4: Shift+AltGr (e.g. Shift+AltGr+a -> Æ)
Level 5: needs to be defined by you, e.g. Windows-key (possible: Win+a -> à, often not predefined)
Examples depend on layout!
Formally a level 6 would be easy then via shift+level5-modifier. (e.g. shift+Win+a -> À)
A howto can be found here.
| What does "level" of a key mean in keyboard settings? |
1,416,950,169,000 |
I found similar questions both here and on Super User. The closest question that comes to my question that I could find is Why can't I use two or more keyboards/mice at the same time on one computer?, but the question was focused on Windows (also, it dates from 2010, and things may have changed since).
I'm wondering whether I can hook up two keyboards simultaneously on my Linux machine. I've recently been working on my desktop again instead of my laptop, but my Cherry MC Blue keycaps actually wakes up my SO. (She's in a different room to me, but Blues are loud).
I could use a USB-PS/2 + USB setup if that would work and two USB keyboard input devices won't work.
I don't wish to simply replace my Blues, as I can use them during the day without bothering her and I rather like that keyboard.
For what it matters, I mostly use Ubuntu.
Considering that I don't tend to actually use them simultaneously, I am aware that I could just unplug the Blues and plug in the Browns at night, and reverse it again in the morning. I'm just being lazy and don't want to go through that daily.
|
Yes, you can connect any number of keyboards simultanously (as long as it's physically possible with your hardware). The "X Input" extension manages multiple input devices, you can use the xinput commandline tool to configure them, and you can also assign them to different "seats" (combinations of keyboard/monitor) or use them alternatively with one monitor.
| Is it possible to use two keyboards simultaneously? |
1,416,950,169,000 |
I am playing with a script that, among other things, list a selection-list. As in:1) Item 1 # (highlighted)
2) Item 2
3) Item 3 # (selected)
4) Item 4
When user press down-arrow next items is highlighted
When user press up-arrow previous items is highlighted
etc.
When user press tab item is selected
When user press shift+tab all items are selected / deselected
When user press ctrl+a all items are selected
...
This works fine as of current use, which is my personal use where input is filtered by my own setup.
Question is how to make this reliable across various terminals.
I use a somewhat hackish solution to read input:
while read -rsn1 k # Read one key (first byte in key press)
do
case "$k" in
[[:graph:]])
# Normal input handling
;;
$'\x09') # TAB
# Routine for selecting current item
;;
$'\x7f') # Back-Space
# Routine for back-space
;;
$'\x01') # Ctrl+A
# Routine for ctrl+a
;;
...
$'\x1b') # ESC
read -rsn1 k
[ "$k" == "" ] && return # Esc-Key
[ "$k" == "[" ] && read -rsn1 k
[ "$k" == "O" ] && read -rsn1 k
case "$k" in
A) # Up
# Routine for handling arrow-up-key
;;
B) # Down
# Routine for handling arrow-down-key
;;
...
esac
read -rsn4 -t .1 # Try to flush out other sequences ...
esac
done
And so on.
As mentioned, question is how to make this reliable across various terminals: i.e. what byte sequences define a specific key. Is it even feasible in bash?
One thought was to use either tput or infocmp and filter by the result given by that. I am however in a snag there as both tput and infocmp differ from what I actually read when actually pressing keys. Same goes for example using C over bash.
for t in $(find /lib/terminfo -type f -printf "%f\n"); {
printf "%s\n" "$t:";
infocmp -L1 $t | grep -E 'key_(left|right|up|down|home|end)';
}
Yield sequences read as defined for for example linux, but not xterm, which is what is set by TERM.
E.g. arrow left:
tput / infocmp: \x1 O D
read: \x1 [ D
What am I missing?
|
What you are missing is that most terminal descriptions (linux is in the minority here, owing to the pervasive use of hard-coded strings in .inputrc) use application mode for special keys. That makes cursor-keys as shown by tput and infocmp differ from what your (uninitialized) terminal sends. curses applications always initialize the terminal, and the terminal data base is used for that purpose.
dialog has its uses, but does not directly address this question. On the other hand, it is cumbersome (technically doable, rarely done) to provide a bash-only solution. Generally we use other languages to do this.
The problem with reading special keys is that they often are multiple bytes, including awkward characters such as escape and ~. You can do this with bash, but then you have to solve the problem of portably determining what special key this was.
dialog both handles input of special keys and takes over (temporarily) your display. If you really want a simple command-line program, that isn't dialog.
Here is a simple program in C which reads a special key and prints it in printable (and portable) form:
#include <curses.h>
int
main(void)
{
int ch;
const char *result;
char buffer[80];
filter();
newterm(NULL, stderr, stdin);
keypad(stdscr, TRUE);
noecho();
cbreak();
ch = getch();
if ((result = keyname(ch)) == 0) {
/* ncurses does the whole thing, other implementations need this */
if ((result = unctrl((chtype)ch)) == 0) {
sprintf(buffer, "%#x", ch);
result = buffer;
}
}
endwin();
printf("%s\n", result);
return 0;
}
Supposing this were called tgetch, you would use it in your script like this:
case $(tgetch 2>/dev/null) in
KEY_UP)
echo "got cursor-up"
;;
KEY_BACKSPACE|"^H")
echo "got backspace"
;;
esac
Further reading:
My cursor keys do not work (ncurses FAQ)
dialog — Script-driven curses widgets (application and library)
keyname/key_name
| Read special keys in bash |
1,512,261,539,000 |
I've tried following the Ubuntu hotkeys/media keys troubleshooting guide and /usr/share/doc/udev/README.keymap.txt.gz to make the Fn keys work. After copying the map file and modifying /lib/udev/rules.d/95-keymap.rules I get the correct key names from sudo /lib/udev/keymap -i input/event4, but none of them do anything at all.
How do I make sure that at least wlan and kbdillumup/kbdillumdown work?
$ /lib/udev/findkeyboards
AT keyboard: input/event4
$ cat /sys/class/dmi/id/sys_vendor
SAMSUNG ELECTRONICS CO., LTD.
$ cat /sys/class/dmi/id/product_name
90X3A
samsung-90x3a map file:
0xCE prog1 # Fn+F1 Unknown
0x8D prog3 # Fn+F6 Economy mode
0x97 kbdillumdown # Fn+F7 Keyboard background light down
0x96 kbdillumup # Fn+F8 Keyboard background light up
0xD5 wlan # Fn+F12 Wifi on/off
$ udevadm info --export-db
Update: The information below will be from Arch Linux since I no longer have Ubuntu.
xdotool key XF86KbdBrightnessUp prints nothing, but returns with exit code 0. I'm not sure if that means anything.
acpi_listen prints nothing when pressing Fn+F7/Fn+F8.
|
Somebody finally found the next best thing. To turn off the backlight, run this:
sudo chattr -i /sys/firmware/efi/efivars/KBDBacklitLvl-5af56f53-985c-47d5-920c-f1c531d06852
echo 0700000000 | xxd -plain -revert | sudo tee /sys/firmware/efi/efivars/KBDBacklitLvl-5af56f53-985c-47d5-920c-f1c531d06852
sudo chattr +i /sys/firmware/efi/efivars/KBDBacklitLvl-5af56f53-985c-47d5-920c-f1c531d06852
and then reboot. To set the illumination low, medium or high, replace 0700000000 in the above with 0700000001, 0700000002 or 0700000003, respectively.
| Fix Fn-keys for keyboard illumination on Samsung Notebook 9 Spin (NP940X3L) |
1,512,261,539,000 |
I don't understand virtual terminal devices (eg. /dev/tty1), but I know I can "switch" to tty1 if I press ctrl + alt + f1.
I've got a custom keyboard layout, which is in /usr/share/X11/xkb/symbols/us but it only "works" if X is running.
Both virtual terminals and X seems to manage keyboard inputs/outputs in their own way, but presumably they both interface with the (Linux) kernel in some way, which must provide some sort of abstraction for the keyboard hardware.
How does the Linux kernel handle keyboard inputs/outputs? Is there a source file I can look at with a list of all scancodes/keycodes/keysims/etc., and, perhaps with the overall logic of how Linux manages the whole idea of a "keyboard"?
(I'm running Lubuntu.)
|
See How do keyboard input and text output work? for an overview of the topic.
In more detail, under Linux, the kernel receives scan codes from the hardware and converts them into keycodes. (This terminology isn't completely standard; you may find “scan code” or “key code” used for both.) How this conversion works depends on the keyboard driver. For PS/2 keyboards, you can configure it with setkeycodes. For USB keyboards, you can configure it via udev. See also the Arch wiki. All user input devices, including keyboards and mice, are exposed via event devices /dev/input/event*.
In a Linux console, keycodes are mapped to escape sequences according to the console keymap. Since a console is a text terminal, applications see bytes, with printable characters representing themselves and function keys encoded using control characters or escape sequences. You can change the mapping with loadkeys. The mapping uses two levels of indirection, from keycode+modifier combination (with three modifiers: shift, control, alt) to keysym and from keysym to string (character or escape sequence). The set of keysyms is fixed, so if you want to define custom combinations you'll need to use existing keysyms that aren't otherwise used such as F13, F14, …
If you want to look at the source code that implements these translations, look at keyboard drivers and generic input code, and udev and libudev.
X11 (the GUI) has its own way to map keycodes to what applications receive. X11 applications see keysyms and modifiers, so function keys don't need to be encoded further. There are in fact two ways to define keymaps under X: the classical method xmodmap, and the newer mechanism XKB which is more powerful but more complex.
| How does the Linux kernel handle keyboards inputs/outputs? |
1,512,261,539,000 |
I want to create and set a custom keyboard layout with setxkbmap. I created a file in ~/.xkb/prog with this content:
partial default alphanumeric_keys
xkb_symbols "basic" {
include "latin(type4)"
name[Group1]="es for developers";
key <AE01> {[ 1, exclam, exclamdown, bar ]};
key <AD03> {[ e, E, EuroSign, sterling ]};
key <AB06> {[ n, N, ntilde, Ntilde ]};
key <AB07> {[ m, M, mu, mu ]};
key <AB10> {[ slash, question, questiondown, dead_hook ]};
include "level3(ralt_switch)"
};
And I tried to load it with setxkbmap -I$HOME/.xkb "prog", but I get a 'Error loading new keyboard description'
I also tried it with setxkbmap -I$HOME/.xkb "prog" -print | xkbcomp -I$HOME/.xkb - $DISPLAY, but I get this error: 'Can't find file "prog" for symbols include'
|
Try that last one, i.e.:
% setxkbmap prog -print | xkbcomp -I$HOME/.xkb - $DISPLAY
But put your layout in ~/.xkb/symbols/prog (note the symbols subdirectory).
| Create and set custom keyboard layout |
1,512,261,539,000 |
Using xmodmap to remap meta key with the following command:
xmodmap -e 'keycode 133 = F14'
How can i make the change permanent, especially on system sleep, resume and reboot?
|
Reboot
On the setting panel (KDE/GNOME) there is a startup section where application can be added to startup session, xmodmap can be added there
Resume
Xmodmap does not keep the changes after sleep/resume, here is how to set xmodmap on system resume with systemd: (non systemd user can use this)
Create xkeyboard resume script:
touch /usr/lib/systemd/system-sleep/xkeyboard; chmod 755 /usr/lib/systemd/system-sleep/xkeyboard
Edit xkeyboard and fill it with:
#!/bin/bash
case $1 in
pre)
exit 0
;;
post)
export DISPLAY=:0
sleep 10
xmodmap -e 'keycode 133 = F14'
;;
esac
| How to make xmodmap changes permanent? |
1,512,261,539,000 |
I'm trying to make slider on MS keyboard working, but still it doesn't.
What I've tried already:
in /etc/udev/hwdb.d/61-keyboard-local.hwdb
keyboard:usb:v045Ep00DB*
KEYBOARD_KEY_c022d=up
KEYBOARD_KEY_c022e=down
and
evdev:input:b0003v045Ep00DB*
KEYBOARD_KEY_c022d=up
KEYBOARD_KEY_c022e=down
following
sudo udevadm hwdb --update
sudo udevadm control --reload
and reboot didn't do anything.
In /lib/udev/keymaps/microsoft-ergonomic-keyboard
0xC022D 0xC1 # Zoom Up which we wish to be Scroll up
0xC022E 0xC2 # Zoom Down which we wish to be Scroll down
and reboot didn't do anything.
In /etc/X11/xorg.conf.d/10-keyboard.conf
Section "InputDevice"
Identifier "Keyboard1"
Driver "evdev"
Option "Device" "/dev/input/event9"
Option "event_key_remap" "418=185 419=186 423=101 425=156 421=157"
EndSection
and reboot didn't do anything.
What I have is
> sudo evtest /dev/input/event9
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x45e product 0xdb version 0x111
Input device name: "Microsoft Natural® Ergonomic Keyboard 4000"
...
Testing ... (interrupt to exit)
Event: time 1478692111.766327, type 4 (EV_MSC), code 4 (MSC_SCAN), value c022d
Event: time 1478692111.766327, type 1 (EV_KEY), code 418 (KEY_ZOOMIN), value 1
Event: time 1478692111.766327, -------------- SYN_REPORT ------------
Event: time 1478692111.886318, type 4 (EV_MSC), code 4 (MSC_SCAN), value c022d
Event: time 1478692111.886318, type 1 (EV_KEY), code 418 (KEY_ZOOMIN), value 0
Event: time 1478692111.886318, -------------- SYN_REPORT ------------
Event: time 1478692112.678287, type 4 (EV_MSC), code 4 (MSC_SCAN), value c022e
Event: time 1478692112.678287, type 1 (EV_KEY), code 419 (KEY_ZOOMOUT), value 1
Event: time 1478692112.678287, -------------- SYN_REPORT ------------
Event: time 1478692112.798370, type 4 (EV_MSC), code 4 (MSC_SCAN), value c022e
Event: time 1478692112.798370, type 1 (EV_KEY), code 419 (KEY_ZOOMOUT), value 0
Event: time 1478692112.798370, -------------- SYN_REPORT ------------
So the slider works, evtest can see events, but xev doesn't show anything.
Is there anything else I can try to make it work in 2016?
I'm using Linux Mint 18 Sarah with 4.4.0-34-generic kernel.
|
Background: Your keyboard is a HID USB device, and the kernel properly recognizes the HID USB events for your slider keys, and translates them to keycodes (KEY_ZOOMIN and KEY_ZOOMOUT). So in that respect, it's already "working": You can receive the events and do something useful with it.
However, the X keyboard translations only supports keycodes up to 255 (see this answer, it's a limitation of the X protocol). So you can't convert them to X keysyms. (And maybe that's not what you want, anyway, because zooming is usually handled by mouse button events in applications, namely button 4 and 5. So even if you did convert it to keysyms, they wouldn't zoom in or out).
But from what you tried to do, it looks like you want to remap them to up and down keys, identical to the arrow up and down keys that are already available as other keys on the keyboard.
As mentioned in the answer already linked, to enable X to remap keycodes greater than 255, somebody created a patched variant of the X evdev driver. So you need to compile and install this patched variant, and then the option event_key_remap will be recognized. It won't be recognized by the standard evdev driver, so it's no surprise that your xorg.conf entry didn't do anything.
That's probably the cleanest method.
In the process of taking over all of Linux, systemd apparently also has now its own hardware database and can overwrite keyboard mappings. I'm not really sure on which level of the kernel this is working, so I don't know if it will help at all, and the format for the "hardware database" doesn't seem to be documented. So I can't help you much in this respect.
However, the format for matching seems to have changed, so maybe you have more luck if you include the bus number, as described.
Edit: Reading the kernel source, I found that each input device has its own scancode (hardware dependend, up to 8 bytes, though in many places only 1/2/4 bytes in the kernel are transferred) to keycode (what you see with evtest) translation mappings. Large code values can be set and get with the EVIOCGKEYCODE_V2 and EVIOCSKEYCODE_V2 ioctls on the device. A general tool similar to xmodmap or loadkeys/dumpkeys doesn't seem to exist, though some IR receiver related tools apparently use these ioctls. If that's how the systemd database works, a more flexible alternative would to be to use such a tool in a udev rule (also simpler for testing). I've written a quick C program to dump the mapping, maybe I should put it on github ...
In principle, you can already process the events with your own programs or scripts and do anything you'd like to do. For example, run evtest on it, parse the output with a bash script, and invoke xdotool with button presses of 4 or 5 to get the same effect as a mouse scrollwheel for your slider buttons. Etc., pp. (There was a stackexchange question with a rudimentary script for a similar purpose, but I can't find it right now. If necessary, I can search some more).
| How to get MS Natural Ergonomic 4000 slider work on Linux Mint? |
1,512,261,539,000 |
Looking for an answer I came across this question. There's something like this:
The keycode X uses and the keycode the kernel uses are OFF BY 8 for "historical reasons". So take 97 - 8 = 89 and use 89 with the setkeycodes command (again as root):
Does anyone know what the historical reasons are and why the codes differ by 8?
|
The X11 protocol defines a keycode as a 8-bit value in the range [8,255]. The value 0 is a special value for AnyKey - I don't remember if anything uses 1-7, or they were simply reserved for future special cases.
| Why does showkey show a different keycode compared to xev? |
1,512,261,539,000 |
I've saved the output of
$ xmodmap -pke
in ~/.map1.
Then, I have changed some settings through the Gnome Tweak Tool (say, to keep it simple, I swapped Esc and Caps Lock).
Then I again saved the output of
$ xmodmap -pke
this time into ~/.map2.
~/.map1 and ~/.map2 are different. And they are different exactly in the way I was expecting. The differences correspond to the keys I have changed.
However I was not expecting the following:
I have disabled all the changes made within the Gnome Tweak Tool, and I have loaded map2 with
$ xmodmap ~/.map2
I was expecting the same behavior achieved with the changes made with the Gnome Tweak Tool. But this is not the case. (That is now in the Gnome Terminal there is no difference of behavior whatsoever compared to the default settings. Within applications instead Esc key works correctly as Caps Lock, but it doesn't turn on the light of Caps Lock. And finally Caps Lock key seems to perform both the Esc and Caps Lock function).
So the following question arises: What are the files that the Gnome Tweak Tool is acting on?
It would be extremely useful for me to understand how things work here since I want to perform some changes that the Tweak Tool doesn't allow me to do and I'm not able to achieve them with xmodmap.
Thanks!
|
The files altered by gnome-tweak-tool are ~/.config/dconf/user (this is the dconf database, a binary file where most user settings are stored) and various other configuration files under ~/.config (these are all text files)
In this particular case - changing the typing settings - gnome-tweak-tool alters the xkb-options in the dconf database. It's easy to check that if you monitor the database with
dconf watch /
and then open gnome-tweak-tool and make CapsLock an additional Esc you'll get an output like
/org/gnome/desktop/input-sources/xkb-options
['caps:escape']
| What files does the Gnome Tweak Tool act on (when changing the Typing settings)? |
1,512,261,539,000 |
I have a Chromebook on which I installed Arch Linux. However, this Chromebook comes with a very odd key: a "Power On/Off" key at the top right of the keyboard. Without ANY warning, this button turns off the computer. Naturally, I have been pressing this key when looking for backspace or when my finger slipped while pressing surrounding buttons. As a consequence, I have turned off my computer at very impractical moments. This has to stop.
How can I disable or remap this key?
|
I found your solution on the Arch wiki:
Out of the box, systemd-logind will catch power key and lid switch
events and handle them: it will shut down the Chromebook on a power
key press, and a suspend on a lid close. However, this policy might be
a bit harsh given that the power key is an ordinary key at the top
right of the keyboard that might be pressed accidentally.
To configure logind to ignore power key presses and lid switches, add
the lines to logind.conf below.
/etc/systemd/logind.conf
HandlePowerKey=ignore
HandleLidSwitch=ignore
Then restart logind for the changes to take effect.
It looks like you just need to add HandlePowerKey=ignore to /etc/systemd/logind.conf.
| Disable the Power button on a Chromebook |
1,512,261,539,000 |
The Wikipedia page on Unix Signals says:
SIGWINCH
The SIGWINCH signal is sent to a process when its controlling terminal changes its size (a window change).
Is it possible to send SIGWINCH from the keyboard?
If so, how?
|
use pgrep myprogram to get pid of myprogram
kill -SIGWINCH pid
you may use
kill -l
to get list of supported signal in numerical form.
kill -28 1234
| Send SIGWINCH from the keyboard |
1,512,261,539,000 |
I just installed VirtualBox (from Oracle) in Windows 7, and created a virtual machine with latest Ubuntu.
Here in Firefox I can use the left Ctrl key, while the right one doesn't have any effect. However, I can't use the AltGr key (also known as Right Alt) to produce e.g. curly braces like {} (I pasted that via Ctrl V).
In a terminal window I can switch the "Input method" to "Multipress", and then I can use AltGr to type e.g. {}, which is how I produced those characters for this posting. However, with "Multipress" the Ctrl keys seem to have no effect whatsoever. So in order to e.g. type Ctrl D I have to right click and switch the "Input method" to "System (IBus (Intelligent Input Bus))". Then AltGr does not work.
I tried specifying the compose key in the system settings keyboard layout.
With that, neither Ctrl nor AltGr worked.
Here's what xmodmap reports:
[~]
$ xmodmap -pke | grep -i control
keycode 37 = Control_L NoSymbol Control_L
keycode 105 = Control_R NoSymbol Control_R
[~]
$ xmodmap -pke | grep -i alt
keycode 64 = Alt_L Meta_L Alt_L Meta_L
keycode 204 = NoSymbol Alt_L NoSymbol Alt_L
[~]
$ _
How can I fix this?
Additional info: the keyboard is a standard PC keyboard, a Logitech K120, with Norwegian layout.
Also, I first tried asking this question over at the Superuser site but no response after 2 days...
|
Run the command xev. In the xev window, press the AltGr key. You'll see something like
KeyPress event, serial 29, synthetic NO, window 0x6400001,
root 0x105, subw 0x0, time 966635535, (243,-207), root:(1891,26),
state 0x0, keycode 66 (keysym 0xff7e, Mode_switch), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
Note the keycode; since the key isn't doing what you want, you'll see something else (possibly Alt_R) instead of Mode_switch. You want to assign this keycode to Mode_switch, which is X11's name for AltGr. Put the following command in a file called .Xmodmap (note capital X) in your home directory:
keycode 66 = Mode_switch
Additionally, you may need to assign a modifier to Mode_switch, but if all that's happening is a keycode discrepancy there'll already be one. See Set the key for spanish eñe letter for more information.
Run xmodmap ~/.Xmodmap to test your file. On many systems, including Ubuntu 10.04, this file is loaded automatically in the default Gnome environment. On other distributions or environments, you may need to indicate explicitly that you want to run xmodmap ~/.Xmodmap when you log in.
| AltGr keys don't work with Ubuntu in VirtualBox |
1,512,261,539,000 |
I just found a tip to set the compose key manually:
setxkbmap -option compose:caps
Unfortunately, after running this several keypresses act as if the compose key had been pressed. For example, to get a tilde, I now have to press Shift-~ twice, and I can no longer figure out how to get a single or double quote - When I press that key twice (without pressing Caps Lock) I get a single ´ (without Shift) or ¨ (with Shift) character.
$ setxkbmap -print
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+us(dvorak-intl)+inet(evdev)+level3(ralt_switch)+compose(caps)" };
xkb_geometry { include "pc(pc105)" };
};
Setting the compose key to the more popular Right-Alt did not help - The results are the same with the following settings:
$ setxkbmap -print
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+us(dvorak-intl)+inet(evdev)+level3(ralt_switch)+compose(ralt)" };
xkb_geometry { include "pc(pc105)" };
};
Stranger still, even after disabling the compose key with setxkbmap -option the keys are still messed up.
On a different machine with GNOME 3 and similar settings it works just fine (Caps Lock, a, a produces å, while a single press of Shift-~ produces ~):
$ setxkbmap -print
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+us(dvorak-alt-intl)+ch:2+inet(evdev)+compose(caps)" };
xkb_geometry { include "pc(pc105)" };
};
Maybe it's an LXDE issue - I'll test it next week.
|
Turns out the problem was actually the keyboard layout - Switching to English (Dvorak alternative international no dead keys) (XKBVARIANT="dvorak-alt-intl" in /etc/default/keyboard) fixed it.
Unfortunately I can't find a way to set this for my user only.
| Why does the setxkbmap compose key mess with other keys? |
1,512,261,539,000 |
Sometimes I'd like to get some command from history output, copy it to a bash prompt, make some changes and run it. Is there a way to copy a command from history output to a bash prompt without involving the mouse? For example, it would be some script that I can bind a shortcut to.
Maybe I do not understand fc enough, but it looks like I cannot select folders or files via fc (like Tab for usual command prompt)
|
The following is a tmux way.
Enter command number (like !1234) and press Alt+Shift+X. After that command with number 1234 will be printed in terminal prompt and this command is editable as usual.
copy_line_from_history_to_prompt () {
READLINE_LINE=$( history -p "$READLINE_LINE" ) ;
}
bind -x '"eX": copy_line_from_history_to_prompt' # Alt+Shift+X
| Copy command from history to bash prompt |
1,512,261,539,000 |
How can I create a script that automatically switches windows? I'm trying to do the same thing Alt+Tab does.
|
Sounds like you're looking for wmctrl - see here for more examples.
Edit: Your window manager/desktop environment has to be standards compliant (EWMH). And here are more examples.
| How to switch X windows from the command-line? |
1,512,261,539,000 |
I recently got a new laptop and installed Arch on it. I noticed that in a few applications, including chrome and gedit, pressing ctrl+shift+e will cause the next few keys pressed to be underlined, beep when pressed, and then deleted.
I've looked around for a while, and the only way I can seem to "fix" it is to unload the pcspkr module. However, this still doesn't fix the issue, it only silences the beeping.
It seems to happen under both gnome and i3, but not in a tty.
Is there any way I can turn this off?
Video of the behavior
|
Seee https://askubuntu.com/a/1039039
One needs to run ibus-setup and in the tab "Emoji" change the shortcut (click on the three dots that are focused in the screenshot)
| ctrl+shift+e causes beeping |
1,512,261,539,000 |
I'm currently learning about the Linux Kernel and OSes in general, and while I have found many great resources concerning IRQs, Drivers, Scheduling and other important OS concepts, as well as keyboard-related resources, I am having a difficult time putting together a comprehensive overview of how the Linux Kernel handles a button press on a keyboard. I'm not trying to understand every single detail at this stage, but am rather trying to connect concepts, somewhat comprehensively.
I have the following scenario in mind:
I'm on a x64 machine with a single processor.
There're a couple of processes running, notably the Editor VIM (Process #1) and say LibreOffice (Process #2).
I'm inside VIM and press the a-key. However, the process that's currently running is Process #2 (with VIM being scheduled next).
This is how I imagine things to go down right now:
The keyboard, through a series of steps, generates an electrical signal (USB Protocol Encoding) that it sends down the USB wire.
The signal gets processed by a USB-Controller, and is send through PCI-e (and possibly other controllers / buses?) to the Interrupt Controller (APIC). The APIC triggers the INT Pin of the processor.
The processor switches to Kernel Mode and request an IRQ-Number from the APIC, which it uses as an offset into the Interrupt Descriptor Table Register (IDTR). A descriptor is obtained, that is then used to obtain the address of the interrupt handler routine. As I understand it, this interrupt handler was initially registered by the keyboard driver?
The interrupt handler routine (in this case a keyboard handler routine) is invoked.
This brings me to my main question: By which mechanism does the interrupt handler routine communicate the pressed key to the correct Process (Process #1)? Does it actually do that, or does it simply write the pressed key into a buffer (available through a char-device?), that is read-only to one process at a time (and currently "attached" to Process #1)? I don't understand at which time Process #1 receives the key. Does it process the data immediately, as the interrupt handler schedules the process immediately, or does it process the key data the next time that the scheduler schedules it?
When this handler returns (IRET), the context is switched back to the previously executing process (Process #2).
|
Your understanding so far is correct, but you miss most of the complexity that's built on that. The processing in the kernel happens in several layers, and the keypress "bubbles up" through the layers.
The USB communication protocol itself is a lot more involved. The interrupt handler routine for USB handles this, and assembles a complete USB packet from multiple fragments, if necessary.
The key press uses the so-called HID ("Human interface device") protocol, which is built on top of USB. So the lower USB kernel layer detects that the complete message is a USB HID event, and passes it to the HID layer in the kernel.
The HID layer interprets this event according to the HID descriptor it has required from the device on initialization. It then passes the events to the input layer. A single HID event can generate multiple key press events.
The input layer uses kernel keyboard layout tables to map the scan code (position of the key on the keyboard) to a key code (like A) and interprets Shift, Alt, etc. The result of this interpretation is made available via /dev/input/event* to userland processes. You can use evtest to watch those events in real-time.
But processing is not finished here. The X Server (responsible for graphics) has a generic evdev driver that reads events from /dev/input/event* devices, and then maps them again according to a second set of keyboard layout tables (you can see those partly with xmodmap and fully via the XKBD extension). This is because the X server predates the kernel input layer, and in earlier times had drivers to handle mouse and PS/2 keys directly.
Then the X server sends a message to the X client (application) containing the keyboard event. You can see those messages with the xev application. LibreOffice will process this event directly, VIM will be running in an xterm which will process the event, and (you guessed it) again add some extra processing to it, and finally pass it to VIM via stdin.
Complicated enough?
| How does a keyboard press get processed in the Linux Kernel? |
1,512,261,539,000 |
In my shell I have flow control disabled using stty -ixon. This works
perfectly in the shell and when I launch tmux and start programs within
tmux.
However, when starting a new session from the command line and directly
launching a command, the flow control setting is not respected and
ctrl-s freezes the terminal.
This works:
tmux new-session -s foo
vim
This does not respect the stty flow control setting:
tmux new-session -s foo vim
How can I disable flow control even in the latter case?
|
If you have stty -ixon in your shell's initialization, it's rather simple: when tmux creates new terminals, it runs user's default shell by default and that in turn disables the control flow during the initialization. However, when you ask tmux to run a specific command (ViM in your case), no initialization takes place and the default terminal settings (flow control enabled) apply.
tmux new-session -s foo "stty -ixon; vim"
should fix your problem.
| tmux not respecting disabled control flow |
1,512,261,539,000 |
When i type Ctrl+Left or Ctrl+Right within Guake or gnome-terminal the last one's behaviour turns to a some kind of non-usual mode: - key acts like arrow up and + like arrow down, v runs Nano, etc. How can i disable this feature ?
UPD: my friend told me that's X.org hotkeys... How can i disable 'em? Googling does not help at all...
UPD2: here's a video showing what's going on.
|
The solution was pretty elegant and simple: editing /etc/inputrc and disabling vi mode.
Here's the renewed inputrc file:
# /etc/inputrc - global inputrc for libreadline
# See readline(3readline) and `info rluserman' for more information.
# Be 8 bit clean.
set input-meta on
set output-meta on
#set editing-mode vi
# To allow the use of 8bit-characters like the german umlauts, uncomment
# the line below. However this makes the meta key not work as a meta key,
# which is annoying to those which don't need to type in 8-bit characters.
# set convert-meta off
# try to enable the application keypad when it is called. Some systems
# need this to enable the arrow keys.
# set enable-keypad on
# see /usr/share/doc/bash/inputrc.arrows for other codes of arrow keys
# do not bell on tab-completion
# set bell-style none
# set bell-style visible
# some defaults / modifications for the emacs mode
#$if mode=emacs
# allow the use of the Home/End keys
"\e[1~": beginning-of-line
"\e[4~": end-of-line
# allow the use of the Delete/Insert keys
"\e[3~": delete-char
"\e[2~": quoted-insert
# mappings for "page up" and "page down" to step to the beginning/end
# of the history
# "\e[5~": beginning-of-history
# "\e[6~": end-of-history
# alternate mappings for "page up" and "page down" to search the history
# "\e[5~": history-search-backward
# "\e[6~": history-search-forward
# mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
"\e[1;5C": forward-word
"\e[1;5D": backward-word
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word
$if term=rxvt
"\e[8~": end-of-line
"\eOc": forward-word
"\eOd": backward-word
$endif
# for non RH/Debian xterm, can't hurt for RH/Debian xterm
# "\eOH": beginning-of-line
# "\eOF": end-of-line
# for freebsd console
# "\e[H": beginning-of-line
# "\e[F": end-of-line
#$endif
Should read more 'bout that modes. Thanks everybody for the trouble-taking!
| Why does Ctrl+Arrow make my terminal switch to a strange mode? |
1,512,261,539,000 |
The Archwiki article Map scancodes to keycodes states
Mapping scancodes to keycodes is universal and not specific to Linux console or Xorg [...]
while the Archwiki article Extra keyboard keys (which the former article suggests to read) states
Note that the keycodes are different for Linux console and Xorg.
Which of the two is true? Or am I getting something wrong and it is no contradiction at all?
|
The keycodes are numerically different: The X keycode value is derived by adding 8 (the value of MIN_KEYCODE) to the Linux input layer keycode, as you can see in the source of evdev.c, line 280. Apart from this, they are identical (same order, same meaning).
Mapping scancodes to keycodes is actually done per input device, so it's not "universal" in this sense: you can connect two USB keyboards to the computer and give each keyboard its own mapping; funnily, there doesn't seem to be standard utility program to do this. However, the resulting keycodes will be the same for the Linux console and X (ignoring the numerical difference).
| Mapping scancodes to keycodes |
1,512,261,539,000 |
The other day, I was using a laptop for general desktop use when its keyboard began to act up. Most of the keys on the keyboard's right side stopped working entirely and key combinations such as Ctrlu made characters appear that should not have appeared. The backspace key exhibited the strangest behavior; it was somehow able to cause the deletion characters in the shell prompt.
I was unable to reboot the computer cleanly so I did a hard shutdown. When I turned the computer on again, I received this message from Grub:
GRUB loading.
Welcome to GRUB!
incompatible license
Aborted. Press any key to exit.
I pressed the any key and Grub responded with
Operating System Not Found.
Pressing another key causes the first message to appear again. Pressing another key after that causes the second message to appear... and so on.
If I leave the laptop on for a few minutes, its fan speeds up significantly as if the laptop is running a CPU-intensive program.
I took the hard drive out of the laptop, mounted it on a server, and looked around. I saw nothing strange in /boot.
The laptop is running Arch Linux. The drive is partitioned with GPT. The laptop works fine with a hard drive from another machine. And other machines do not work with the laptop's hard drive.
I am not certain that the keyboard issues are directly related to the Grub issues.
What could be causing the problems that I am having? Or, what should I do to find out or narrow down the list of potential causes?
Just in case it's relevant, here (removed) is a tarball with /boot and /etc/grub.d and here is my Grub configuration:
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
insmod part_gpt
insmod part_msdos
if [ -s $prefix/grubenv ]; then
load_env
fi
set default="0"
if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
else
menuentry_id_option=""
fi
export menuentry_id_option
if [ "${prev_saved_entry}" ]; then
set saved_entry="${prev_saved_entry}"
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi
function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}
function load_video {
if [ x$feature_all_video_module = xy ]; then
insmod all_video
else
insmod efi_gop
insmod efi_uga
insmod ieee1275_fb
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
fi
}
if [ x$feature_default_font_path = xy ] ; then
font=unicode
else
insmod part_gpt
insmod ext2
set root='hd0,gpt1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 d44f2a2f-c369-456b-81f1-efa13f9caae2
else
search --no-floppy --fs-uuid --set=root d44f2a2f-c369-456b-81f1-efa13f9caae2
fi
font="/usr/share/grub/unicode.pf2"
fi
if loadfont $font ; then
set gfxmode=auto
load_video
insmod gfxterm
set locale_dir=$prefix/locale
set lang=en_US
insmod gettext
fi
terminal_input console
terminal_output gfxterm
set timeout=5
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Arch GNU/Linux, with Linux PARA kernel' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-PARA kernel-true-d44f2a2f-c369-456b-81f1-efa13f9caae2' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
set root='hd1,gpt1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt1 --hint-efi=hd1,gpt1 --hint-baremetal=ahci1,gpt1 b4fbf4f8-303c-49bd-a52f-6049e1623a26
else
search --no-floppy --fs-uuid --set=root b4fbf4f8-303c-49bd-a52f-6049e1623a26
fi
echo 'Loading Linux PARA kernel ...'
linux /boot/vmlinuz-linux-PARA root=UUID=d44f2a2f-c369-456b-81f1-efa13f9caae2 ro quiet
echo 'Loading initial ramdisk ...'
initrd /boot/initramfs-linux-PARA.img
}
menuentry 'Arch GNU/Linux, with Linux core repo kernel' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-core repo kernel-true-d44f2a2f-c369-456b-81f1-efa13f9caae2' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
set root='hd1,gpt1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt1 --hint-efi=hd1,gpt1 --hint-baremetal=ahci1,gpt1 b4fbf4f8-303c-49bd-a52f-6049e1623a26
else
search --no-floppy --fs-uuid --set=root b4fbf4f8-303c-49bd-a52f-6049e1623a26
fi
echo 'Loading Linux core repo kernel ...'
linux /boot/vmlinuz-linux root=UUID=d44f2a2f-c369-456b-81f1-efa13f9caae2 ro quiet
echo 'Loading initial ramdisk ...'
initrd /boot/initramfs-linux.img
}
menuentry 'Arch GNU/Linux, with Linux core repo kernel (Fallback initramfs)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-core repo kernel-fallback-d44f2a2f-c369-456b-81f1-efa13f9caae2' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
set root='hd1,gpt1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt1 --hint-efi=hd1,gpt1 --hint-baremetal=ahci1,gpt1 b4fbf4f8-303c-49bd-a52f-6049e1623a26
else
search --no-floppy --fs-uuid --set=root b4fbf4f8-303c-49bd-a52f-6049e1623a26
fi
echo 'Loading Linux core repo kernel ...'
linux /boot/vmlinuz-linux root=UUID=d44f2a2f-c369-456b-81f1-efa13f9caae2 ro quiet
echo 'Loading initial ramdisk ...'
initrd /boot/initramfs-linux-fallback.img
}
### END /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###
### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" --class memtest86 --class gnu --class tool {
insmod part_gpt
insmod ext2
set root='hd1,gpt1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt1 --hint-efi=hd1,gpt1 --hint-baremetal=ahci1,gpt1 b4fbf4f8-303c-49bd-a52f-6049e1623a26
else
search --no-floppy --fs-uuid --set=root b4fbf4f8-303c-49bd-a52f-6049e1623a26
fi
linux16 ($root)/boot/memtest86+/memtest.bin
}
### END /etc/grub.d/20_memtest86+ ###
### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###
### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###
### BEGIN /etc/grub.d/41_custom ###
if [ -f ${config_directory}/custom.cfg ]; then
source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
Update
After installing LILO last night, the computer booted just fine at least once. When I booted the computer this morning, I was faced with a kernel panic:
Initramfs unpacking failed: junk in compressed archive
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(8,1)
Pid: 1, comm: swapper/0 Not tainted 3.8.7-1-ARCH #1
Call Trace:
...
Here is a picture of the kernel panic.
Update 2
I reinstalled LILO and no longer receive the kernel panic on boot.
|
Update2:
Forgot you posted the tar ball. Too bad. Anyhow, did a test on your .mod files
by using the below code and:
./grum_lic_test32 evan_teitelman/boot/grub/i386-pc/*.mod
which yielded the following error:
...
bufio.mod License: LICENSE=GPLv3+ OK
cacheinfo.mod License: LICENSE=NONE_FOUND ERR
cat.mod License: LICENSE=GPLv3+ OK
chain.mod License: LICENSE=GPLv3+ OK
...
but that file is identical with the one from Archlinux download, so it should
not be an issue. In other words, was not the cause.
Also, first now, notice you have installed LILO, – and guess by that the case
is closed. If not there is always the question about GPT and BIOS + other issues. Did you install it the first time? Can be that there was some tweak
involved on first install that reinstall of GRUB did not fix.
Update1: OK. Fixed. Should work for both 32 and 64-bit ELF's.
When GRUB get to the phase of loading modules it check for license embedded
in ELF file for each module. If non valid is found the module is ignored –
and that specific error is printed. Could be one or more modules are corrupted.
If it is an essential module everything would go bad. Say e.g part_gpt.mod
or part_msdos.mod.
Accepted licenses are GPLv2+, GPLv3 and GPLv3+.
It could of course be other reasons; but one of many could be corrupted module file(s).
It seems like the modules are valid ELF files as they are validated as such
before the license test. As in: if ELF test fail license test is not executed.
Had another issue with modules where I needed to check for various, have
extracted parts of that code and made it into a quick license tester. You could
test each *.mod file in /boot/grub/* to see which one(s) are corrupt.
This code does not validate ELF or anything else. Only try to locate license
string and check that. Further it is only tested under i386/32-bit. The original
code where it is extracted from worked for x86-64 as well – but here a lot is stripped and hacked so I'm not sure of the result. If it doesn't work under 64-bit it should most likely only print License: LICENSE=NONE_FOUND.
(As noted in edit above I have now tested for 32 and 64-bit, Intel.)
As a separate test then would be to do something like:
xxd file.mod | grep -C1 LIC
Not the most beautiful code – but as a quick and dirty check.
(As in; you could try.)
Compile instructions e.g.:
gcc -o grub_lic_test32 source.c # 32-bit variant
gcc -o grub_lic_test64 source.c -DELF64 # 64-bit variant
Run:
./grub_lic_test32 /path/to/mods/*.mod
Prints each file and license, eg:
./grub_lic_test32 tar.mod gettext.mod pxe.mod
tar.mod License: LICENSE=GPLv1+ BAD
gettext.mod License: LICENSE=GPLv3+ OK
pxe.mod License: LICENSE=GPLv3+ OK
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
#ifdef ELF64
struct ELF_hdr
{
unsigned char dummy0[16];
uint32_t dummy1[6];
uint64_t sh_off;
uint16_t dummy2[5];
uint16_t sh_entsize;
uint16_t sh_num;
uint16_t sh_strndx;
};
struct ELF_sect_hdr
{
uint32_t sh_name;
uint32_t dummy0[5];
uint64_t sh_offset;
};
#else
struct ELF_hdr
{
unsigned char dummy0[16];
uint32_t dummy1[4];
uint32_t sh_off;
uint16_t dummy2[5];
uint16_t sh_entsize;
uint16_t sh_num;
uint16_t sh_strndx;
};
struct ELF_sect_hdr
{
uint32_t sh_name;
uint32_t dummy[3];
uint32_t sh_offset;
};
#endif
enum {
ERR_FILE_OPEN = 1,
ERR_FILE_READ,
ERR_MEM,
ERR_BAD_LICENSE,
ERR_ELF_SECT_CORE_BREACH
};
int file_size(FILE *fh, size_t *fs)
{
size_t cp;
cp = ftell(fh);
fseek(fh, 0, SEEK_END);
*fs = ftell(fh);
fseek(fh, cp, SEEK_SET);
return 0;
}
static const char *valid_licenses[] = {
"LICENSE=GPLv2+",
"LICENSE=GPLv3",
"LICENSE=GPLv3+",
NULL
};
int grub_check_license(struct ELF_hdr *e)
{
struct ELF_sect_hdr *s;
const char *txt;
const char *lic;
unsigned i, j = 0;
s = (struct ELF_sect_hdr *)
((char *) e + e->sh_off + e->sh_strndx * e->sh_entsize);
txt = (char *) e + s->sh_offset;
s = (struct ELF_sect_hdr *) ((char *) e + e->sh_off);
for (i = 0; i < e->sh_num; ++i) {
if (strcmp (txt + s->sh_name, ".module_license") == 0) {
lic = (char*) e + s->sh_offset;
if (j)
fprintf(stdout, "%25s", "");
fprintf(stdout, "License: %-25s ", lic);
for (j = 0; valid_licenses[j]; ++j) {
if (!strcmp (lic, valid_licenses[j])) {
fprintf(stdout, "OK\n");
return 0;
}
}
fprintf(stdout, "BAD\n");
}
s = (struct ELF_sect_hdr *) ((char *) s + e->sh_entsize);
}
if (!j)
fprintf(stdout, "License: %-25s ERR\n", "LICENSE=NONE_FOUND");
return ERR_BAD_LICENSE;
}
int grub_check_module(void *buf, size_t size, int verbose)
{
struct ELF_hdr *e = buf;
/* Make sure that every section is within the core. */
if (e->sh_off + e->sh_entsize * e->sh_num > size) {
fprintf(stderr, "ERR: Sections outside core\n");
if (verbose)
fprintf(stderr,
" %*s: %u bytes\n"
#ifdef ELF64
" %*s %u < %llu\n"
" %*s: %llu\n"
#else
" %*s %u < %u\n"
" %*s: %u\n"
#endif
" %*s: %u\n"
" %*s: %u\n"
,
-25, "file-size", size,
-25, "",
size, e->sh_off + e->sh_entsize * e->sh_num,
-25, "sector header offset", e->sh_off,
-25, "sector header entry size", e->sh_entsize,
-25, "sector header num", e->sh_num
);
return ERR_ELF_SECT_CORE_BREACH;
}
return grub_check_license(e);
}
int grub_check_module_file(const char *fn, int verbose)
{
FILE *fh;
void *buf;
size_t fs;
int eno;
char *base_fn;
if (!(base_fn = strrchr(fn, '/')))
base_fn = (char*)fn;
else
++base_fn;
fprintf(stderr, "%-25s ", base_fn);
if (!(fh = fopen(fn, "rb"))) {
fprintf(stderr, "ERR: Unable to open `%s'\n", fn);
perror("fopen");
return ERR_FILE_OPEN;
}
file_size(fh, &fs);
if (!(buf = malloc(fs))) {
fprintf(stderr, "ERR: Memory.\n");
fclose(fh);
return ERR_MEM;
}
if (fread(buf, 1, fs, fh) != fs) {
fprintf(stderr, "ERR: Reading `%s'\n", fn);
perror("fread");
free(buf);
fclose(fh);
return ERR_FILE_READ;
}
fclose(fh);
eno = grub_check_module(buf, fs, verbose);
free(buf);
return eno;
}
int main(int argc, char *argv[])
{
int i = 1;
int eno = 0;
int verbose = 0;
if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'v') {
verbose = 1;
++i;
}
if (argc - i < 1) {
fprintf(stderr, "Usage: %s [-v] <FILE>[, FILE[, ...]]\n", argv[0]);
return 1;
}
for (; i < argc; ++i) {
eno |= grub_check_module_file(argv[i], verbose);
if (eno == ERR_MEM)
return eno;
}
return eno;
}
| Grub 'incompatible license' error |
1,512,261,539,000 |
I've got a new keyboard (Steelseries Apex).
It has extra key, but I can't get linux to detect it.
I tried xev, getscancodes, showkey --scancodes and dmesg!
Any of those command give me error or code when I hit the keys.
What else can I try?
|
I've created an utility that sends neccesary commands to the keyboard for it to report additional key events:
https://github.com/tuxmark5/ApexCtl
| Recognise extra keyboard keys: Steelseries Apex |
1,512,261,539,000 |
I am running Debian GNOME 8.0.
I would like to have Numlock ON as default.
So I followed the instructions on this page:
https://wiki.archlinux.org/index.php/Activating_Numlock_on_Bootup#GDM
replacing gdm by gdm3 for my case.
This turns Numlock ON at login.
But then, after login, Numlock is automatically switched OFF again, and I cannot figure out how to leave it ON.
I looked at this page :
Keep NumLock always on
and edited my .bashrc file to add this line:
xmodmap -e "keycode # = """
which works to disable Numlock key. But since Numlock is OFF when my session opens, I could not turn it ON anymore! Thus it did not solve my problem. That would be useful if my Numlock was ON by default. (I re-enabled the Numlock key).
As information, I had initially installed Debian LXDE, but added GDM to switch to GNOME, and then removed and purged lxde* and lightdm*.
I feel like this is the reason for my problem, since:
I found on the web that LXDE switches numlock OFF as default
my other computer, on which I installed Debian GNOME natively, does not have this problem.
I am sure to be using GNOME since:
pierre@Ockham:~$ echo $XDG_SESSION_DESKTOP
gnome
pierre@Ockham:~$ echo $GDMSESSION
gnome
pierre@Ockham:~$ echo $XDG_CURRENT_DESKTOP
GNOME
However, just in case lightdm would still play a role, I did try to follow the instructions on that page:
http://wiki.archlinux.org/index.php/LightDM#NumLock_on_by_default
and that one:
http://linuxquestions.org/questions/debian-26/howto-debian-7-wheezy-lxde-auto-numlock-both-before-and-after-login-4175500323/
but it did not solve the problem.
Does anybody have an idea?
By the way, the /etc/xdg/ folder still contains LXDE and Openbox (which I also removed) folders:
pierre@Ockham:/etc/xdg$ ls
autostart libfm lxlauncher lxpanel lxsession menus openbox pcmanfm systemd user-dirs.conf user-dirs.defaults
Is it normal or should I remove them? And how?
|
The solution was actually very simple (see @don_crissti 's comment): set the dconf key remember-numlock-state (under org > gnome > settings-daemon > peripherals > keyboard) value to true via dconf-editor or in terminal:
gsettings set org.gnome.settings-daemon.peripherals.keyboard remember-numlock-state true
| Remember Numlock state after login in GNOME |
1,512,261,539,000 |
So basically my End, Pageup/Pagedown, and Delete key are not working in ksh93. I'm running FreeBSD by the way.
My arrow keys are working, and so is my home key.
Those keys work when I put this in my .kshrc
set -o emacs
I have tried doing THIS, by putting this in my .kshrc. To make the End key work.
alias __Y=`echo "\005"` # end = ^e = end of line
I opened up vim, and pressed Ctrlv, and typed 005. And the ^E showed up. Still, nothing worked.
Anyone know anyway to get those key to work?
Also, When ever I press those keys it prints out a ~. I also know that I could use Ctrld, or Ctrla, I do NOT want to use these.
|
That answer is specific to certain terminal emulators, I don't think it can be generalized outside Solaris.
In ksh, press Ctrl+V then End. This will insert a literal escape character followed by the rest of the escape sequence that the key sends. For example, you might see ^[[4~ (the ^[ at the beginning is in fact an escape character, not ^ followed by [). Do the same for the other cursor keys you want to reconfigure.
In your .kshrc, set a KEYBD trap to translate the escape sequences from the function keys into the bindings for the commands you want the key to invoke. For example (you may need to adjust the escape sequences — note that inside $'…',\e` means an escape character):
keybd_trap () {
case ${.sh.edchar} in
$'\e[1~') .sh.edchar=$'\001';; # Home = beginning-of-line
$'\e[4~') .sh.edchar=$'\005';; # End = end-of-line
$'\e[5~') .sh.edchar=$'\e>';; # PgUp = history-previous
$'\e[6~') .sh.edchar=$'\e<';; # PgDn = history-next
$'\e[3~') .sh.edchar=$'\004';; # Delete = delete-char
esac
}
trap keybd_trap KEYBD
set -o emacs
| Korn Shell: End, pgup, pgdown, and delete key not working |
1,512,261,539,000 |
I'm using a logitech k810 bluetooth keyboard with my laptop running Debian Wheezy. (I got the keyboard working by following this guide.)
By default the F1-12 keys are multimedia keys unless the FN key is pressed. I prefer the keys to be F1-12 by default.
Luckily this guy made a program that reverses the key functions. Running the program works to get the keys as I like and it survives reboot.
Unfortunately the program doesn't survive if I turn the keyboard off and on again (to save power.)
For this reason I'm trying to make a udev rule to run the key reversal program when the keyboard connects.
I've been trying the the following solution which is proposed in both the above links. So far it's not working.
andreas@crunchbang:/etc/udev/rules.d$ cat 00-k810.rules
KERNEL==”hidraw*”, SUBSYSTEM==”hidraw”, ATTRS{address}==”00:1F:20:76:41:30”, RUN+=”/srv/scripts/k810.sh %p”
andreas@crunchbang:/srv/scripts$ cat k810.sh
#! /bin/bash
line=`dmesg | grep -i k810 | grep hidraw`
[[ $line =~ (.*)(hidraw+[^:])(.*) ]]
device=${BASH_REMATCH[2]}
/srv/bin/k810_conf -d /dev/${device} -f on
The /srv/bin/ folder does indeed contain the program for key reversal (k810_conf). I don't know exactly what the program does but running it with the script like this works:
sudo /srv/scripts/k810.sh
So the problem has to be with udev not detecting the device properly.
The MAC address is the one i get if I do:
hcitool scan
... while the keyboard is in pairing mode. It's also the one I see in Blueman.
Not sure if it's relevant but this is the output of udevadm monitor when the keyboard is turned on:
KERNEL[31976.490290] add
/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.6/1-1.6:1.0/bluetooth/hci0/hci0:12/0005:046D:B319.001C
(hid) KERNEL[31976.491464] add
/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.6/1-1.6:1.0/bluetooth/hci0/hci0:12/input39
(input) KERNEL[31976.491689] add
/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.6/1-1.6:1.0/bluetooth/hci0/hci0:12/input39/event12
(input) KERNEL[31976.491885] add
/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.6/1-1.6:1.0/bluetooth/hci0/hci0:12/0005:046D:B319.001C/hidraw/hidraw0
(hidraw) UDEV [31976.496400] add
/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.6/1-1.6:1.0/bluetooth/hci0/hci0:12/0005:046D:B319.001C
(hid) UDEV [31976.497196] add
/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.6/1-1.6:1.0/bluetooth/hci0/hci0:12/input39
(input) UDEV [31976.499496] add
/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.6/1-1.6:1.0/bluetooth/hci0/hci0:12/0005:046D:B319.001C/hidraw/hidraw0
(hidraw) UDEV [31976.500679] add
/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.6/1-1.6:1.0/bluetooth/hci0/hci0:12/input39/event12
(input)
Any ideas on why the above udev rule isn't working - and how I can make a working one?
|
At least in my case, the problem was that the address needs to be in lower case! So, in your case, change ATTRS{address}=="00:1F:20:76:41:30" to the following:
ATTRS{address}=="00:1f:20:76:41:30"
In case that doesn't do it, I'd double check the permissions.
Also, udev should set a DEVNAME variable (among others) which you can use, so you don't really need the grep the logs (another possible candidate for a permission issue). To troubleshoot further, you could just create a log file every time the script is run (from the script) - that way, you will know if the script was run at all - i.e. if the udev rule triggered at all, or if the error is somewhere later on.
So, the authors script solution (on the page you have already linked) is better IMO. I've adapted it as such:
Permissions:
# ls -l /etc/udev/rules.d/50-k810.rules /opt/bin/k810*
-rw-r--r-- 1 root root 106 2014-07-16 19:21 /etc/udev/rules.d/50-k810.rules
-rwxr-xr-x 1 root root 304 2014-07-16 19:39 /opt/bin/k810.sh
-rwxr-xr-x 1 root root 13102 2014-06-07 22:05 /opt/bin/k810_conf
50-k810.rules:
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{address}=="my:k8:10:ad:re:ss" \
RUN+="/opt/bin/k810.sh %p"
k810.sh:
#!/bin/sh
LOGFILE=/tmp/logfilek810sh.log
echo "RUN: at `date` by `whoami` act $ACTION \$1 $1 DEVPATH $DEVPATH DEVNAME $DEVNAME" >> ${LOGFILE}
echo "Setting F-keys on for your K810!"
if [ "$ACTION" == "add" ];
then
# configure k810 ($DEVPATH) at $DEVNAME.
/opt/bin/k810_conf -d $DEVNAME -f on
fi
Also, one little thing: You can use udevadm info -a -n /dev/hidraw1 to get the right address instead of hcitool (replace with the right hidraw). It should match, but just to double check (that's how I figured udev is seeing a lower case address).
| Making udev rule for bluetooth keyboard |
1,512,261,539,000 |
I am trying to achieve something similar to this:
https://superuser.com/questions/67659/linux-share-keyboard-over-network
The difference is that I need the remote keyboard to be usable separate from my local keyboard. The method described in the link seems to pipe the events into an existing device file. I need the remote keyboard to show as a physical (slave) device when I run xinput list
Why do I need this? I am trying to play a two player game but I don't have an external USB keyboard, so I want to pipe the keypresses from the remote computer to a fake device (so I can assign one device per player).
|
I found a project called netevent on GitHub which does exactly what I need. It makes local devices available to a remote computer.
I was able to forward the mouse, but not the keyboard due to compatibility issues.
Technically, this answers my question of how to share the keyboard over the network and have it appear as a separate device.
| Share keyboard over network as separate device? |
1,512,261,539,000 |
In general, I want to make specific keymaps for application, that working only in it and doesn't affect any other app.
For example, I already use my Caps key to toggle input language (via xorg.conf), but I want Capslock to behave like Esc in vim.
Looks like xmodmap doesn't have any options related to that.
I use Gnome and would also appreciate any third-party applications.
|
I found solution in evrouter. It maps any keyboard event onto keypress in X.Org if active window title is matched by regexp you specify. It also helps me to deal with Zoom key on my Microsoft Natural Keyboard.
The bad thing is default X keypress also occurs.
| Application-specific keymapping |
1,519,672,792,000 |
I use my USB keyboard in home and now I want disable the laptop keyboard on plug of this keyboard.
How could I achieve this?
I use ArchLinux and DWM.
ps:
i found my device and in udev disable it
xinput disable 'AT Translated Set 2 keyboard'
|
Write a udev script that floats the built-in keyboard using xinput.
| How to disable laptop keyboard on plugging in a USB keyboard? |
1,519,672,792,000 |
How can I quickly change my keyboard layout between US and German?
setxkbmap does not apply here, as I only have an SSH shell.
Persistent changes via
dpkg-reconfigure keyboard-configuration
dpkg-reconfigure console-data
are unwanted as well.
I suppose the solution is very simple, but I did not find it.
|
Try:
# loadkeys us
From a terminal, it does not make sense to run this over ssh as the keyboard you use over ssh is the local one and the ssh client sends the keys after they have already been interpreted according to your local keymap. And it won't even work if you try.
You can find all the available console keymaps in /usr/share/kbd/keymaps.
| How do I temporary change my keyboard layout on Debian? (no X) |
1,519,672,792,000 |
How can I log a keyboard hit via shell script?
My aim is to log the number of keyboard hits of a login session on my Ubuntu system.
Note: I do not want to log the keystrokes itself, only the number of hits. So in the end it says:
94853 hits today.
|
Monitoring in X11 (Graphical Desktop) Session Only
In you're using the XInput layer (you probably are, if you're running a modern X) then xinput test «keyboard-id» (from the xinput package on Debian) will give pey press and release events. You can get the keyboard ID by running xinput list. You can also use the name.
xinput test 'AT Translated Set 2 keyboard' | grep -c 'key press'
Note that when you pipe xinput, it has a fairly large buffer. So you may lose some keystrokes, unfortunately. You could use the XI2 API directly to avoid that, but that's not easy from shell.
You can fairly easily start your script as one of the login scripts in your desktop environment or from your .xsession file, depending. The xinput should exit when you log out, because it'll lose its X11 connection. So it's really easy to track when your session starts and ends.
Monitoring System-wide (All Sessions, Even Text Mode)
Alternatively, if you want to monitor all keystrokes on the system, not just those in your X11 session, you can use the input-events (part of the input-utils package on Debian, at least). This must run as root. Use lsinput to find the right input device (happens to be 0 on my system) and then:
input-events 0 | grep -c 'EV_KEY.*pressed'
If you go this way, you'll have to figure out when your sessions start and end some way (e.g., peterph's dbus suggestion).
| Log number of keyboard hits |
1,519,672,792,000 |
When I run a GUI program from a terminal and type Ctrl+C,
I get echo from the terminal:
^C
Despite signal being delivered to the application (and presumably the key handled by the terminal). Why is the character echoed?
|
The character is echoed back because you have the ECHO flag on in the terminal settings, and is echoed in the ^C form because you also have the ECHOCTL flag on. Both flags are on by default on most systems. You can turn them on and off by using their lowercase form with the stty(1) utility:
stty -echoctl # turn echoctl off
stty echoctl # turn echoctl on
You can refer to the termios(3) manpage on Linux for a description [1]:
ECHOCTL (not in POSIX)
If ECHO is also set, terminal special characters other than TAB, NL, START, and STOP are echoed as ^X, where X is
the character with ASCII code 0x40 greater than the special
character. For example, character 0x08 (BS) is echoed as ^H. [requires _BSD_SOURCE or _SVID_SOURCE]
Notice that turning just the ECHOCTL flag off will not prevent control characters from being echoed back, but will cause them to be echoed back in their raw form, rather than in the ^X caret form. The fact that a character is special and will generate a signal (eg. ^C -> VINTR -> SIGINT) does not affect in any way whether it will be echoed back or not.
Most terminal emulators will not display the control characters in any way (unfortunately), but they may interpret them in funny ways: for an illustrative example, start a command like
sleep 3600 or cat > /dev/null, then on the next line press the <Escape>[41m foo<Enter> keys. With echoctl on, you'll have ^[[41m foo printed on your screen, and nothing special will happen. But with echoctl off, the terminal will interpret the echoed back <Raw_esc>[41m as an ANSI color escape (without displaying any of the [41m, etc) and will turn the background red.
Depending on the terminal emulator and its settings, an emacs user pressing ^N by reflex may end up switching to the alternate character set, and turn all the letters into line-drawing squiggles.
You usually don't want these to happen, thence ECHOCTL can be considered a reasonable default.
[1] That description is not very accurate:
It's not the "terminal special characters" which are echoed in that caret form, but the control characters (ASCII 0x0 - 0x1f and 0x7f), no matter if they're special or not. If you define Q as the VINTR "terminal special character" (replacing the default ^C, eg. with stty intr Q), it will still be echoed back as simply Q, not as ^Q or chr(0x91).
On Linux, VEOF will not be echoed back (as ^D or in any other form) when the ICANON flag is also set. But it will be echoed back in that case too on *BSD and MacOS.
ASCII 0x7f (DEL) will not be displayed as char + 0x40 (as described), but as char ^ 0x40 (^?). Just like all the others, btw ;-)
| Why do terminals sometimes echo special characters like ^C? |
1,519,672,792,000 |
How can I get the KDE (Plasma 5.8.6 on Debian Stretch) System Settings for keyboard repeat & delay to actually do something?
These settings:
Whenever I change and apply the settings I don't see any effect on the X11 repeat/delay state (as seen via xset q | grep "auto repeat delay").
|
In the Startup and Shutdown → Background Services configuration applet,
make sure the Keyboard Daemon service ("Enables switching keyboard layout through shortcuts or system tray") is checked and in the "Running" state:
If this does not seem to have an effect, log out and back in. The settings should be applied afterwards.
For whatever reason this service is also responsible for propagating rate/delay changes to X11, which you can see live via:
watch -n1 'xset q | grep "auto repeat delay"'
Source: bcooksley's post at KDE Community Forums.
| KDE keyboard repeat delay/rate settings don't work/have no effect? |
1,519,672,792,000 |
I've already checked the option section in /usr/share/X11/xkb/rules/base.lst but I didn't find an entry for AltGr...
|
Thanks to the suggestions of the Xorg community I found out the correct setxkbmap command:
setxkbmap -option ctrl:ralt_rctrl
| Is there a way to remap the AltGr key to Ctrl with setxkbmap? |
1,519,672,792,000 |
I am setting up Arcade Puppy http://scottjarvis.com/page105.htm on an old Dell GX50 PC.
Instead of using a PS2 style keyboard which I don't have I opted for a low profile generic USB keyboard.
The problem is that once installed to the hard disk the GRUB boot menu does not recognize the USB Keyboard so I cannot choose the boot option to start Linux, also there isn't the normal default timeout setup.
The USB keyboard works the BIOS settings fine and worked okay when booting off the live CD to install Linux.
Has anyone got any suggestions or will I be forced to find a PS2 keyboard?
|
I had the same problem with my wireless keyboard (and running Puppy too, even if it's not related...) you have to enable in your BIOS USB Device Legacy Support.
Find it in some submenu, for example Integrated Peripherals.
| USB Keyboard does not work with Grub |
1,519,672,792,000 |
I have an annoying problem using the terminal and I cannot look for a solution on Google because I don't know how to phrase it.
When I have load of text on terminal (for instance after a dmesg) and I try to scroll up to look for the bit of text I am interested in, after a random amount of time the terminal automatically scrolls down where the cursor is.
Also, I noticed that when xscreensaver is running, the login gui comes out without any input from keyboard. And do you know in xscreensaver there
is an "elapsing time" bar that gives you more time (the bar increase) when you start type in? Well, it increase once without any input from me...
I thought I have some random input from the keyboard, but how to solve this annoying problem?
I have been trying to track down the event generated with xev but it is quite difficult.
On the terminal I have temporarily solved it by un-ticking "scroll on keyboard press", but it is not a reasonable permanent solution.
The whole system, as xscreensaver confirms, is affected.
It is a laptop Acer Aspire e1-571g.
I recently installed Funtoo. I am still finishing to configure ad-hoc every single piece of my hardware.
Before installing Funtoo I had Arch Linux and everything was working fine, so I assume no issue with the hardware, but just a problem with the current configuration.
cpu:
Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz, 1383 MHz
Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz, 1400 MHz
Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz, 1350 MHz
Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz, 1472 MHz
keyboard:
/dev/input/event4 AT Translated Set 2 keyboard
mouse:
/dev/input/mice SynPS/2 Synaptics TouchPad
graphics card:
Intel 3rd Gen Core processor Graphics Controller
nVidia VGA compatible controller
sound:
Intel 7 Series/C210 Series Chipset Family High Definition Audio Controller
storage:
Intel 7 Series Chipset Family 6-port SATA Controller [AHCI mode]
network:
eth0 Broadcom NetLink BCM57785 Gigabit Ethernet PCIe
wlan0 Intel Centrino Wireless-N 105 BGN
network interface:
wlan0 WLAN network interface
lo Loopback network interface
eth0 Ethernet network interface
sit0 Network Interface
disk:
/dev/sda KINGSTON SH103S3
partition:
/dev/sda1 Partition
/dev/sda2 Partition
/dev/sda3 Partition
/dev/sda4 Partition
cdrom:
/dev/sr0 HL-DT-ST DVDRAM GT51N
usb controller:
Intel 7 Series/C210 Series Chipset Family USB xHCI Host Controller
Intel 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #2
Intel 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #1
bios:
BIOS
bridge:
Intel 3rd Gen Core processor DRAM Controller
Intel Xeon E3-1200 v2/3rd Gen Core processor PCI Express Root Port
Intel 7 Series/C210 Series Chipset Family PCI Express Root Port 1
Intel 7 Series/C210 Series Chipset Family PCI Express Root Port 2
Intel HM77 Express Chipset LPC Controller
hub:
Linux 4.3.0-gentoo ehci_hcd EHCI Host Controller
Hub
Linux 4.3.0-gentoo ehci_hcd EHCI Host Controller
Hub
Linux 4.3.0-gentoo xhci-hcd xHCI Host Controller
Linux 4.3.0-gentoo xhci-hcd xHCI Host Controller
memory:
Main Memory
unknown:
FPU
DMA controller
PIC
Keyboard controller
PS/2 Controller
Intel 7 Series/C210 Series Chipset Family MEI Controller #1
Intel 7 Series/C210 Series Chipset Family SMBus Controller
Broadcom NetXtreme BCM57765 Memory Card Reader
Broadcom System peripheral
Broadcom System peripheral
Chicony Electronics HD WebCam
Any idea/solution?
UPDATE: thanks to Stéphane I found out the device the generates spurious events is id=5.
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
...and to confirm I also did:
xinput test-xi2 --root 5
and the output is :
EVENT type 13 (RawKeyPress)
device: 5 (5)
detail: 255
valuators:
EVENT type 14 (RawKeyRelease)
device: 5 (5)
detail: 255
valuators:
...still don't know how to solve. I've tried also to disable it but I got an error.
|
That's not a problem with a real keyboard but with fake key events sent by xfce4-power-manager.
xfce4-power-manager is faking dummy (keycode 255, unassigned) keyboard events (keypress followed by keyrelease, every 20 seconds according to the source) to make sure the screen saver doesn't kick in when in presentation mode (typically, when you're watching a film or giving a presentation).
That behaviour was added in 1.5.2 (latest release as of 2015-01-06) to fix this bug to disable all possible types of screen savers when in presentation mode.
That has that side effect you're affected by, and which was already noted at that bug.
So, you'd want to leave that presentation mode to avoid the problem. That issue should probably be raised as a bug against xfce4-power-manager so that change be reverted, or a better fix to #11083 be found.
As interesting as the explanation to the problem is how we ended up finding the culprit:
xinput test-xi2 --root
Reports all X input events, telling us their source and nature. Which led to:
EVENT type 13 (RawKeyPress)
device: 5 (5)
detail: 255
valuators:
EVENT type 14 (RawKeyRelease)
device: 5 (5)
detail: 255
valuators:
That is a key press followed by a key release event for keycode 255 coming from device 5.
xinput list lets us identify the input device:
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
That id=5 device is a virtual device that acts as source for software generated events like you can generate with:
xdotool key x
or
xte 'key x'
If you run that xte command under ltrace, you'll notice it does:
XStringToKeysym(0x7ffed76983e0, 0x7ffed76983e0, 0, 0x7f34e491deb0) = 120
XKeysymToKeycode(0x23abfe0, 120, 120, 0x7f34e4ce7139) = 53
XTestFakeKeyEvent(0x23abfe0, 53, 1, 0) = 1
That XTestFakeKeyEvent is the standard X API to send those keypress events.
Now, we want to know what is sending those 255 keypress events. We can try and find which of the currently running applications use that API.
sudo lsof -Fn -nPd txt | sed -n '/proc/!s/^n//p' | sort -u | xargs grep -l XTestFakeKeyEvent
Or its more robust equivalent:
sudo lsof -Fn -nPd txt | sed -n '/^n\/proc/!s/^n//p' |
sort -u | xargs -d '\n' grep -l XTestFakeKeyEvent
Lists the files that are currently open and mmapped as executable (txt) to any process (that includes libraries and executables) and grep for XTestFakeKeyEvent in them.
That returned xfce4-power-manager.
All was left to do is look in the source for why that process does those XTestFakeKeyEvent.
| My keyboard generates spurious events |
1,519,672,792,000 |
I have a Sun type 7 UNIX keyboard that I'd like to get more productivity out of. So what are those extra keys for, or rather, what were they intended for by Sun? And is there a way to approximate those functions in any useful way on a modern Linux or Solaris 11 system?
The keys in question are:
Label Keycode keysym
===========================
Compose 135 Menu
Stop 136 Cancel
Again 137 Redo
Props 138 SunProps
Undo 139 Undo
Front 140 SunFront
Copy 141 XF86Copy
Open 142 SunOpen
Paste 143 XF86Paste
Find 144 Find
Cut 145 XF86Cut
|
Undo, Again, Copy, Open, Paste, Find and Cut are easy, those keys did pretty much exactly what their inscriptions say. On today's PC keyboards, those functions are the CTRL-XCV family.
Compose is, however, a special meta key for creating accented characters like umlauts (ä,ö,ü) or the German ß. You press Compose, the desired modifier and the desired base character in sequence. This behaviour is still supported by X, and can be mapped to any key.
Stop was a CTRL-Break, IIRC.
| What are/were the keys on a Sun keyboard for? |
1,519,672,792,000 |
We have a shell/tty based application that has ~1,000 users. It is running in an environment where X Server is not available. If a user accidently turns on the Scroll Lock, it makes it seem as if the application is frozen because it quits responding to keyboard input. Is there a way to disable the Scroll Lock or remap it to something less intrusive for this use-case?
|
For a GUI env:
Type xev on the CLI, then click on the Scroll Lock key to see what its keycode is.
Then use xmodmap -e 'keycode <value>=<action>'
Where the value is the keycode number you get from the xev command.
If you want to desable the Scroll Lock, you should leave the <action> as blank.
or you can map the <action> to another keycode.
For example, on my Asus EEE 1005P, the Scroll Lock key is map to keycode 78 so i would issue xmodmap -e 'keycode 78=' to disable it.
For a non GUI env:
setkeycodes scancode keycode you get the scancode with the showkey command. And then you need to use loadkeys.
And here you can find a guide.
I don't have any experience with a non GUI env, hence i gave you the links and a general way on how to do it.
| Disable scroll lock |
1,519,672,792,000 |
I am using a US keyboard layout because it's more convenient for programming, but since I am German I need the German umlauts for texting. (Umlauts like ÄäÖöÜü)
I am running Manjaro with KDE.
I want to get press
AltGr + u -> ü
and
AltGr + Shift + u -> Ü
I tried copying the US keymap from /usr/share/kbd/keymap and adding
alt keycode 32 = odiaeresis
to get the ü to work, but it didn't do anything.
I queried the keycode 32 by entering
xmodmap -pk | grep -i o
which returned:
32 0x006f (o) 0x004f (O) 0x006f (o) 0x004f (O)
|
setxkbmap 'de(us)'
This is a good in-between solution. It is actually the US-layout with only a few modifications. File is symbols/de:
xkb_symbols "us" {
include "us"
name[Group1]="German (US, with German letters)";
key <AC01> { [ a, A, adiaeresis, Adiaeresis ] };
key <AC02> { [ s, S, ssharp, U1E9E ] };
key <AC10> { [ semicolon, colon, odiaeresis, Odiaeresis ] };
key <AC11> { [ apostrophe, quotedbl, adiaeresis, Adiaeresis ] };
key <AD03> { [ e, E, EuroSign, EuroSign ] };
key <AD07> { [ u, U, udiaeresis, Udiaeresis ] };
key <AD09> { [ o, O, odiaeresis, Odiaeresis ] };
key <AD11> { [ bracketleft, braceleft, udiaeresis, Udiaeresis ] };
key <AE03> { [ 3, numbersign, section, section ] };
key <AE11> { [ minus, underscore, ssharp, question ] };
include "level3(ralt_switch)"
};
The ralt_ should be the AltGr key. The umlaute are on the letters and on the "german" place (right side).
With include "us" this is more us(de) than de(us).
€ ßẞ ÄÖÜ § äöü
| German Umlauts on US keyboard |
1,519,672,792,000 |
I recently noticed some weird behavior on my GNU/Linux machine. I've been trying to narrow it down but I am unsure where to go next. My setup uses the following:
i3
gdm
arch
systemd
grub2
pulseaudio
4.13.3-1-ARCH
Here is how it manifests iself:
when trying to resize panes in i3 (alt+right click and hold) the action will be randomly canceled (happens on key presses)
alt+dragging windows meets a similar fate
booting to tty periodically adds ^@s to the login prompt, I'd estimate them to be ~0.5s intervals
in tty I can see those being passed to vim when I open the command bar (:)
using a pager like less in tty mode and searching with / will result in (?) being spammed
htop's search (/) is instantly canceled by the periodic keypress
holding a key and trying to have it be repeated (such as holding space) will stop the other occurrences from happening (e.g. only one or two happen)
any tooltip (such as chrome tooltips) get instantly closed because of key presses
Here is what I have tried:
tried switching DE temporarily (gnome, cinnamon, xfce)
tried killing programs one by one until I was left with a tty session and essentially systemd services + pulseaudio
tried booting on an arch livecd - problem does not manifest
overriding grub2 with init=/bin/bash drops me into a shell where the problem does not manifest
I have tried pressing all keys to verify it wasn't a hardware problem, however previous steps point to it not being hardware
I have made a diff of dmesg, from the init=/bin/bash and the regular boot - the main difference seems to be systemd being started in the regular boot
Made a diff of lsmod from init=/bin/bash and regular boot, tried to rmmod modules that seemed related
My system is up to date, I'm not quite sure what other steps I can do to track this down. Any other debugging tips?
|
In 4.13, +CONFIG_PEAQ_WMI=m was added to the vanilla kernel, a dependency of CONFIG_INPUT_POLLDEV. This has resulted in regressions for various types of systems, including the console spamming you experienced. It appears to have been introduced with this commit.
Blacklisting input_polldev is the current workaround.
| ^@ spam in tty (but seems to be system-wide) |
1,519,672,792,000 |
Having just upgraded to Linux Mint 18.1 KDE (Plasma 5.8.5, Qt 5.6.1) all is working excellent apart from strange problem I never come across before. Something is grabbing my "Ctrl+s" sequence on what seems at the X-window level since it never reaches the application level. So for example neither "Ctrl+s" nor "Ctrl+x Ctrl+s" standard emacs keys work. Even in more typical KDE program the "Ctrl+s" sequence is dead. I guess this could be KDE framework as well but there is no global hotkey defuned as Ctrl+s (I've moved the global Ctrl+s to Ctrl+Shift+s)
And here is the ringer; Its is only the "Ctrl+s" seqeunce that is dead. All other, to me known, Ctrl keys works as expected.
Some clue to what is going on is gotten from running xev. Typing Ctrl+s generates the following sequence
KeyPress event, serial 40, synthetic NO, window 0x3400001,
root 0x4c4, subw 0x0, time 14783934, (-711,685), root:(1159,750),
state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
FocusOut event, serial 40, synthetic NO, window 0x3400001,
mode NotifyGrab, detail NotifyAncestor
FocusIn event, serial 40, synthetic NO, window 0x3400001,
mode NotifyUngrab, detail NotifyAncestor
KeymapNotify event, serial 40, synthetic NO, window 0x0,
keys: 2 0 0 0 4294967200 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
KeyRelease event, serial 40, synthetic NO, window 0x3400001,
root 0x4c4, subw 0x0, time 14784998, (-711,685), root:(1159,750),
state 0x4, keycode 39 (keysym 0x73, s), same_screen YES,
XLookupString gives 1 bytes: (13) ""
XFilterEvent returns: False
KeyRelease event, serial 40, synthetic NO, window 0x3400001,
root 0x4c4, subw 0x0, time 14785566, (-711,685), root:(1159,750),
state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
This is quite different from, say, pressing, say Ctrl+y. The Ctrl+s sequence generates both a "FocusOut" and "FocusIn" which is the core problem. This indicates that some process is grabbing the sequence, possible the KDE window manager. However, I cannot for my life identify what process is grabbing the key.
My theory is confirmed by running showkey -a in a terminal. It clearly confirms that the application elevel never receives the Ctrl+s. All other Ctrl+ gives a keycode, for example
^Y 25 0031 0x19
^R 18 0022 0x12
^T 20 0024 0x14
^T 20 0024 0x14
However, trying to type Ctrl+s and nothing happens.
Furthermore I have double (and triple) checked that there are no global hotkeys in KDE mapped to Ctrl+s nor does the Ctrl+s actually do anything. It seems to be sent directly to /dev/null ...
I've also tried
xdotool keydown Ctrl+s;xdotool key XF86LogGrabInfo; xdotool keyup Ctrl+s;
to see if I can find what process is grabbing the Ctrl+s key. From the logs I cannot however, identify any such process.
I'm starting to run out of ideas and was hoping someone have an idea on where to look next?
|
Analyzing the Xorg.0.log in more details showed that Ctrl+s was consumed by the kglobalaccel5 process which is the Wayland/KDE global hot key manager.
However, since I knew there were no Ctrl+s key defined as a global hotkey the only solution was that this was a keymap collision (or rather a key chord collision).
It turned out (after some trial and error testing) that the resulting key events for Ctrl+§ on my keyboard was the same as for Ctrl+s (I used to map Ctrl+§ to open the "Dashboard Widget" )
Most likely because I use a Generic keyboard mapping and not specific for my "rapoo"-quick typing keyboard. I don't have the detailed knowledge of how the interaction of keys + modifier can result in this collision. The normal keys, i.e. 's' and '§' individually works but apparently using them together with the 'Ctrl' modifier gives the same chord value.
The solution was to remove the global mapping for Ctrl+§
Interesting problem!
| What is grabbing my Ctrl+s key? |
1,519,672,792,000 |
I'm on Solaris 10 and by default vi version SVR4.0, Solaris 2.5.0 is installed.
The system was set up so that when I ssh to it Control+H does backspace, and backspace outputs ^?
I added stty erase '^?' into .profile so that in the terminal the backspace key works correctly now. However when I use vi it still is outputting the ^? character.
Normally I would type :set nocompatible to fix this but it gives me
compatible: No such option - 'set all' gives all option values
set all gives me
noautoindent nomodelines noshowmode
autoprint nonumber noslowopen
noautowrite nonovice tabstop=8
nobeautify nooptimize taglength=0
directory=/var/tmp paragraphs=IPLPPPQPP LIpplpipnpptags=tags /usr/lib/tags
noedcompatible prompt tagstack
noerrorbells noreadonly term=xterm
noexrc redraw noterse
flash remap timeout
hardtabs=8 report=5 ttytype=xterm
noignorecase scroll=33 warn
nolisp sections=NHSHH HUuhsh+c window=66
nolist shell=/bin/ksh wrapscan
magic shiftwidth=8 wrapmargin=0
mesg noshowmatch nowriteany
I'm guessing that this version of vi is too old and that I need either a newer version or vim if I want to use set nocompatible, but I'm wondering is there another way to get vi to use backspace for backspacing without having to load vim?
|
ok. so we solved the backspace key not working.
by adding
:map! ^? ^H
to your .exrc file. to map the arrow keys in a similar manner, you can add the following to the same .exrc file.
:map! ^[OA ^[ka
:map! ^[OB ^[ja
:map! ^[OC ^[la
:map! ^[OD ^[ha
Keep in mind that all of these 'escape codes' are created not by simply typing shift+6 for the '^' character, but by pressing the following keys:
backspace & delete:
^? = control + v+delete
^H = control + v+control + h
up arrow:
^[OA = control + v+up arrow
^[ka = control + v+esc+k+a
down arrow:
^[OB = control + v+down arrow
^[ja = control + v+esc+j+a
right arrow:
^[OC = control + v+right arrow
^[la = control + v+esc+l+a
left arrow:
^[OD = control + v+left arrow
^[ha = control + v+esc+h+a
Any comment lines in your .exrc file must be marked by ", rather than #.
And you can't leave any blank lines in your .exrc file, otherwise that first blank line is where your .exrc will stop being processed.
Once these are in place, vi will start to feel a bit more like it was designed for use by humans. :)
for an example of how powerful the .exrc file is, check out this .exrc example by Dave Capella.
| Switch VI to use backspace key instead of Control+H for backspace? |
1,519,672,792,000 |
Up front, I found this answer and it didn't help (read below).
I am using vanilla-gnome-desktop in Ubuntu 18.04 and I have not been able to pass through special keys like Windows (aka Super) to the session connected in Remmina.
I have assigned that key (Super) to a number of global shortcuts in the GNOME shell for convenience (e.g. Super+T for Terminal and Super), though.
However, as I understand it Remmina should be able to do just that by activating a sort of "grab all keys" mode with Control_R (right Ctrl key). And indeed hitting that key toggles the respective icon in that floating bar Remmina provides when inside a connected session. However, it appears to have no effect whatsoever. The following screenshot illustrates the icon/button (and underlying setting) I mean:
For example hitting Alt+F4 simply closes the Remmina window, instead of closing whatever window I have focused inside the session. Hitting Super will open that quick launch thingamy (no idea what the proper term is) and not the start menu inside the session.
The keyboard settings for Remmina look as follows:
So what am I doing wrong here?
My goal is to have Remmina (and thus the connected session) receive the maximum number of special keys, although it's perfectly acceptable to have an "escape" like in virtualization GUIs.
|
There is another Workaround for this. I had the same behavior in xfreerdp. I've found a solution on reddit:
https://www.reddit.com/r/archlinux/comments/elp2lf/cant_grab_input_in_fullscreen_apps_like_vms/
I run the following in my terminal:
settings set org.gnome.mutter.wayland xwayland-grab-access-rules "['xfreerdp']"
Now, the keys works and i can continue using Wayland.
| How to make Remmina grab all "special" keys with GNOME on Ubuntu 18.04? |
1,519,672,792,000 |
I probably misconfigured something, but I don't know what. (see UPDATE 1 and 2 below) In gnome-terminal, when I hit Alt (without any other key), it immediately sends ^[< to the terminal (I tested by hitting Ctrl+V before Alt). Since I use Alt+Tab a lot, this is very unfortunate, because the control sequence will, for example, move to the beginning of history or do strange stuff in vim.
The Alt+Tab, however,
does still work and cycles through the windows as wanted.
What might be the reason and how can I restore the default behavior in gnome-terminal?
OS: Linux Mint 19.3 Tricia x86_64
Kernel: 5.3.0-24-generic
Shell: bash 4.4.20
GNOME Terminal 3.28.1 using VTE 0.52.2 +GNUTLS -PCRE2
UPDATE 1
I found out that this happens only on the laptops keyboard itself, but not using an external attached usb keyboard. While the external keyboard is attached both Alt-keys behave differently.
The laptop is a Lenovo P53.
I still don't know how to fix it for the laptops keyboard but at least I am closer to the origins of the issue.
UPDATE 2
Running xev I shortly hit (pressed and immediately released) Alt a single time; first on the laptops keyboard and then on the external USB keyboard:
# LAPTOP KEYBOARD ALT-KEY
MappingNotify event, serial 39, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 248
KeyPress event, serial 39, synthetic NO, window 0x6a00001,
root 0x2b6, subw 0x0, time 9398319, (162,-8), root:(903,449),
state 0x10, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 39, synthetic NO, window 0x6a00001,
root 0x2b6, subw 0x0, time 9398319, (162,-8), root:(903,449),
state 0x18, keycode 94 (keysym 0x3c, less), same_screen YES,
XLookupString gives 1 bytes: (3c) "<"
XmbLookupString gives 1 bytes: (3c) "<"
XFilterEvent returns: False
KeyRelease event, serial 40, synthetic NO, window 0x6a00001,
root 0x2b6, subw 0x0, time 9398360, (162,-8), root:(903,449),
state 0x18, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 40, synthetic NO, window 0x6a00001,
root 0x2b6, subw 0x0, time 9398360, (162,-8), root:(903,449),
state 0x10, keycode 94 (keysym 0x3c, less), same_screen YES,
XLookupString gives 1 bytes: (3c) "<"
XFilterEvent returns: False
# EXTERNAL USB KEYBOARD ALT-KEY
MappingNotify event, serial 40, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 248
KeyPress event, serial 40, synthetic NO, window 0x6a00001,
root 0x2b6, subw 0x0, time 9402608, (162,-8), root:(903,449),
state 0x10, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 41, synthetic NO, window 0x6a00001,
root 0x2b6, subw 0x0, time 9402704, (162,-8), root:(903,449),
state 0x18, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
UPDATE 3
It's probably a hardware defect (see comments and answer). I will get a new keyboard from the manufacturer.
|
It is a hardware defect and was confirmed by the manufacturer. Replacing the keyboard solved the issue. Thanks for helping to investigate!
| gnome-terminal: strange control characters on Alt key |
1,519,672,792,000 |
I use bash and the up arrow key sometimes to be able to quickly get the previous commands I used. What is irritating is sometimes when I do this I get a [A instead of a previous command. After doing some research online it looks like this is a key code representing the up arrow key being sent to the computer.
I can't seem to find any answers to this online. How can I stop this from happening in the future?
|
Background
The sequence is actually Escape[A, and it's part of a set that was adopted by Ecma in 1976 as standard ECMA-48, being supported by ANSI as a separate but almost identical standard for a number of years (later withdrawn) and also ratified by ISO/IEC 6429 on the way. The upshot of this multiple standardisation is that although they are frequently referenced as ANSI escape codes they should properly be called ECMA-48 control functions*.
Explanation
The usual reason for seeing [A on the screen instead of the action will be that the inital Escape code has been absorbed unexpectedly. I cannot reproduce this on my keyboard unless I first press Ctrl V, which tells the terminal line driver to process the next character as a literal.
So, we can then get this sequence Ctrl VEscape[A, producing the visible output [A.
You'll notice that if you press the sequence of characters Escape[A in quick succession the cursor will indeed go upwards. However, if you pause after the first character you'll fail to get a cursor movement, and this is because the Escape character has a timeout associated with it. On slow serial lines to UNIX systems this used to be a real problem, and the closest equivalent is a slow or intermittent network connection, with a brief lag during this sequence transmission.
Prevention
Now to your question, how to prevent this. There isn't much you can do if you're on an intermittent network connection, except maybe use one of the alternate sequences such as Escapek...k...k that are available during command editing in "vi mode" (set -o vi).
* Much like JavaScript should be called ECMAScript, I suppose
| How do I stop the "[A" showing sometimes when I press the up arrow key? |
1,519,672,792,000 |
I recently bought a Varmilo VA109M mechanical keyboard. It works fine on Windows, but seems to confuse my Ubuntu install in that the F1-F12 function keys appear always to activate media shortcuts, regardless of whether I've held the dedicated Fn modifier key or not. For instance, F12 will increase my system volume if I press it on its own, and will do the same if I press Fn+F12; there is no way to get it to act like a normal F12 key. This is causing me issues because I do a lot of programming, and many IDE shortcuts rely on the standard function keys.
I have tried resetting the keyboard's internal settings by holding Fn+Esc, but this didn't help. My Windows install on the same machine functions perfectly fine with this keyboard. Is there anything I can do to try and diagnose exactly what Ubuntu is getting confused about?
EDIT: lsusb outputs the following:
Bus 001 Device 003: ID 05ac:024f Apple, Inc. Varmilo Keyboard
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x05ac Apple, Inc.
idProduct 0x024f
bcdDevice 1.00
iManufacturer 1
iProduct 2
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x005b
bNumInterfaces 3
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 350mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 1 Boot Interface Subclass
bInterfaceProtocol 1 Keyboard
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.10
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 75
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.10
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 85
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0010 1x 16 bytes
bInterval 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.10
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 33
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0020 1x 32 bytes
bInterval 4
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x04 EP 4 OUT
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0020 1x 32 bytes
bInterval 4
|
This is solvable!
So I did some research into this myself recently and while Jd3eBP is right about the keyboard pretending to be an Apple keyboard, it's actually probably an issue with Varmilo's flashing at the factory.
They sell a Mac version of the keyboard that I think differs only in firmware and labeling, by default I think it supports the Mac layout, it's also supposed to be able to switch to "windows mode" which probably swaps the order of the keys to what you'd expect, it identifies itself as an Apple keyboard to get Macs to treat it properly.
However it seems like maybe they accidentally flashed that firmware onto every keyboard instead of just the Mac only ones, which isn't noticeable on Windows since it ignores the id, but on linux will activate the hid_apple driver.
Solution:
On to the answer part. There's two big options for solving this, I tested both and ended up finding the second much better.
Change hid_apple into a mode where it treats the function keys normally, afaik this will basically solve the issue. You can find instructions here for how to do that, it will work on Ubuntu as well. https://wiki.archlinux.org/index.php/Apple_Keyboard#Function_keys_do_not_work.
Reflash the keyboard with the product and vendor ID such that it will not be detected. This is arguably the right answer but a little more risky. You can get the firmware files from the manufacturer site here, https://en.varmilo.com/keyboardproscenium/Driverdownload, using the VA87M download. The updater itself didn't work (I think I needed Chinese localization installed), so you can use the updater that was supplied to someone here https://www.reddit.com/r/Varmilo/comments/g4sabk/fn_lock_on_va87m/, using the official firmware file from the for good measure. If you don't trust that, I hear that if you email Varmilo about the issue they will provide the required files.
That updater worked under wine for me after installing wine from the official site. This just reflashes the vendor and product ID to not come up as an Apple keyboard, it also removes the "switch to windows/mac mode" functionality that was unused on the Windows only version. You could probably flash the Mac firmware to revert to the old behavior if you want I didn't test that however.
| Keyboard function keys always trigger media shortcuts, regardless of whether Fn is held down |
1,519,672,792,000 |
Let's say we have a generic keyboard with some unknown keys which may send escape sequences to terminal.
The keyboard is connected to an xterm terminal emulator running on a generic BSD/Linux.
To create correct mapping for the unknown keys, we must first know what escape sequences they send to the xterm.
But how to know what escape sequences the keys send?
|
Your keyboard is not connected to xterm. It's connected to your PC. A kernel driver knows how to decode the key press and release sent by the keyboard and make that available to applications via a generic API on special device file.
An X server is such an application that uses that API.
It translates those key presses and releases into X "KeyPress" and "KeyRelease" events which carry with them the information of the key pressed as both a keycode and a keysym. That's another API.
xterm is an X application. It connects to an X server and tells it: I'm interested in all KeyPress and KeyRelease events. When it has the focus and when the KeyPress and KeyRelease events are not hijacked by your Window Manager or other applications that register for some KeyPress events globally, xterm will receive the KeyPress and KeyRelease events.
xterm translates a keysym in a KeyPress event into a sequence of characters it sends to the master side of a pseudo-terminal driver. Applications running in your xterm will eventually read from the slave side of that pseudo-terminal driver the characters sent by xterm, but potentially altered by the pseudo-terminal driver (for instance, under some conditions, 0xd characters are translated to 0xa ones, 0x3 would cause a SIGINT to be sent...).
With those clarifications out of the way. To know which keycode or keysym is sent by the X server upon a given key press, you can use xev.
To know which sequence of characters (if any) is sent by xterm, you need to tell the pseudo-terminal driver not to mingle with them first (stty raw) and then you can use cat -vt or sed -n l or od to see them:
{
stty raw min 1 time 20 -echo
dd count=1 2> /dev/null | od -vAn -tx1
stty sane
}
(above adding a min 1 time 20 and using dd so it exits after one keypress as you wouldn't be able to exit with Ctrl-C otherwise).
| How to find out the escape sequence my keyboards sends to terminal? |
1,519,672,792,000 |
I am using Debian Testing/Stretch with Xfce. I just bought this wired keyboard. I would like the num lock to be turned on by default, but I do not want to have the led indicator light on. This could be accomplished by disabling the num lock indicator altogether, reversing the state (showing the indicator light when the num lock is off), or all of the num-lock-off keys could be remapped to type numbers instead (with this I can type numbers when the indicator is on or off). setleds -L -num works but only in a tty session. Thanks
|
If “num lock turned on by default” means “keys on the numpad by default” and you don’t want/don’t care about navigation on the keypad:
setxkbmap -option numpad:mac <layout>
So for the us layout:
setxkbmap -option numpad:mac us
Now the numpad always enters digits, no matter the num lock state.
Reference: xkeyboard-config man-page
| Disable num lock indicator LED or reverse keypad so when num lock is on, indicator light is off |
1,519,672,792,000 |
On my laptop, turning on autorepeat (xset r on) does not work. When checking the output of xev, it seems that the reason why autorepeat fails is because another key is being pressed intermittently (although I am not pressing anything), which cancels autorepeating the currently held down key. When no keys are being pressed, the following events are recorded repeating consistently:
KeyPress event, serial 33, synthetic NO, window 0x1200001,
root 0x123, subw 0x0, time 1652400, (-509,794), root:(455,814),
state 0x0, keycode 221 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 33, synthetic NO, window 0x1200001,
root 0x123, subw 0x0, time 1652400, (-509,794), root:(455,814),
state 0x0, keycode 221 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
It seems that a key with keycode 221 is being pressed, even when it is not.
Thus, is it possible to completely disable a keycode such that xorg does not recieve the keypress signal from that keycode at all? Or, is it possible to make keys autorepeat when held down, regardless of whether another key is pressed?
Update:
After running sudo evtest, it appears that when the hidden output is coming from
/dev/input/event11 PEAQ WMI hotkeys
No other input device seems to send events when nothing is pressed.
Autorepeat works when checking keyboard events in evtest.
The full output of xev running for a couple seconds when nothing is pressed:
Outer window is 0x1200001, inner window is 0x1200002
PropertyNotify event, serial 8, synthetic NO, window 0x1200001,
atom 0x27 (WM_NAME), time 1651733, state PropertyNewValue
PropertyNotify event, serial 9, synthetic NO, window 0x1200001,
atom 0x22 (WM_COMMAND), time 1651733, state PropertyNewValue
PropertyNotify event, serial 10, synthetic NO, window 0x1200001,
atom 0x28 (WM_NORMAL_HINTS), time 1651733, state PropertyNewValue
CreateNotify event, serial 11, synthetic NO, window 0x1200001,
parent 0x1200001, window 0x1200002, (10,10), width 50, height 50
border_width 4, override NO
PropertyNotify event, serial 14, synthetic NO, window 0x1200001,
atom 0x15c (WM_PROTOCOLS), time 1651734, state PropertyNewValue
MapNotify event, serial 15, synthetic NO, window 0x1200001,
event 0x1200001, window 0x1200002, override NO
ReparentNotify event, serial 28, synthetic NO, window 0x1200001,
event 0x1200001, window 0x1200001, parent 0x4000d5,
(0,0), override NO
ConfigureNotify event, serial 28, synthetic NO, window 0x1200001,
event 0x1200001, window 0x1200001, (2,0), width 952, height 1033,
border_width 2, above 0x0, override NO
PropertyNotify event, serial 28, synthetic NO, window 0x1200001,
atom 0x15e (WM_STATE), time 1651735, state PropertyNewValue
MapNotify event, serial 28, synthetic NO, window 0x1200001,
event 0x1200001, window 0x1200001, override NO
VisibilityNotify event, serial 28, synthetic NO, window 0x1200001,
state VisibilityUnobscured
Expose event, serial 28, synthetic NO, window 0x1200001,
(0,0), width 952, height 10, count 3
Expose event, serial 28, synthetic NO, window 0x1200001,
(0,10), width 10, height 58, count 2
Expose event, serial 28, synthetic NO, window 0x1200001,
(68,10), width 884, height 58, count 1
Expose event, serial 28, synthetic NO, window 0x1200001,
(0,68), width 952, height 965, count 0
ConfigureNotify event, serial 28, synthetic YES, window 0x1200001,
event 0x1200001, window 0x1200001, (962,18), width 952, height 1033,
border_width 2, above 0x0, override NO
FocusIn event, serial 28, synthetic NO, window 0x1200001,
mode NotifyNormal, detail NotifyNonlinear
KeymapNotify event, serial 28, synthetic NO, window 0x0,
keys: 4294967236 0 0 0 16 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
PropertyNotify event, serial 28, synthetic NO, window 0x1200001,
atom 0x14f (_NET_WM_DESKTOP), time 1651736, state PropertyNewValue
KeyRelease event, serial 30, synthetic NO, window 0x1200001,
root 0x123, subw 0x0, time 1651775, (-509,794), root:(455,814),
state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
XLookupString gives 1 bytes: (0d) "
"
XFilterEvent returns: False
MappingNotify event, serial 33, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 248
KeyPress event, serial 33, synthetic NO, window 0x1200001,
root 0x123, subw 0x0, time 1652400, (-509,794), root:(455,814),
state 0x0, keycode 221 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 33, synthetic NO, window 0x1200001,
root 0x123, subw 0x0, time 1652400, (-509,794), root:(455,814),
state 0x0, keycode 221 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 34, synthetic NO, window 0x1200001,
root 0x123, subw 0x0, time 1653200, (-509,794), root:(455,814),
state 0x0, keycode 221 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 34, synthetic NO, window 0x1200001,
root 0x123, subw 0x0, time 1653200, (-509,794), root:(455,814),
state 0x0, keycode 221 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 34, synthetic NO, window 0x1200001,
root 0x123, subw 0x0, time 1654000, (-509,794), root:(455,814),
state 0x0, keycode 221 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 34, synthetic NO, window 0x1200001,
root 0x123, subw 0x0, time 1654000, (-509,794), root:(455,814),
state 0x0, keycode 221 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
MappingNotify event, serial 34, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 248
KeyPress event, serial 34, synthetic NO, window 0x1200001,
root 0x123, subw 0x0, time 1654760, (-509,794), root:(455,814),
state 0x0, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
MappingNotify event, serial 35, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 248
KeyPress event, serial 35, synthetic NO, window 0x1200001,
root 0x123, subw 0x0, time 1654800, (-509,794), root:(455,814),
state 0x40, keycode 221 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 35, synthetic NO, window 0x1200001,
root 0x123, subw 0x0, time 1654800, (-509,794), root:(455,814),
state 0x40, keycode 221 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
MappingNotify event, serial 36, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 248
FocusOut event, serial 36, synthetic NO, window 0x1200001,
mode NotifyGrab, detail NotifyAncestor
ClientMessage event, serial 37, synthetic YES, window 0x1200001,
message_type 0x15c (WM_PROTOCOLS), format 32, message 0x15d (WM_DELETE_WINDOW)
|
It seems this is a bug introduced with kernel 4.13, as per Redhat bugzilla bug #1497861.
I found out that unloading the peaq_wmi module also serves as a workaround; it seems that someone already submitted a patch to fix the issue though.
(To unload the peaq_wmi module one can issue the command sudo modprobe -r peaq_wmi.)
| Autorepeat does not work |
1,519,672,792,000 |
I recently purchased a Corsair k65 RGB keyboard. Of course it didn't work at first, but with an ckb-opensource driver I got everything working on my arch system.
Everything went so well until I started to get errors whenever I boot my system:
usb_submit_urb(ctrl) failed: -1
appears on my screen and the system freezes for 30sec. After that the keyboard works and I can login on my system.
But what does the error mean?
[ 11.238682] hid-generic 0003:1B1C:1B17.0002: usb_submit_urb(ctrl) failed: -1
[ 11.239526] hid-generic 0003:1B1C:1B17.0002: timeout initializing reports
[ 11.239959] input: Corsair Corsair K65 RGB Gaming Keyboard as /devices/pci0000:00/0000:00:1c.7/0000:07:00.0/usb5/5-1/5-1:1.1/0003:1B1C:1B17.0002/input/input6
[ 11.291882] hid-generic 0003:1B1C:1B17.0002: input,hidraw4: USB HID v1.11 Keyboard [Corsair Corsair K65 RGB Gaming Keyboard] on usb-0000:07:00.0-1/input1
[ 21.291319] hid-generic 0003:1B1C:1B17.0003: timeout initializing reports
[ 21.291585] hid-generic 0003:1B1C:1B17.0003: hiddev0,hidraw5: USB HID v1.11 Device [Corsair Corsair K65 RGB Gaming Keyboard] on usb-0000:07:00.0-1/input2
[ 31.290650] hid-generic 0003:1B1C:1B17.0004: timeout initializing reports
[ 31.290905] hid-generic 0003:1B1C:1B17.0004: hiddev0,hidraw6: USB HID v1.11 Device [Corsair Corsair K65 RGB Gaming Keyboard] on usb-0000:07:00.0-1/input3
If I use lsusb I get:
Bus 005 Device 002: ID 1b1c:1b17 Corsair
I have heard about "usbhid quirks" is a possible workaround. But how do I use this ? Or is there any possible solution for this ?
|
Solution for all Corsair mechanical keyboards with usbhid quirks.
sudo nano /etc/default/grub
or any other editor you like to use instead of nano.
you will see this line
GRUB_CMDLINE_LINUX_DEFAULT=""
make sure to put the usbhid.quircks between the quotes and save that.
In my case I had to change it to this line
GRUB_CMDLINE_LINUX_DEFAULT="usbhid.quirks=0x1B1C:0x1B17:0x20000408"
after that, update grub
sudo update-grub
*If that command is not found, you probably run grub 2.0. Use this command instead. update-grub command is just a script which runs the grub-mkconfig
sudo grub-mkconfig -o /boot/grub/grub.cfg
after that is done, reboot the system.Now it should work normal and the message won't appear.
Use the quirks for your keyboards. You can use this list below for Corsair keyboards.
K65 RGB: usbhid.quirks=0x1B1C:0x1B17:0x20000408
K70: usbhid.quirks=0x1B1C:0x1B09:0x0x20000408
K70 RGB: usbhid.quirks=0x1B1C:0x1B13:0x20000408
K95: usbhid.quirks=0x1B1C:0x1B08:0x20000408
K95 RGB: usbhid.quirks=0x1B1C:0x1B11:0x20000408
Strafe: usbhid.quirks=0x1B1C:0x1B15:0x20000408
Strafe RGB: usbhid.quirks=0x1B1C:0x1B20:0x20000408
M65 RGB: usbhid.quirks=0x1B1C:0x1B12:0x20000408
Sabre RGB Optical: usbhid.quirks=0x1B1C:0x1B14:0x20000408
Sabre RGB Laser: usbhid.quirks=0x1B1C:0x1B19:0x20000408
Scimitar RGB: usbhid.quirks=0x1B1C:0x1B1E:0x20000408
Update
Linux kernel 4.11: HID fixes are support for some more Corsair mice and keyboards. K65RGB and K70RGB have their HID quirk fixes in Linux 4.11 for these devices.
See commit: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=deaba636997557fce46ca7bcb509bff5ea1b0558
You can find out your kernel version to use this command in the terminal
uname -r
to sum up, if you have Linux kernel 4.11 there's a chance you don't need to go through this process for adding usbhid quirks.
| usb_submit_urb(ctrl) failed: -1 Corsair k65 RGB keyboard |
1,519,672,792,000 |
I need to work on a Solaris server over ssh from my Ubuntu (Lucid) laptop. I got Home/End Insert/Delete Page Up/Down working in csh and bash using bindkey and ~/.inputrc, respectively. But I can't figure out how to get them working in less. How can I figure out what the problem is, and fix it?
|
I found the answer here, in section 4.4. less (1).
to use it with the movement keys, have this plain ASCII file .lesskey in your home directory:
^[[A back-line
^[[B forw-line
^[[C right-scroll
^[[D left-scroll
^[OA back-line
^[OB forw-line
^[OC right-scroll
^[OD left-scroll
^[[6~ forw-scroll
^[[5~ back-scroll
^[[1~ goto-line
^[[4~ goto-end
^[[7~ goto-line
^[[8~ goto-end
then run the command lesskey. (These are escape sequences for vt100-like terminals.) This creates a binary file .less containing the key bindings.
| Why don't Page U/Down, Home/End work in less on Solaris over ssh from Ubuntu? |
1,519,672,792,000 |
I'm in a mintty window of a cygwin environment.
When I typed ⎈ Ctrl+V then ↑ key I got : ^[[A
Then I ssh into Raspberry Pi, and exit immediately.
Now I type ⎈ Ctrl+V then ↑ key I get : ^[OA
~$ ^[[A
~$ ssh rasp
Last login: Tue Dec 24 12:08:16 2019 from 192.168.0.5
raspberrypi%
Connection to 192.168.0.12 closed.
~$ ^[OA
Can someone help me to understand ?
|
On login, something in the remote shell is initializing your terminal (possibly even the ssh command itself, though that would be a misfeature). The ^[[A is a normal-mode and ^[OA an application-mode (see summary in XTerm Control Sequences), and applications such as screen which initialize the terminal for full-screen operations typically use the terminal initialization capabilities in the terminal description. mintty has its own terminal description, but sets TERM to xterm. So you're getting xterm's initialization string (see xterm-basic), probably smkx:
smkx=\E[?1h\E=
which is two settings:
\E[?1h Ps = 1 ⇒ Application Cursor Keys (DECCKM), VT100.
\E= ESC = Application Keypad (DECKPAM).
If this is just a case of an application setting something and not resetting it (using the same terminal description), you could follow up by
tput rmkx
(removing that mode). Doing that inside of screen or tmux would confuse the screen/tmux program; doing it inside of some other program also might not be good...
| Why the codes generated by [UP] key changed after ssh session |
1,519,672,792,000 |
I have a USB numpad that I want to use to control a specific application running as a daemon in the background. The daemon is written in Python and I'm currently reading input using python-evdev which works quite well.
However, everything I type on the keyboard is still also processed normally, meaning that keypresses are also inserted into any application dealing with keyboard input (including the login prompt that is shown when the computer boots up). This is somewhat annoying.
Is there a way to disable the "normal" processing of keyboard events, and only allow manual reading of the key states? Hopefully one that does not depend on running X.
Everything I've found so far seems to be dealing with disabling the keyboard completely or using X.
One idea I have is to create a keymap which maps all the keys to dead keys, which prevents any output, but still allows me to read the actual keycodes. However, it seems that there should be an easier solution to this problem.
|
If I understand the kernel sources directly, you cannot disconnect specific input devices from the global handlers (see /proc/bus/input/handlers): The kbd handler will always receive all input events, and convert key events into keypresses.
However, you can grab an input device for exclusive use with an EVIOCGRAB ioctrl on the device, either directly from your program, or using tools such as evtest --grab /dev/input/eventX (for testing). As long as the grab is active, the events shouldn't be processed by anything else.
I'm not familiar with python-evdev, but even if it doesn't support grab mode, it's not to difficult to perform ioctls in Python.
(I was lazy and tested only under X, where it works, but I see no reason why it shouldn't work without X).
| Disable keyboard but still allow reading from it |
1,519,672,792,000 |
I want to somehow generate a comprehensive "menu" of all possible ways to set up the GNU-screen "command characters" for a standard, off-the-shelf "US keyboard" and a specific terminal emulator, say xfce4-terminal.
I imagine that this universe of possibilities would decompose into three lists:
list A: all the possible values of the escape directive
list B: all the possible values for the <CODE> parameter in the expression bindkey -k <CODE> command, together with the "null setting" (i.e. the .screenrc config in which no bindkey -k <CODE> command directive is used)
list C: a mapping from any pair (a, b) (where a ∈ A, and b ∈ B) to an explicit description of how one would type the corresponding GNU-screen command character on a standard US keyboard, and assuming a specific terminal emulator (IOW, something equivalent to, for instance, "simultaneously press Ctrl and \").
Keep in mind, however, that these specs are a "best effort" by someone (me) who really does not understand the underlying basics. I hope that those who do understand these basics will be able to "read between the lines", and modify these specs as needed, while still retaining the spirit of the question (see Background), to render the question tractable.
I realize that the "menu" I'm hoping for may be very large, but I figure that it can't be intractably so, since, after all, the number of keys on a standard US keyboard is finite and not ginormous, and the set of fingers one can use for this purpose is even more so. (In case it matters, I could further stipulate that I am only interested in key combinations consisting of at most, say, 2 sequential "key chords", with at most 3 keys per key chord. By "key chord" I mean "set of keys to be pressed simultaneously".)
Background (aka tl;dr)
This question is actually a follow-up to a comment by Gilles in a thread I started earlier. It turns out that most of what that comment says is beyond my grasp. I figure that there are some huge gaps in my understanding of the basics here, so big in fact that I cannot even articulate sufficiently clear questions to fill them.
In a nutshell, it is a huge mystery to me that, for example, the key combination Ctrl + \ can be used to type the "command character" for GNU-screen, whereas other similar-looking key combinations, like (maybe) Ctrl + ', cannot 1.
Without a clear understanding of the underlying basics from the user (like me), the search for a suitable GNU-screen command character reduces to a sequence of isolated proposals ("How about Ctrl + H? After all, no one uses that for anything else.") that the user evaluates in turn until an acceptable one pops up.
How long this sequence of proposals and evaluations needs to go on depends on the size of the set of acceptable key combinations for that user. Clearly, this size will vary from one user to the next. In my case, it appears to be smaller than average, and as a result this approach has not yet given me an acceptable "command character" for GNU-screen.
The approach, in any case, seems to me inherently inefficient. It make more sense to me to be able to choose the best option from an explicit "universe" (i.e. "exhaustive set") of possibilities. This is what I'm trying to get at here.
EDIT: OK, after some studying, I now have a clear picture of how one types the (1-byte) characters in the ASCII range between \0001 and \0177, inclusive. These include all the "true" "control characters".
Also, I figure that list A can be described as all possible pairs of integers between \0001 and \0377, although probably many of these pairs can be ruled out as completely impractical. (E.g., those in which the first element of the pair is common "printable character", such as "e" or "8").
I'm still trying to figure out the following:
how to type the (1-byte) characters in the ASCII range \0200 to \0377, inclusive; I expect there will be some variation across terminals and terminal emulators on this, but I have no sense at the moment of how chaotic the variation is; is there a subset of these characters on which there is a substantial consensus? If so, I would love to know what these characters are (and how to type them)
how to get useful values for list B; I realize that these values are termcap codes; my difficulty here is not having a way to identify those termcap codes that map neatly to a convenient key combination; e.g. I know that the code F2 maps to F12 (sic), but I imagine that most termcap codes don't have such a neat association with a single key.
how to complete list C, even for a specific terminal emulator, and the "null setting" from list B.
1Please, don't attempt to explain this mystery to me: many very knowledgeable, and very patient, people have tried, and I still don't get it. The "knowledge gap" between those who understand what's going on and me is so great that their answers are invariably as baffling to me as what they aim to address. What I'm hoping to achieve with this post is precisely to work around this huge knowledge gap, by casting the question as a search for, in essence, an algorithm (to construct a prescribed finite set of possibilities) that could be implemented by even someone who does not understand the underlying basics.
|
To understand the answer to this question, you need to have some understanding of how keyboard input is processed. I refer you to How do keyboard input and text output work? for background. In this answer, I'm going to explain the relevant part in a different way, but I'll assume some general familiarity given by my earlier answer.
My answer here concerns typical unix systems; non-unix systems may behave differently. I will make some simplifications here and there; the additional complications are not relevant to answering this question. (This answer is complicated enough as it is.)
Most communication and storage, including the communication between a terminal-based application and a terminal (hardware or software), takes the form of a stream of bytes. A byte is a unit of information that can take 256 different values; it can be subdivided in 8 bits. Bytes are represented by a number between 0 and 255.
In order to transmit information, the parties need to agree on a way to encode this information as bytes. There are multiple ways to encode streams of characters as streams of bytes, but all of them are based on ASCII in one way or another. ASCII defines a correspondence between 7-bit values ranging from 0 to 127 and a set of 128 characters; this leaves an unused bit in each byte. The 128 characters fall into two categories:
95 printable characters: letters (A–Z, lowercase and uppercase), digits (0–9), space, some punctuation;
33 control characters.
Control characters encode orders and ancillary information sent to or from a terminal such as “move the cursor to the next line”, “ring the bell”, “wait for me”, “goodbye”, etc. Historical terminals introduced a key labeled “Control” (or “Ctrl” for short), which allowed users to enter control characters. To keep the electronics of the terminal simple, pressing Ctrl together with a key would perform a simple bit mask in the byte value normally sent by the character. For example, A sends the character A represented by the byte 65 (1000001 in binary); Ctrl+A sends the character represented by the byte value 1 (0000001 in binary), which is known as the “control-A” character, often written ^A.
Most control characters correspond to an uppercase letter, with the bit pattern 10xxxxx, with bit 6 set to 0 instead of 1. That accounts for 26 of them. 6 more control characters correspond to the punctuation characters that also have a bit pattern of the form 10xxxxx: these are @[\]^_ (see the ASCII printable character chart. In addition to the range 0–31, the character 127 is also a control character; it's known as “control-?” (? is 0111111; control-? is 1111111).
Over the years, non-ASCII byte values have been assigned different meanings. The world is converging to Unicode as the set of all characters anybody might want. The Unix world (as well as the Internet) has mostly standardized on UTF-8 as a way to encode characters as byte sequences. UTF-8 maintains compatibility with ASCII by assigning the same character as ASCII to any byte in the range 0–127, and using sequences 2 to 4 bytes in the range 128–255 to represent the million or so other characters. Some other character encodings are used in the unix world; most are based on ASCII and have different meanings for bytes above 128.
I can now answer one of your follow-up questions:
how to type the (1-byte) characters in the ASCII range \0200 to \0377
That depends what character encoding you use. If you use UTF-8, the most common one, sending these individual bytes is impossible, because they're only used as part of sequences of 2 to 4 bytes that represent a single character.
As for
list A: all the possible values of the escape directive
that's just byte values. The escape directive requires a two-byte parameter. If Screen receives the first byte value from the terminal, it decides that its escape key has been pressed. If the next byte sent by the terminal is the second byte from the escape setting, then Screen decides that you wanted to send that first byte to the application running inside the Screen window after all.
The description of the bind command explains how to specify byte values in a way that Screen understands. Where the documentation reads “character”, read “byte” instead.
Before we get to list B, we need to understand keychords. A keychord is the press of a key together with modifiers such as Ctrl, Shift, etc. We saw earlier that all information transmitted by the terminal is encoded as a stream of bytes. To keep things simple, all printable characters are encoded in the standard way, as one byte in the range 32–126 if they're ASCII characters and as bytes in the range 128–255 for other characters. This leaves only control characters to encode function keys and characters with modifiers other than Shift. But there are only 33 control characters!
A few function keys send a control character. For example, the Tab key sends ^I (byte value 9), because byte 9 is the TAB control character that instructs a printer to move to the next tab column. The Return key sends ^M (byte value 13), because byte 13 is the CR control character that instructs a printer to move its head to the beginning of the line. For similar reasons, Escape sends ^[, and BackSpace sends either ^H or ^? due to some historical waffling that I won't discuss here.
Most function keys and keychords send an escape sequence: a sequence of bytes starting with byte 27, the escape character (ESC) defined by ASCII, which happens to be ^[ (control-[). Different terminals sent different escape sequences. There are standards, but they don't define encodings for all keychords, far from it, and to some extent there are competing standards.
We're now ready to understand
list B: all the possible values for the <CODE> parameter in the expression bindkey -k <CODE>
The Screen documentation explains that these codes are termcap keyboard capability names. Termcap is a programming library that applications can use to abstract themselves from the variations between terminals. (It has now been mostly supplanted by Terminfo.) The Termcap database specifically contains information about the terminal such as the number of lines and columns (back when Termcap appeared, terminals were hardware devices, for which the concept of resizing didn't apply), the byte sequences (often beginning with ESC) that an application could use to perform operations such as moving the cursor or clearing the screen, and the byte sequences send by various keys. The symbolic names given by Termcap to function keys are what you can use after bindkey -k.
The Termcap manual lists all the entries in that database. The entries all have two-character names; the FreeBSD manual also gives a slightly more expressive name for each entry. The entries where FreeBSD lists key_SOMETHING in the first columns are the ones that describe function keys; the <CODE> you need for bindkey -k is the name in the second column, such as kl for Left, k1 for F1, F1 for F11, etc.
You'll notice that this database is missing a lot of keychords. If there's no entry for a keychord in this database, then there's no name you can use for the key with bindkey -k. Note that the set of supported keys varies from unix variant to unix variant.
bindkey can also be passed an escape sequence. To use this feature, you need to know what your terminal sends for the keychord you're interested in. While different terminals send different escape sequences for the same keychord, going from escape sequence to keychord is, fortunately, rarely ambiguous: very few escape sequences correspond to different keychords on different terminals.
You can find out what escape sequence a keychord sends by pressing Ctrl+V then the keychord. In a terminal in its default mode, as well as on the command line of all common shells, Ctrl+V means “interpret the next byte literally”. If it's followed by an escape sequence, this causes the ESC byte to be inserted literally instead of initiating the parsing of an escape sequence. Since escape sequences almost always consist of printable characters after ESC, this effectively inserts the escape sequence literally. For example, press Ctrl+V then Ctrl+Left to see what escape sequence Ctrl+Left sends: you'll see something like ^[O5D where ^[ is a visual representation of the ESC control character. (Once again, your terminal may send a different escape sequence.)
As for the null setting, when Screen reads an ESC byte, it enters escape sequence parsing mode. Each new byte is added to the accumulated escape sequence. If the accumulated sequence has an associated binding, Screen exits escape sequence parsing mode and fires the binding. If the accumulated sequence is not the prefix of any sequence with an associated binding, Screen exits escape sequence parsing mode and the accumulated sequence is discarded. So the null setting here is a complicated form of “nothing happens”.
After all this work, let's turn to
list C: a mapping from any pair (a, b) (where a ∈ A, and b ∈ B) to an explicit description of how one would type the corresponding GNU-screen command character on a standard US keyboard, and assuming a specific terminal emulator
As I hinted above, specific terminal emulator is important here: different terminals encode keychords in different ways, and some terminals can be configured in different ways. The mapping doesn't correspond to a pair (a, b): A × B is not an interesting set. Most keychords are mapped to either a printable character (which, as we saw above, extends A) or an escape sequence (which, as we saw above, extends B). In other words, the mapping is to a superset of A ∪ B.
Unfortunately for you, many terminals don't fully document how to send escape sequences. Fortunately for you, this is rarely needed. Instead of working from escape sequence to keychord, work from keychord to escape sequence. This can be determined for each terminal using Ctrl+V as described above.
Some terminals, notably xterm, can be configured to encode keychords in a systematic way. See Problems with keybindings when using terminal for an Emacs-oriented discussion. Unfortunately, this does not include the vte library that many terminal emulators use, especially in the GNOME world.
| How to make a comprehensive set of possibilities for defining GNU-screen "command characters"? |
1,519,672,792,000 |
I would like to remap CapsLock to Esc when pressed by itself and Ctrl when pressed with another key without using X.
This is similar to a previous question ( Remap CapsLock to Escape and Control System Wide ) but I am specifically looking for a solution without X.
|
This keymod program reads keyboard events from a /dev/input/eventX device and injects most directly back into the kernel using the /dev/uinput device. The caps lock behavior is special: if the key is pressed and released without touching another key, an Esc key is sent into the kernel. If another key is pressed while holding the caps lock, holding the (left) control key is emulated instead.
Since the program takes control over the specified event device, being able to access the computer using e.g. SSH can be very handy when testing this. For example, pausing this program (using ctrl-z for example) will make sure you can't use your keyboard anymore (it has taken control over it exclusively and is now no longer active).
| Multi-function CapsLock without X |
1,519,672,792,000 |
At the moment I have a keyboard which lacks function keys (F1 through F12), and I was wondering - is there a way I could switch to textual TTYs (and back, which might prove to be a problem if I were to use xmodmap)?
|
Assuming Linux, you can use chvt (as in sudo chvt N) to switch virtual terminal, where N is the number corresponding to the VT to activate. For example, sudo chvt 1 for the first VT, and sudo chvt 7 for the VT where you will most often find X running.
Note that chvt requires root privileges to do its thing, hence the sudo is necessary unless you are already logged in as root.
On Debian, chvt is provided by the packages kbd and console-tools; mine is the one from console-tools. Other distributions are likely similar.
By the way, this took me about 15 seconds to find by typing linux remap virtual terminal switch into Google. :-) I was expecting to find something to actually remap the switch to another key combination, but chvt answers your question just as well.
| Switch to TTYs without Function keys |
1,519,672,792,000 |
In my keyboard the I key doesn't work. So, I use an on-screen keyboard.
I'm using Ubuntu 13.04. But its hectic. Is there a way so that I can make another key (for example Home on my keypad) to behave like I?
Also, if you have any other easy way to achieve this please share.
|
You can re-map keys with xmodmap. E.g.:
xmodmap -e "keycode 79 = i I"
To find correct keycode and alias use xev.
Looking around a bit: this should give you needed details about persistent configuration etc.
| How to make a key simulate another key? |
1,519,672,792,000 |
I switch language layouts by pressing Alt+Shift and it's infuriating when after pressing alt my focus goes to some settings (especially in Skype)
Instead of staying in the text input it focuses ALT menu
To get back i have to remember to press ALT again
How can I disable this functionality?
OS: Linux Ubuntu 20.04
|
Create the file
~/.config/gtk-3.0/settings.ini
and add the following to it
[Settings]
gtk-enable-mnemonics = 0
If you want the settings to apply to all users, you can put in /etc/gtk-3.0/settings.ini instead.
Restart the X session once done.
Adapted/Stolen from https://askubuntu.com/a/569310 (go there and give it an upvote!).
| Disable alt focus |
1,519,672,792,000 |
I need to get access to modifier-key state for a console app I'm writing (a personalized editor).
Are there any packages/libs/whatever that provide this access?
I cobbled the following from somewhere, but it only works if you're root, and I don't really want to mess about at root-level.
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <termios.h>
#include <fcntl.h>
#include <linux/input.h>
#include <unistd.h>
#include <errno.h>
int kbhit(void)
{
struct termios oldt, newt;
int ch;
int oldf;
tcgetattr(STDIN_FILENO, &oldt);
newt = oldt;
newt.c_lflag &= ~0000172 ; //~(ICANON | ECHO);
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
oldf = fcntl(STDIN_FILENO, F_GETFL, 0);
fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK);
ch = getchar();
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
fcntl(STDIN_FILENO, F_SETFL, oldf);
return ch;
}
enum MODKEYS
{
SHIFT_L = 1,
SHIFT_R = 2,
CTRL_L = 4,
CTRL_R = 8,
ALT_L = 16,
ALT_R = 32,
};
int chkmodifiers()
{
int mods=0,keyb,mask;
char key_map[KEY_MAX/8 + 1]; // Create a byte array the size of the number of keys
//event1 - got by inspecting /dev/input/...
FILE *kbd = fopen("/dev/input/event1", "r");
if (kbd == NULL)
{
printf("(chkmodifiers) ERROR: %s\n", strerror(errno)); //permission - got to be root!
return 0;
}
memset(key_map, 0, sizeof(key_map));
ioctl(fileno(kbd), EVIOCGKEY(sizeof(key_map)), key_map); // Fill the keymap with the current keyboard state
keyb = key_map[KEY_LEFTSHIFT/8];
mask = 1 << (KEY_LEFTSHIFT % 8);
if (keyb & mask) mods += SHIFT_L;
keyb = key_map[KEY_RIGHTSHIFT/8];
mask = 1 << (KEY_RIGHTSHIFT % 8);
if (keyb & mask) mods += SHIFT_R;
keyb = key_map[KEY_LEFTCTRL/8];
mask = 1 << (KEY_LEFTCTRL % 8);
if (keyb & mask) mods += CTRL_L;
keyb = key_map[KEY_RIGHTCTRL/8];
mask = 1 << (KEY_RIGHTCTRL % 8);
if (keyb & mask) mods += CTRL_R;
keyb = key_map[KEY_LEFTALT/8];
mask = 1 << (KEY_LEFTALT % 8);
if (keyb & mask) mods += ALT_L;
keyb = key_map[KEY_RIGHTALT/8];
mask = 1 << (KEY_RIGHTALT % 8);
if (keyb & mask) mods += ALT_R;
return mods;
}
int main()
{
puts("Press a key!");
char ch=0;
int n=0,m;
while (ch != 'q')
{
n = kbhit();
if (n != -1)
{
m = chkmodifiers();
ch = (char)n;
printf("You pressed '%c' [%d]\n", ch, n);
if ((m & SHIFT_L) == SHIFT_L) printf(" .. and ls\n");
if ((m & SHIFT_R) == SHIFT_R) printf(" .. and rs\n");
if ((m & CTRL_L) == CTRL_L) printf(" .. and lc\n");
if ((m & CTRL_R) == CTRL_R) printf(" .. and rc\n");
if ((m & ALT_L) == ALT_L) printf(" .. and la\n");
if ((m & ALT_R) == ALT_R) printf(" .. and ra\n");
}
}
return 0;
}
|
Maybe have a look at libtermkey, a terminal key input library that recognises special keys (such as arrow and function keys), including "modified" keys like Ctrl-Left.
Another option might be to enhance the functionality of charm, a minimal ncurses copy.
| How to get user-level access to modifier keypresses in console app? |
1,519,672,792,000 |
I'm playing around with keyboard settings, and wanted to remap my windows keys to tab, for convenience. So I tried (133 is the left super key on my keyboard)
xmodmap -e "keycode 133 = Tab Super_L"
but this didn't work, in that hitting the windows key still brings up the "windows" menu, and no tab is inserted. A few different variations on the same theme also didn't work, e.g. making the Tab happen on shift+super.
I'm using cinnamon (installed from a ppa on ubuntu 16.04) and lightdm, and I imagine that the windows/super key is being intercepted at a lower level, which xmodmap can't quite deal with...is there any way of achieving what I want? Answers not involving xmodmap are welcome!
(I'm far from an expert, so perhaps there's a very easy solution...)
|
Trying to understand what's happenning
If I type xmodmap without argument (to get modifier list), I get:
xmodmap: up to 4 keys per modifier, (keycodes in parentheses):
shift Shift_L (0x32), Shift_R (0x3e)
lock Caps_Lock (0x42)
control Control_L (0x25)
mod1 Alt_L (0x40), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3 ISO_Level5_Shift (0x69)
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
The important part is for mod4. That's where Super_L is.
Now, I run : xmodmap -e "keycode 133 = Tab Super_L" && xmodmap | grep mod4, and I get:
mod4 Tab (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
The mod4 line changed and added Tab. That's why your key 133 still open the window menu.
By the way, I'm trying this on I3WM so the results can be a bit different.
For example, if I press the key 133 on a terminal or text editor, it both write a tab and becomes a modifier.
I also noticed I don't have a different behavior with Shift because the type of the key is ONE_LEVEL.
You can also run xev | grep key to see what happens with some key combinations.
Solution
But xmodmap also tells you can't have more than 4 keys per modifier, so a solution (the only one that worked for me so far) is to sacrifice a key you don't use / don't have, make it become a Super_L.
If you use QWERTY, you can modify the layout located on /usr/share/X11/xkb/symbols/us (it's usually another file of the same folder if you're using another layout), and write:
key.type[Group1] = "TWO_LEVEL";
key <MENU>{[Super_L]}; // ONE or TWO level, assuming MENU key isn't used
key <LWIN>{[ Tab, Super_L]}; // should be TWO_LEVEL
key.type[Group1] = "ONE_LEVEL";
instead of (probably line 14 of the file)
key <LWIN>{[Super_L]};
Then, update your keyboard layout with setxkbmap us && xmodmap | grep mod4.
You will get something like:
mod4 Super_R (0x86), Super_L (0x87), Super_L (0xce), Hyper_L (0xcf)
If you still get Tab, you should probably sacrifice another key.
Note that 0x85 is the hexadecimal value of 133, that mean this key will not be a direct mod4 but it still can behave like window key if Shift is pressed.
| how to remap super keys? |
1,583,864,375,000 |
I will try to describe the problem in details. Very often I use external keyboard with my netbook. The keyboard is "TK Stealth":
Click to zoom
You can see, that the numpad, is very similar to the classic numpad, but the arrow keys are actually mapped differently - as the additional arrow keys on a wide keyboards.
I want to make them to be mapped as in a numpad, i.e. "8" == "Up", "2" == "Down", "4" == "Left", "6" == "Right" and so on.
These settings must work only if this type of keyboard is attached.
I tried to make this using xmodmap /home/johnfound/TKStelth with the following map file "TKStelth":
keycode 79 = KP_Home KP_Home KP_Home KP_Home
keycode 80 = KP_Up KP_Up KP_Up KP_Up
keycode 81 = KP_Prior KP_Prior KP_Prior KP_Prior
keycode 83 = KP_Left KP_Left KP_Left KP_Left
keycode 84 = KP_Begin KP_Begin KP_Begin KP_Begin
keycode 85 = KP_Right KP_Right KP_Right KP_Right
keycode 87 = KP_End KP_End KP_End KP_End
keycode 88 = KP_Down KP_Down KP_Down KP_Down
keycode 89 = KP_Next KP_Next KP_Next KP_Next
keycode 90 = KP_Insert KP_Insert KP_Insert KP_Insert
keycode 91 = KP_Delete KP_Delete KP_Delete KP_Delete
It works actually, but there are ugly side effects. For example, sometimes the layout is restored to the default and I must run the above script manually. Including the script to the initialization scripts caused some conflicts/locks that made the OS to hang for several minutes after resuming from suspend and changing screen resolutions. This way, I was forced to remove the scripts from the initialization scripts.
I read somewhere that xmodmap is actually the old way to handle keyboard layouts.
So, the question: How to configure Linux to handle this and only this keyboard properly?
Additional information: Manjaro Linux with XFCE. The keyboard is configured with two layouts - US and Bulgarian and they must stay after the above configuration changes.
|
As long as I found the proper solution, I will answer my own question.
There is a program named keyfuzz that can change the keyboard maps used by the kernel, based on input devices - i.e. separately for every keyboard attached to the computer.
There are two problems with this program that are not described properly in the documentation:
The USB keyboards generate scan codes, other than the scan codes of keyboards attached to ps/2 port. This way, if you need to remap USB keyboard, you will need a way to know the scan codes of the keys. The tool "showkey", usually recommended for testing scancode and keycode will not do the job, because it reads form /dev/console that emits "standard" scan codes, regardless of the keyboard.
In order to test the scan codes of the keyboard based on its /dev/input/KEYBOARD address, you need to use the program named getscancodes. Notice that the downloaded file from the above link is not properly compressed. It is named getscancodes.tar.gz, but is compressed with ZIP algorithm. The package contains the source code as well as precompiled binaries.
In my case the keyfuzz configuration file looks this way:
### evdev 1.0.0., driver 'TK Stealth keyboard'
### Proper old-style numpad handling
0x70059 107
0x7005A 108
0x7005B 109
0x7005C 105
0x7005D 108
0x7005E 106
0x7005F 102
0x70060 103
0x70061 104
0x70062 110
0x70063 111
The program "keyfuzz" starts as a service during the boot, in order to patch the tables as early as possible. Unfortunately, the USB keyboards are added to the devices later, so when the keyfuzz starts, there is no keyboard to be patched, even if the USB keyboard is attached during the boot.
The solution is to use udev rules files and to start keyfuzz on adding the needed keyboard.
In order to do it, you need to add a file /etc/udev/rules.d/mykeyboard.rules, containing (in my case):
ACTION=="add", ATTRS{idVendor}=="2516", RUN+="/usr/lib/systemd/scripts/keyfuzz start"
Now, after plugging the keyboard, the keyfuzz start script will start and patch the keyboard decoding tables.
| How to properly change the keyboard mapping? |
1,583,864,375,000 |
How can I map the spanish eñe letter to a key combination? What application is suitable for this purpose (xmodmap, xbindkeys, ...)?
When I press Caps Lock + n, it should type ñ
When I press Caps Lock + N, it should type Ñ
I'd like to do this without switching keyboard layouts; I want to use only the English keyboard layout.
|
This answer explains how to set this up with xmodmap. Put the configuration snippets below in ~/.Xmodmap, and run xmodmap <~/.Xmodmap to apply them. Depending on your distribution and your setup, ~/.Xmodmap may be loaded automatically when you log in, or you may need to call xmodmap explicitly from ~/.xinitrc or ~/.xsession, or you may need to configure your desktop environment to apply ~/.Xmodmap.
X has a keysym (i.e. an abstract key name) called Mode_switch. On most keyboard mappings for latin-script languages other than US, this keysym is bound to the key labeled AltGr, which replaces the right Alt key. You can choose to map Mode_switch to a different key such as Caps Lock. On a PC keyboard, the keycode (what the hardware sends) for Caps Lock is 66, so change its binding to Mode_switch, and remove the caps lock modifier from it:
keycode 66 = Mode_switch
clear Lock
You also need to associate a modifier with Mode_switch. There are 5 custom modifiers, Mod1 through Mod5; any will do, but there has to be one. Run xmodmap -pm to see what modifiers are in use, and pick one of the 5 that isn't, then add a line like this to your .Xmodmap:
add Mod3 = Mode_switch
In an xmodmap key specification, the character sent by the key with Mode_switch is in the third column after the = sign, and with Mode_switch+Shift in the fourth column. (The first two columns are for the key with no modifiers and with Shift.) You can use a keysym directive to rebind the key that now sends n regardless of its keycode:
keysym n = n N ntilde Ntilde
The names on the right are in fact keysym names. You can find a list of these in
/usr/include/X11/keysymdef.h, e.g. the line #define XK_Ntilde 0x00d1 means there's a keysym called Ntilde that corresponds to Unicode character U+00D1. There are characters that don't have a keysym name; you can use the unicode number instead.
! U+2030 is PER MILLE SIGN, U+2031 is PER TEN THOUSAND SIGN
keysym 5 = 5 percent U2030 U2031
Note that if you're shifting modifiers around on systems of ~2009–2011 vintage, you might run into an X_SetModifierMapping bug. Often, but not always, using clear Lock will work around the bug.
| Set the key for spanish eñe letter |
1,583,864,375,000 |
I'm using FreeBSD 11 with PuTTY for SSH. The keyboard's key codes don't seem to be set up at all correctly - for example it beeps on up arrow and inserts '~' for most navigation keys including basics like arrows and delete key. The keyboard is a standard UK English keyboard. Typing is a real pain.
I've read a number of threads about setting key codes, both in rc and shell, so I know I can set it up that way as a last resort.
But it would be very odd for a client with so much configurability, and an OS with such wide use, not to have some terminal option / setting in common that they both "just understand", that I can set on both and voila - the keys all (or mostly) work. The trouble is I have no idea how to find it and, when I do find it, how to set it for all future sessions.
I understand how to find the keycode being sent by the terminal for an individual key, so I could set up my keys that way, one by one. But I would like to find basic terminal settings for my shell rc and for PuTTY, that gets as many keys as possible understood by both, so I only have to set up a few exceptions if I need them.
How can I do this?
|
There are so many knobs to twist and turn. And much advice on the Internet people follow blindly. As always many ways to Rome but when you know how things are connected they are very simple.
The ultra short answer is:
Change the terminal string in Putty from xterm to putty (under Connection -> Data -> Terminal-type string).
The typical pitfall to avoid:
Make sure that you are not setting TERM elsewhere in your rc files.
The slightly longer answer:
First I would start by ensuring that you are actually using the defaults. From my personal Windows 10 laptop using DK keyboard (and mapping) I connect to a FreeBSD 11.1 setup with DK mapping. In my case the arrow keys works as expected on the command-line. Left/right moves on current line. Up/Down goes through command history.
I have verified this for both /bin/sh (default user shell) and /bin/tcsh (default root shell). You can read up on shells.
You write that you know how you can do your keymapping in the shell rc file. Many suggestions on how to do this is floating around. But it is usually not what you should do.
You will find suggestions like this for tcsh keybindings:
# Del(ete), Home and End
bindkey "\e[3~" delete-char
bindkey "\e[1~" beginning-of-line
bindkey "\e[4~" end-of-line
And suggestions like this for bash ( ~/.inputrc)
"\x7F": backward-delete-char
"\e[3~": delete-char
"\e[1~": beginning-of-line
"\e[4~": end-of-line
But rather than setting these bindings locally for each session and each shell you should rather use termcap/terminfo for this purpose (more on this later).
In this context Putty is your terminal.
The default for Putty is to set TERM for your session to "xterm". It does that because it is reasonably xterm compatible. xterm is not a reference to any terminal but for the program Xterm.
PuTTY Configuration
Connection -> Data -> Terminal-type string: `xterm`
When you have logged in you can verify this setting carries through to your session:
echo $TERM
xterm
If $TERM does not match what you have set in Putty then you might have set an override in your rc files. Notice the warning for /bin/sh in ~/.profile:
# Setting TERM is normally done through /etc/ttys. Do only override
# if you're sure that you'll never log in via telnet or xterm or a
# serial line.
# TERM=xterm; export TERM
Because we do not use a lot of physical DEC VT100's anymore xterm is what you will see many places.
Even if you just keep TERM as xterm you will get colour output with default Putty and FreeBSD as ls -G will work.
Some will recommend that you set TERM to xterm-color, xterm-256 or rxvt-256color to get "proper" colour support.
But remember: All these magic TERM values are just mappings in a database. A reason xterm is so prevalent today is that some programs and script checks if $TERM begins with xterm (which is a horrible idea).
This then brings us back to termcap which is the default on FreeBSD. If you want to use terminfo then you will need to install devel/ncurses. For more on this see: How can I use terminfo entries on FreeBSD?
You can find the source of the termcap database in the text file /usr/share/misc/termcap. If you make changes to this file you need to run cap_mkdb to get the system to acknowledge the change. In here you will find the answer to your conundrum. There is an explicit TERM setting for Putty named: putty.
FreeBSD has then made the choice not to change the settings for xterm to match Putty's behavior (probably due to combatibility concerns). But they have been nice enough to supply a setting for Putty.
So if you change the Putty default setting for Terminal-type string: from xterm to putty then this is is reflected in TERM when you log in. And the default FreeBSD termcap has an entry for this.
And by magic and without touching a lot of rc files you now have working arrow keys (I had that with xterm as well) but also Home/End moves to start/end of line and Del(ete) deletes.
Bonus:
It seems the default putty definition does not support all 256 colours. You can then modify your termcap and add these two lines (and run cap_mkdb):
putty-256color:\
:pa#32767:Co#256:tc=putty:
Then you can set your TERM to putty-256color.
Scott Robison suggested this should be added - but the change has not been picked up by FreeBSD. I cannot find this PR in the database anymore.
Bonus 2:
If you prefer to keep TERM as xterm then you should spend time configuring Putty to match what FreeBSD expects of the xterm terminal.
If you go to the settings Terminal -> Keyboard in the setting The Home and End keys you can change "Standard" to "rxvt".
With this change you will notice the Home key works on the command line (moves to start of line). But End now does nothing.
So it is then a question of getting Putty to agree with what FreeBSD expects from an xterm. Just to show that you can also go the other way around.
| Getting PuTTY to work properly with FreeBSD |
1,583,864,375,000 |
Which application can I use to figure out what to put in .inputrc for any custom keyboard shortcut? I've tried a few, and none of them seem to be usable:
showkey, showkey -a and read just print ' if you press Ctrl-'.
xev prints them separately, and doesn't print anything that seems usable for .inputrc.
|
I believe ctrl-' will not be passed to applications in the console. It also doesn't show up in xev.
It may be the input system or even PC hardware, but without trickery some of the key combinations may be impossible to detect.
| How to print keypresses in .inputrc format? |
1,583,864,375,000 |
When I am using emacs 23.3 on KDE, I can not input ^, ´ and ~ from my German keyboard. If I press these keys, then emacs says that <dead-circumflex>, <dead-acute> and <dead-tilde> are undefined.
I can input ^, ´ and ~ on other applications (e.g. Konsole, Kwrite and firefox), and I can also paste these letters on emacs.
I have tried to type C-x ret C-\ latin-1-postfix, but there is no change.
Could anyone tell me how to solve this problem?
|
I don't know what's causing this problem or how to fix this, but I can offer a workaround for most purposes.
Normally, dead keys are processed at a very low input layer, not even visible from Lisp. But you can do the processing in Lisp.
If you want the keys to act as dead keys:
There is already a limited mechanism for dead keys in Lisp, designed for 8-bit character sets on machines that don't have any way to input non-ASCII characters. If you type C-x 8 followed by an accent and a letter, the corresponding accented letter is inserted, thanks to the iso-transl library. We can copy this mechanism. Put this in your .emacs:
(define-key key-translation-map [dead-grave] (lookup-key key-translation-map "\C-x8`"))
(define-key key-translation-map [dead-acute] (lookup-key key-translation-map "\C-x8'"))
(define-key key-translation-map [dead-circumflex] (lookup-key key-translation-map "\C-x8^"))
(define-key key-translation-map [dead-diaeresis] (lookup-key key-translation-map "\C-x8\""))
(define-key key-translation-map [dead-tilde] (lookup-key key-translation-map "\C-x8~"))
(define-key isearch-mode-map [dead-grave] nil)
(define-key isearch-mode-map [dead-acute] nil)
(define-key isearch-mode-map [dead-circumflex] nil)
(define-key isearch-mode-map [dead-diaeresis] nil)
(define-key isearch-mode-map [dead-tilde] nil)
The map key-translation-map rewrites key sequences as they are entered, so this will make dead ` a equivalent to à for most purposes. Explicitly setting entries in isearch-mode-map to nil is necessary because otherwise pressing a dead key would exit isearch before the translation could kick in.
If you want the accent characters to be inserted immediately
(define-key key-translation-map [dead-grave] "`")
(define-key key-translation-map [dead-acute] "'")
(define-key key-translation-map [dead-circumflex] "^")
(define-key key-translation-map [dead-diaeresis] "\"")
(define-key key-translation-map [dead-tilde] "~")
| Some keys are invalid on emacs when using German keyboard |
1,583,864,375,000 |
I want to know which keys are pressed on my keyboard and print the information to stdout.
A tool that can do this is showkey. However, if I want to pass the data of showkey to read:
while read line; do
echo "$line" | otherprog
done <`showkey -a`
OR
showkey -a | while read line; do
echo "$line" | otherprog
done
Then showkey waits until a sum of 140 characters is typed in and then sends the buffered information to read.
showkey -a prints the pressed keys line by line, without any buffering.
Why does it buffer?
How do I avoid this buffering, so that I can read showkey's output truly line by line?
Is there an alternative to showkey?
Is there a file I can read the pressed keys directly from?
What is the correct way to pass data to read?
Solution:
I've used lornix's solution and included it into my simple keyboard keyboard :D!
stdbuf -o0 showkey -a | while read line; do
perl -e 'print sprintf "%030s\n",shift' "$line" | aplay &> /dev/null &
done
Lasership version:
#!/bin/bash
MP3=(); for i in mp3/*.mp3; do MP3+=("$i"); done
NMP3=${#MP3[@]}
stdbuf -o0 showkey -a 2>/dev/null | while read line; do
[ -z "$line" ] || ! [[ $line =~ ^[0-9] ]] && continue
NUM="$(echo "$line" | awk '{print $2}')"
mplayer "${MP3[$(($NUM % $NMP3))]}" &>/dev/null &
done
In the same folder, download some laser mp3 files into a folder called mp3.
|
Try setting showkey output to non-buffering with the stdbuf command:
stdbuf -o0 showkey -a | cat -
Will show the output as keys are pressed, rather than buffering a line.
stdbuf can adjust the buffering of stdin, stdout and stderr, setting them to none, line buffered, or block buffered, with a choosable block size. Very handy.
| Print currently pressed keys to stdout and read them line by line |
1,583,864,375,000 |
Is there a way in Linux mint to use numpad as a mouse on my desktop. I have tried shift+numlock but it did not work.
Is there a package that I must install?
Articles on the Internet are too old to be useful.
|
Try this:
setxkbmap -option keypad:pointerkeys
and then the combination.
| How to use numeric keypad as mouse? |
1,583,864,375,000 |
I am running GNOME 3.4 (Debian 7.0) and my laptop (Gigabyte Q2532), unlike all those I've used before, doesn't change application tabs with CtrlPg Up and CtrlPg Dn. This forces me to use Alt0...9, which is not always convenient. Is there something wrong with my laptop? Is this normal? How to remedy? My layout is set to English (US).
Note that I tried this with a fresh user, and still get the same issue. I'm also using GNOME 3 fallback mode.
|
GtkNotebook defaults to CtrlPageUp and CtrlPageDown for switching tabs (hardcoded in gtk/gtknotebook.c).
The problem is your keys are on the numpad, so they have different keynames/keysyms, i.e.: KP_Page_Up (instead of Page_Up) and KP_Page_Down (instead of Page_Down). Remapping the keys should fix it. I have no numpad on my XPS 15 to test but something like this should work:
xmodmap -e 'keysym KP_Prior = Prior' -e 'keysym KP_Next = Next'
You could also patch the source code, replacing all occurrences of GDK_KEY_Page_Up/GDK_KEY_Page_Down with GDK_KEY_KP_Page_Up/GDK_KEY_KP_Page_Down in gtknotebook.c
Since you're on Gnome, you can make it permanent by adding it to your start-up programs. In terminal, run gnome-session-properties, then Add:
Name: Whatever
Command: xmodmap -e 'keysym KP_Prior = Prior' -e 'keysym KP_Next = Next'
Comment: Whatever
Alternatively, create a file ~/.Xmodmap with this content:
keysym KP_Prior = Prior
keysym KP_Next = Next
test if it works with:
xmodmap ~/.Xmodmap
Load it at start-up with xmodmap /home/yourusername/.Xmodmap, via gnome-session-properties, xinitrc, xprofile. E.g. (note the full path for the file):
gnome-session-properties >> Add :
Name: Whatever
Command: xmodmap /home/tshepang/.Xmodmap
Comment: Whatever
| How to make Ctrl+PgUp and Ctrl+PgDn change window tabs |
1,583,864,375,000 |
I was looking for a list of keyboard scancodes in the linux kernel sources, but I did not find anything. Does someone know where to find these? Especially the USB scancodes would be interesting.
|
The keycodes are in [src]/drivers/tty/vt/defkeymap.map:
# Default kernel keymap. This uses 7 modifier combinations.
[...]
See also my answer here for ways to view (dumpkeys) and modify (loadkeys) the current keymap as it exists in the running kernel.
However, those are a bit higher level than the scancodes sent by the device. Those might be what's in the table at the top of [src]/drivers/hid/hid-input.c, however, since they come from the device, you don't need the linux kernel source to find out what they are; they are the same regardless of OS.
"HID" == human interface device. The usbhid subdirectory of drivers/hid doesn't appear to contain any special codes, since USB keyboards are really regular keyboards.
One difference between keycodes and scancodes is that scancodes are more granular -- notice there's a different signal for the press and release. A keycode corresponds to a key that's down, I believe; so the kernel maps scancode events to a keycode status.
| Where in the linux kernel sources can I find a list of the different keyboard scancodes? |
1,583,864,375,000 |
I recently acquired MK-85 mechanical USB keyboard from QPAD. The keyboard works perfect on Windows. It works perfect in Syslinux. It works almost perfect on Linux. The only issue on Linux is that a single key is misbehaving (Gentoo (3.6.11), Arch Linux and Linux Mint (2.6.38) are all affected).
The keyboard is a 105-key German layout keyboard and the key in question is the one between Ä and ENTER. On US layout this corresponds to the key \, on German layout this corresponds to # and on Scandinavian layout it's '.
When this key is pressed with other keys, it produces an extra keypress for each other key that is simultaneously pressed. For example, under Scandinavian layout if I want to type the word "don't" really fast I end up with: don'''t'
The behaviour can be observed with the program showkeys:
kb mode was UNICODE
[ if you are trying this under X, it might not work
since the X server is also reading /dev/console ]
press any key (program terminates 10s after last keypress)...
keycode 28 release
keycode 32 press // d pressed
keycode 24 press // o pressed
keycode 49 press // n pressed
keycode 32 release // d released
keycode 43 press // ' pressed
keycode 24 release // o released
keycode 43 release // ' released
keycode 43 press // ' pressed, extra ' produced
keycode 49 release // n released
keycode 43 release // ' released
keycode 43 press // ' pressed, extra ' produced
keycode 20 press // t pressed
keycode 43 release // ' released
keycode 43 press // ' pressed, extra ' produced
keycode 20 release // t released
keycode 43 release // ' released
keycode 43 press // ' pressed, extra ' produced
keycode 43 release // ' released (REAL)
It only happens with this single key, regardless of keyboard layout. Another way it manifests itself is if I press and hold a key, it repeats, and I press and hold another key which should also start repeating:
aaaaaaaaaakkkkkkkkkkkkk (works as intended)
¨¨¨¨¨¨¨¨¨¨fffffffffffff (works as intended)
''''''''''a'''''''''''' (a is not repeated, instead ' continues)
On Windows this issue does not exist:
OnKeyDown, Key code=68, Control keys=, Key name d
OnKeyPress d
OnKeyDown, Key code=79, Control keys=, Key name o
OnKeyPress o
OnKeyDown, Key code=78, Control keys=, Key name n
OnKeyPress n
OnKeyup, Key code=68, Control keys=, Key name d
OnKeyDown, Key code=191, Control keys=, Key name ........OEM specific
OnKeyPress '
OnKeyup, Key code=79, Control keys=, Key name o
OnKeyup, Key code=78, Control keys=, Key name n
OnKeyDown, Key code=84, Control keys=, Key name t
OnKeyPress t
OnKeyup, Key code=191, Control keys=, Key name ........OEM specific
OnKeyup, Key code=84, Control keys=, Key name t
What do you think SE? Hardware issue? It works fine in Syslinux which makes me feel like there'''s' something wrong on Linux side. Any pointers, ideas or better ways to debug? If getting this to work right requires patching the kernel I'm up for it.
|
I have tried to make a proper patch for this bug. It is a problem in the kernel rather than with the keyboard, although it could be argued that the keyboard behave in a strange way. Anyway, the patch is submitted to the linux-input list for review but there are no comments on it yet.
This should fix the problem mentioned here with the QPAD MK-85, but the same problem exists with Corsair K70, Gigabyte Osmium and other similar keyboards. If you have a keyboard that has the bug it would be great it you can test the patch. If you test it let me know if it works and also what keyboard you have, it is also important what language version you are using, US and non-US keyboards will behave differently. Note that the backslash key on US keyboards will have other labels on other versions of the keyboard.
Here is the mail from linux-input with the patch:
http://article.gmane.org/gmane.linux.kernel.input/37583
| A single key on keyboard produces extra keypresses for each simultaneously pressed key |
1,583,864,375,000 |
whenever I login to my system (Ubuntu 13.10) onboard (on-screen keyboard) automatically runs. I don't want it to run any more. Why does it run automatically & how to disable it?
Long back as far as I remember, once I manually started onboard. And after that it starts on its own.
|
If your on screen keyboard is appearing at your login screen, find the circle with the little guy in it and click on him. You should be able to disable the keyboard from there.
If that doesn't work, go to System Settings > Universal access and disable it from there.
| How to disable onboard (on-screen keyboard) that automatically starts when I log onto my system? |
1,583,864,375,000 |
How can I build a component that sits between the keyboard and applications that captures all key presses and emits it's own key press signals. The emitted signals won't necessarily be 1-to-1 with those captured. Ultimately, I'm attempting to create an input method similar to ibus (I'd also appreciate information on how ibus works technically).
After reading this question, I think the appropriate place to capture would be after keycodes or keysymbols are generated. I also understand X allows a client to grab all keyboard events which sounds relevant to what I'm trying to do.
|
There are basically two ways:
1) On the kernel level, find the /dev/input device that produces your keypresses, open it and do a "grab"-ioctl (same as evtest --grab does). That will cause this input device to send the key events exclusively to your application. Then use /dev/uinput to create your own input device from your application, where you can send key events out. X should connect to that device automatically.
2) On the X level, intercept keypress events just like the window manager does, and send out your own events with XSendEvent instead. I am not sure a grab would be the best way to do it; grabs are intended for a situation when some application temporarily wants to intercept all events during a specific interaction.
I have no idea what ibus does (maybe even a third method), I haven't looked at it in detail.
Edit
Had to look this up, because it's too long that I read about all the X details.
There are two basic grab functions: XGrabKeyboard, which generates FocusIn and FocusOut events, and takes complete control of the keyboard (active grab). This is the function I meant when talking about X grabs above, and this is the function that should only be active temporarily.
There is also XGrabKey, which registers a passive grab for specific keycodes. Looking very quickly at the source code of the window manager fvwm, this seems to be what the window manager uses.
The details of this are complicated enough that you probably want to dig up some documentation about how to program a window manager (or read source code, maybe even ibus source code).
| how to proxy key presses |
1,583,864,375,000 |
Today I had to force-shutdown my machine after it froze during resume from suspend. Since the reboot, I've found that the p key doesn't work normally in X. It does work normally in the console.
Modified keypresses, e.g. shift-p, ctrl-p, do work normally.
Pressing p with xev running gives
FocusOut event, serial 34, synthetic NO, window 0x5000001,
mode NotifyGrab, detail NotifyAncestor
FocusIn event, serial 34, synthetic NO, window 0x5000001,
mode NotifyUngrab, detail NotifyAncestor
KeymapNotify event, serial 34, synthetic NO, window 0x0,
keys: 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Could this problem be happening because of file corruption? What file would I check for corruption?
I've done an fsck on the system drive —by running tune2fs -C 200 /dev/sda3 before rebooting— which seems to have come up clean. I.E.
$ sudo tune2fs -l /dev/sda3 | grep 'state\|check'
Filesystem state: clean
Last checked: Sat Dec 11 12:27:16 2010
Next check after: Thu Jun 9 13:27:16 2011
I'm running an updated (last dist-upgrade done yesterday) ubuntu 10.10.
|
I've realized that this was happening because of a typo I made when manually editing my xfce keyboard shortcuts file.
Specifically, the file ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml used the modifier Meta5 (which doesn't exist) instead of Mod5 to modify the p key.
I did note that no errors were recorded in ~/.xsession-errors, despite the fact that xfce seems to register things there.
It may be useful to some people to note that one of my reasons for editing the file was in order to make the same shortcuts work with or without the Keyboard Layouts applet being loaded. Depending on whether or not that applet is loaded, the "windows" key will register as either <Super> or <Mod5>.
| `p` key doesn't work in X |
1,583,864,375,000 |
I have a Keychron K2 mechanical keyboard and the keys on the righthand side of the keyboard look like this:
I would like to swap them to a more standard layout, so that, from top to bottom, I would have Light Toggle, Home, Page Up, Page Down, and End.
I used xev to retrieve the key codes and wrote a small script that uses xmodmap to swap them to my liking:
#!/bin/bash
xmodmap -e "keycode 110 = Next" && xmodmap -e "keycode 112 = Home" && xmodmap -e "keycode 117 = Prior"
This script is executed on start up and works exactly as expected.
The problem is this keyboard is both wired and Bluetooth. When I switch between wired mode to Bluetooth mode or vice-versa, the keys go back to their default position and I need to manually run my script above one more time. xev shows to me that in both cases the key codes are the same. Is there a better way of tackling this so that these keys are swapped regardless of the keyboard mode I use?
|
Unfortunately, in Linux Mint (and Ubuntu derivates) xmodmap resets whenever a keyboard is plugged/unplugged or when a new keyboard is detected. In the case of keyboards with dual mode like mine, the system understands that these are two separate keyboards and will reset xmodmap at that point.
The solution to this is to edit the file pc in /usr/share/X11/xkb/symbols/ using:
$ sudo nano /usr/share/X11/xkb/symbols/pc
Then change lines 77, 78, and 81 from...:
key <HOME> { [ Home ] };
key <PGUP> { [ Prior ] };
key <PGDN> { [ Next ] };
... to:
key <HOME> { [ Next ] };
key <PGUP> { [ Home ] };
key <PGDN> { [ Prior ] };
This will hardcode change those keys for all keyboards.
| xmodmap resets when keyboard mode changes |
1,583,864,375,000 |
I know how to map mouse click for F1, F2 and F3 (respectively left click, middle click, right click):
xkbset m # required, but disable keypad
xmodmap -e "keycode 67 = Pointer_Button1 Pointer_Button1"
xmodmap -e "keycode 68 = Pointer_Button2"
xmodmap -e "keycode 69 = Pointer_Button3"
But this requires me to use xkbset m that use the slow keys mode :
If I press 4 from the keypad, it moves the cursor to the left. I don't need this feature, just the mapping above.
I tried to figure it out with xdotool, but I don't know how to handle key pressed/key released (for drag & drop) with
xdotool mousedown 1
xdotool mouseup 1
How can I not use this mode or how can I remap all keypad keys ?
What about the numeric and arithmetic signs from keypad please ?
Is there another solution ?
For information, needed for Debian (cinnamon) and Archlinux (xfce), and if possible, I would like a solution not based on the window manager.
EDIT:
Tried this solution but I can't drag and drop with F1.
In ~/.xbindkeysrc :
"xdotool mousedown 1"
F1
"xdotool mouseup 1"
F1 + Release
Or :
"xdotool mousedown 1"
m:0x10 + c:67
"xdotool mouseup 1"
m:0x10 + c:67 + Release
Then :
xset -r 67
EDIT2
Tried with actkbd
# actkbd configuration file
<keycode ("67")> :key : :xdotool mousedown 1
<keycode ("67")> :rel : :xdotool mouseup 1
No cigar :/
Adapted from here
|
W00T !
First : create a script click:
#!/bin/bash
id=$(
xinput list |
awk '/Dell USB Keyboard/{print gensub(/.*id=([0-9]+).*/, "\\1", "1")}'
)
xdotool mousedown $1
while IFS= read -r event; do
if [[ $event == *release* ]]; then
xdotool mouseup $1
exit
fi
done < <(xinput test $id)
Then add a new keyboard shortcut in your window manager and map F1 to run /path/to/mouse <1|3> (left OR right click).
Et voilà ;)
This can be ran with xbindkeys to be WM agnostic
Edit:
don't know why this doesn't work with archlinux + xfce 4.12 but on Debian9 + Cinnamon
Edit :
This solution works better :
In .bashrc :
xmodmap -e "keycode 67 = Pointer_Button1 Pointer_Button1"
xmodmap -e "keycode 68 = Pointer_Button2"
xmodmap -e "keycode 69 = Pointer_Button3"
As a keyboard shortcut :
#!/bin/bash
id=$(
xinput list |
awk '/Dell USB Keyboard/{print gensub(/.*id=([0-9]+).*/, "\\1", "1")}'
)
(
while read event; do
if [[ $event == *release* ]]; then
xkbset -m
exit
fi
done < <(xinput test $id)
) &
xkbset m
| How to map mouse keys as keyboard keys without losing'numeric keypad' for Linux? |
1,583,864,375,000 |
Distro and X.org Version Information
I am using Ubuntu 12.10 with xserver-xorg/quantal 1:7.7+1ubuntu4.
Disabling Built-In Keyboard in X11
I have a laptop with a built-in keyboard that no longer recognizes certain letters. I am currently disabling the built-in keyboard by opening a terminal and running the following shell function:
disable_keyboard () {
xinput --set-int-prop $(
xinput --list |
ruby -ane 'if /AT.*keyboard/ then puts $_.match(/(?<==)\d+/) end'
) "Device Enabled" 8 0
}
This works (albeit manually) by disabling the built-in AT Translated Set 2 keyboard while allowing my external Chicony USB Keyboard to continue working. However, I'd really like this to happen automatically during X11 sessions.
I tried modifying my X.org configuration as follows:
# /etc/X11/xorg.conf.d/disable_keyboard
Section "InputClass"
Identifier "disable built-in keyboard"
MatchIsKeyboard "on"
MatchProduct "AT Translated Set 2 keyboard"
Option "Ignore" "on"
EndSection
However, either this is not being sourced when X11 starts, or it is not the correct incantation. How can I correctly configure X11 to use only the USB keyboard?
|
Disable Built-In Keyboard and Trackpad with InputClass
One can disable the built-in devices by setting the Ignore option in an input class to true or on. The necessary information to match the devices can usually be gathered from /var/log/Xorg.0.log.
I chose to place my disabling sections in the evdev configuration file that was already present, since on my system both devices use the evdev driver. The sections could just as easily go somewhere else, but I'm unsure about the precedence of the matching rules and decided to play it safe by placing the rules in the same file above other devices that contain a Driver "evdev" line.
# /etc/X11/xorg.conf.d/10-evdev.conf
Section "InputClass"
Identifier "Built-In Touchpad"
MatchIsTouchpad "on"
MatchProduct "SynPS/2 Synaptics TouchPad"
Option "Ignore" "true"
EndSection
Section "InputClass"
Identifier "Built-In Keyboard"
MatchIsKeyboard "on"
MatchProduct "AT Translated Set 2 keyboard"
Option "Ignore" "true"
EndSection
| How can I automatically disable my laptop's built-in keyboard in X.org? |
1,583,864,375,000 |
I have some problem. Every 3-5 second everything, that I input from keyboard became UPPERCASE only. I also have two keyboard layouts: us and ua. And when uppercase happens - I can't switch my keyboard layout (I use mod4 for switching).
This is my xmodmap output:
$ xmodmap
xmodmap: up to 3 keys per modifier, (keycodes in parentheses):
shift Shift_L (0x32), Shift_R (0x3e)
lock Caps_Lock (0x42)
control Control_L (0x25), Control_R (0x69)
mod1 Alt_L (0x40), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
I tried xmodmap -e "clear lock", but uppercase input still periodically turns on. I tried to disable Caps Lock key in "hardware way", putting insulator between keyboard contacts. But I doesn't help.
== Update == For A#1
Look, there is sticky Caps_Lock:
KeyPress event, serial 40, synthetic NO, window 0x2a00001,
root 0xaa, subw 0x0, time 30893676, (-254,229), root:(384,359),
state 0x2, keycode 39 (keysym 0x53, S), same_screen YES,
XLookupString gives 1 bytes: (53) "S"
XmbLookupString gives 1 bytes: (53) "S"
XFilterEvent returns: False
What I'm doing? First, I run florence (Virtual Keyoards) and turn off Caps_Lock key. Second, I type: xmodmap -e "clear lock". But it is very dirty hack :), you know. It works for few minutes or few hours.
|
I plugged in USB keyboard. In GRUB menu I added into kernel string: i8042.nokbd (after quiet).
Also, if you need to turn-off notebook keyboard while working, use xinput.
First execute xinput list, than find line with AT Translated Set 2 keyboard.
Then xinput list-props 'AT Translated Set 2 keyboard' or using id (14 for example) xinput list-props 14.
Find Device Enabled and xinput set-prop 'AT Translated Set 2 keyboard' 'Device Enabled' 0 or using id xinput set-prop 14 134 0.
| Uppercase input turns on periodically |
1,583,864,375,000 |
I have a linux box with two keyboards, two displays, and one mouse. One of the displays is running an X session, and the other is running a text console, started by mingetty. Currently, the mouse is used by X, one of the keyboards is used only by the text console, but the other keyboard sends input to both the X session and the text console.
Is there any way to have the second keyboard send input to only the X session?
|
Simplest way is probably to write an xorg.conf and configure the "other keyboard" with option GrabDevice as true. This will make sure the kernel input layer only outputs events from this device to X, which means the console won't see them.
You can test the effect of the grab with evtest --grab /dev/input/... (which will make evtest grab it, of course).
See man evdev for details, see Inputclass and Inputdevice in man xorg.conf on how to match your keyboard using hardware ids (or google, there are plenty of tutorials).
| Can I prevent keyboard input from being used by console? |
1,583,864,375,000 |
I want to redefine keybindings for the commandline of a lisp dialect. The commandline is actually modeled after Vi and implemented with tput/terminfo. I want an alternative version with Emacs keybindings, and I would like to give it a try without using gnu readline or so.
A typical key assignment looks like this:
(setq *XtF1 (in '("tput" "kf1") (line T)) ...
This question is about the
("tput" "kf1")
part, ignore the rest.
Now, "kf1" is easy to find in the terminfo man-page:
key_f1 kf1 k1 F1 function key
I find there 3 entries for "meta" too:
has_meta_key km km Has a meta key
(i.e., sets 8th-bit)
meta_off rmm mo turn off meta mode
meta_on smm mm turn on meta mode
(8th-bit on)
But how can I use this info to define typical Emacs keybindings like e.g. M-f, M-b, M-d etc. with tput?
|
terminfo is probably not going to help you much. In most terminal emulators, you can configure with M-x sends <Esc>x or x with the 8th bit set, and the terminfo entry won't magically be updated when the user does so.
Also, most character sets are 8bits now, so it doesn't make much sense nowadays to use that 8th bit for Meta.
I would just hardcode M-x == <Esc>x (the sequence of two characters \033 and x). This way, even if the terminal doesn't support that mode, the user can still type Esc, x in sequence.
| How to use the Meta/Alt Key with tput? |
1,583,864,375,000 |
I've currently got Fedora 9 on my home PC (yes, I know its quite old - but hell I only reboot it every 6 months - nevermind upgrading!) . My only niggle is that keyboard I've got has quite a different feel / lyaout to the one I use everyday in work. To make life a bit simpler, I tried to enable the audio feedback. I first tried the setting in KDE (4.2) System settings - to no avail. I also tried 'xset c 100' but still nothing. The ALSA inerface seems to have no problems producing audio output from mplayer, xine, amarok.... and kmixer works as expected.
Looking at the Xorg man pages there's nothing obviously jumping out here. Any ideas?
|
X11's keyclick setting is primarily meant for the keyboard's on-board speaker. Many workstations without audio devices had keyboards with a speaker and simple audio device on-board. It played the keyboard bell noise (hence the name), and also clicked. The keyboards could be instructed to turn keyclick on or off, and some even had volume settings. Sun Type 3/4/5 keyboards certainly did this (even on Sun workstations with audio). I can't speak about others.
PC keyboards don't have sound capability, and it's almost certain the X PC keyboard driver doesn't use the PC speaker device for this. xset c has never worked for me for as long as I've used X11 on PCs (since the days of Linux 0.99).
| Xorg key clicks? |
1,583,864,375,000 |
I have a physical MIDI keyboard that also features some control keys, such as "play" and "stop". When pressed, they send the MIDI codes 115 and 116 respectively over the MIDI bus. Is it possible to hook up these commands to the usual media controls (play and pause) of Linux, so that when I press "play", the playback starts?
Is it furthermore possible to hook up other MIDI keys (e.g., up/down) to their respective keyboard counterparts (e.g., arrow up/down)?
|
In the comments, dirkt suggested to write a custom program. So, I wrote a short working proof of concept script in Python that reads inputs from a MIDI controller and then simulates the required key press. I tested it on Ubuntu 20.04. Unfortunately, it requires superuser privileges to run, otherwise /dev/uinput cannot be opened for writing.
import mido
from evdev import uinput, ecodes as e
def press_playpause():
"""Simulate pressing the "play" key"""
with uinput.UInput() as ui:
ui.write(e.EV_KEY, e.KEY_PLAY, 1)
ui.syn()
def clear_event_queue(inport):
"""Recent events are stacked up in the event queue
and read when opening the port. Avoid processing these
by clearing the queue.
"""
while inport.receive(block=False) is not None:
pass
device_name = mido.get_input_names()[0] # you may change this line
print("Device name:", device_name)
MIDI_CODE_PLAY = 115
MIDI_VALUE_ON = 127
with mido.open_input(name=device_name) as inport:
clear_event_queue(inport)
print("Waiting for MIDI events...")
for msg in inport:
print(msg)
if (hasattr(msg, "value")
and msg.value == MIDI_VALUE_ON
and hasattr(msg, "control")
and msg.control == MIDI_CODE_PLAY):
press_playpause()
Requirements:
evdev
mido
python-rtmidi
python-uinput
| Use MIDI signals for media control |
1,583,864,375,000 |
I'm having a very specific problem, however any help will aid in understanding X's relationship to the keyboard.
I'd like to be able to launch the ElectricSheep program on top of music playing from XBMC. I've already got the launch script set up, and I can launch ElectricSheep with no problems.
The problem occurs when I try to close it. If I launch ElectricSheep without XBMC running, pressing escape closes it. If XBMC is running (or even if I include a line in the script to kill xbmc before launching), it grabs all keyboard input making my only route out of ElectricSheep to either kill it from an ssh session or kill X itself.
If I run xev while XBMC is running, it recieves no input.
Is there any way to launch an application and explicitly give it the X keyboard? Thanks for any help!
|
Depends on which application has the 'focus'. I prefer 'focus follows mouse', so whatever window my mouse is over, is where my keyboard presses are going to register. Other modes are 'click to focus' and some variations on 'focus under mouse'. Microsoft Windows is "Click to Focus" (as an example), although if you play with some of the tweakui tools, you can obtain 'focus follows mouse' if you desire.
I'm not sure what mode your X-windows desktop is in initially, I THINK it's usually 'click to focus' by default, you'd have to check yours, my setup for mouse focus is under 'window behavior' in system settings, KDE 4.7.4)
I'll admit I don't have much experience with Electric Sheep (dreaming screensaver, right?) and XMBC (media center, IIRC). Both of those seem like they'd want to be full-screen apps, which could present problems because of the loss of focus. Almost sounds like a problem with ES, since if it's in the foreground (having taken over as a screensaver...) it SHOULD capture any keystrokes and use that as an abort signal to quit, returning your screen to anything else running.
You might try ALT-TAB to flip between the various apps you've got running, which should rotate focus between them, it sort of depends on how XMBC & ES are being used, whether windowed or full-screen.
You CAN control focus command-line-wise using several programs, of course, I've gone blank... looking through my /bin directories and my notes to find them. I wrote my own control programs a few months ago for a project, seeing what I could do programmatically to control windows and focus...
ah, here's one:
wmctrl, man page says you can raise a window using the '-R' option...
There's another that I found more useful, although I'm totally at a loss to name it today, maybe someone will know what I'm hinting at and post it. I'll keep looking though, evidently my blonde is kicking in hard today.
| how to deal with keyboard-greedy apps |
1,583,864,375,000 |
I recently installed awesome on my ubuntu oneiric, a nice window manager. This doesn't seem to inherit the keyboard settings that were set in the Unity settings.
Now, the problem is, I can't seem to find the correct keyboard layout to set (using setxkbmap). The control panel in Unity just states "US", bet with
setxkbmap -layout us
some keys don't work correctly on my macbook pro 8,2. Does anyone here know the correct settings?
|
The point was that the mac us keymap (setxkbmap -layout us -variant mac) had some keys at the wrong spot.
I edited /usr/share/X11/xkb/symbols/us, where it seemed that the TLDE and LSGT key are switched in the mac section. Loading setxkbmap -layout us -variant mac does the trick now.
| setxkbmap for macbook pro (US) |
1,583,864,375,000 |
When I type the key sequence oun quickly, the key sequence oun<F12> is emitted by my keyboard.
(Update: actually, you must press-and-hold each key in the sequence in order to trigger the problem. If the 'o' is released before pressing 'u', the problem does not trigger).
I first noticed the problem when typing into a website using Google Chrome, and noticed that the developer console would randomly pop up while typing. I didn't figure out the specifics until I was typing into vim and suddenly an <F12> appeared in my text.
A few minutes of experimentation yielded the following:
This is 100% reproducible, every time
It is triggered specifically by the key sequence "oun"
The first key must still be depressed by the time you hit the third key. Releasing each key before pressing the next does not trigger the problem (this is why you only encounter the problem when typing quickly).
As a developer, this seems like a straight-forward problem to solve (if you see these four inputs in sequence, drop the fourth). However, I have no idea where to start: what low-level input stream filtering is available on Linux, or how to go about hacking device drivers and such.
My question is, where would I implement a change like this? In the kernel? It there a keyboard input processing mechanism which accepts filters?
Additional details:
This is on an HP ProBook 4530s (a business laptop from 2011). I'm running Debian 8 in a VirtualBox VM on a Windows 7 host. I haven't yet booted into Knoppix to verify the problem still exists in a 100% pure Linux environment, but I'm pretty confident this is problem is happening below the level of the OS.
Someone else reported the exact same problem (the same sequence of keys) back in 2012 with a brand new 4530s: http://www.tomsguide.com/forum/75276-35-keys-activate-typing-help
UPDATE:
I booted the 4530s using Knoppix and ran xev to confirm that this is a hardware issue. Here's an excerpt of the output, where you can see the oun<F12> sequence: https://gist.github.com/cellularmitosis/018d822e5ccc5c1a64e6
UPDATE 2:
Well, I got lucky and a BIOS update was sufficient to solve the problem. See http://h20564.www2.hp.com/hpsc/swd/public/detail?sp4ts.oid=5060881&swItemId=ob_146941_1&swEnvOid=4059
I'm accepting Dmitry's answer because that's what I would have tried next had the BIOS update not solved the problem.
|
There's a project on GitHub called inputty which does what you're trying to achieve - it reads evdev events from real HID devices and creates uinput devices to emulate virtual HID hardware. For example, here's a qml script adds a virtual keyboard which outputs an additional x keypress after an f keypress on a real keyboard.
You should be able to implement your algorithm with this, or just drop the F12 key if you can live without it.
| Working around a buggy keyboard / hacking an input stream? |
1,471,004,309,000 |
This may seem a bit of a strange question, but it occurred to me that when typing a command such as the following, I always have to copy and paste the character from Wikipedia.
echo '5 μs' >> /tmp/Output
Is there a way to input such a character directly using an escape sequence on keyboard shortcut on a standard English keyboard?
For example, in Vim, one can do C-k,m* to produce this character.
|
Yes, there are at least this four (five?) ways:
AltGr
Make your keyboard layout English (international AltGr dead keys).
Then the right Alt key is the AltGr key. Pressing AltGr-m will generate a µ. Many other keys also generate other characters: AltGr-s for ß, and Shift-AltGr-s for §.
There is a separate keyboard layout for the console (the true consoles at AltCtrlF1 up to F6) and one for the GUI in X. Changing either depends on your distro (CentOS, Fedora, Debian, etc.) and Display manager (gnome, kde, xfce, etc.). For example, installing xfce4-xkb-plugin will allow a button on a panel to configure the keyboard and switch between several keyboard layouts for X in XFCE.
Compose
Make some key the Compose key. Then, presing Compose, releasing it, pressing /, releasing it, and then u will generate a µ.
Defining a Compose key is usually done with xkb or with a keyboard layout applet.
For example, in Gnome usually available at Region & Language section, or maybe, Switch Keyboard Layout Easily.
Unicode
There is a generic way to type any Unicode character (if your console supports it). Yes any codepoint of the 1,111,998 possible characters (visible if your font(s) could draw them). Press, as one chord (at the same time) ShiftCtrlu, release them (Probably, an underlined u̲ will appear), then type b5 which is the Unicode codepoint (always in Hex) for the character. And to end, type space or enter (at least).
Readline
In a bash prompt (as you tagged the question) is possible to use readline to generate a µ (mu).
bind '"\eu": "µ"'
Or add the line:
"\eu": "µ"
to ~/.inputrc, read it with Alt-x Alt-r or start a new bash shell (execute bash) and when you type:
Alt-u
An µ will appear.
Input method
Probably too much for a short answer like this.
A mistake:
Technically, the character requested in the question was Unicode \U3bc while this answer has provided solutions for \Ub5. Yes, they are different, my mistake, sorry.
$ unicode $(printf '\U3bc\Ub5')
U+03BC GREEK SMALL LETTER MU
UTF-8: ce bc UTF-16BE: 03bc Decimal: μ Octal: \01674
μ (Μ)
Uppercase: 039C
Category: Ll (Letter, Lowercase)
Unicode block: 0370..03FF; Greek and Coptic
Bidi: L (Left-to-Right)
U+00B5 MICRO SIGN
UTF-8: c2 b5 UTF-16BE: 00b5 Decimal: µ Octal: \0265
µ (Μ)
Uppercase: 039C
Category: Ll (Letter, Lowercase)
Unicode block: 0080..00FF; Latin-1 Supplement
Bidi: L (Left-to-Right)
Decomposition: <compat> 03BC
And technically, the only valid solutions are number 3 and 4. In 3 the Unicode number could be changed from b5 to 3bc to get even this Greek character. In 4 just copy the correct character and done.
Not in my defense, but
Both b5 and 3bc have as Uppercase 39c. So, both are the lowercase of MU.
Both look very, very similar (probably the same glyph from the font):
Alternatives.
AltGr
Its quite possible and already done by changing the AltGr-g (with xkb) to:
key <AC05> { [ g, G, dead_greek, dead_greek ]};
And then typing AltGr-g m to get a true greek-mu.
Compose
The Compose table is incorrect, even the Greek Compose file (/usr/share/X11/locale/el_GR.UTF-8/Compose) lists:
<Multi_key> <slash> <u> : "µ" mu
<Multi_key> <u> <slash> : "µ" mu
<Multi_key> <slash> <U> : "µ" mu
<Multi_key> <U> <slash> : "µ" mu
Those compositions as Greek, which they are not.
The correct solution for compose is to include an ~/.XCompose for greek and reboot.
Unicode
Works as posted, with unicode number 3bc
Readline
Works as posted, change the effective character to any wanted.
| Is it possible to type μ on the bash command line without copying and pasting? |
1,471,004,309,000 |
Whenever I have to write scripts or change my .zshrc file for example, it often breaks whenever I type an " (quotation mark) -- it gets automatically converted to a italic quotation mark: “ and it doesn't get recognized by the shell when I run the script. I often have to manually copy/paste a clean quotation mark (") when writing things that are run by the shell.
I am on MacOS Catalina 10.15.6, using zsh.
Any idea on how to solve this?
|
These aren't italic, they're the "typographically correct" open- and close-quotes. But they are pretty useless in a shell
To disable them globally:
System Preferences > Keyboard > Text > uncheck "Use smart quotes and dashes"
To disable them in-application, if the menu is available, deselect "Smart Quotes" in the Edit > Substitutions menu of your application
| MacOS quotation marks turning italic and breaking scripts |
1,471,004,309,000 |
I find myself using the irony mark ⸮ unicode U+2E2E (or ؟ unicode U+061F) in both mcabber and vim a lot. The old copy-and-paste antipattern is tedious so I thought I would rename one of the many useless keyboard keys I have to print it. So, my question is three-fold (but really the same question):
How to do it in mcabber?
How to do it in awesome? Since that's the window manager I use, it should work for all application, right?
How to do it using xmodmap or some other arcane X11 incantation?
Note that in vim this is trivial, just add map! ;; ⸮ in your ~/.vimrc file so in insert mode all you need is to type ";;" to get it replaced.
|
The best way to do it is in the keyboard configuration.
I don't know if you can set a custom shortcut to print the character in your jabber client, but then it would be just for that application. As for Awesome : it's a window manager, so it's not its job.
How to input it (or any unicode character) in some (GTK at least) applications :
Ctrl+Shift+U then 2E2E (the hexadecimal code).
How to configure the keyboad to get it elsewhere too :
xmodmap is one way, but it's being deprecated in favor of Xkb even if Xkb configuration can look more complex. But you asked for arcane incantations :D
setxkbmap -print prints the keymap in use. You can send that into a file to use it as base for your new keymap. (Skip to exemple below for the quick version of "how").
xkbcomp is an utility that can be used to compile and send a keymap to the X server.
xkbcomp $DISPLAY keymap.dump will dump the current configuration in the file keymap.dump. It's quite long as it is the same as previously, but with the values obtained from combining the included elements. It can be useful to look up the names that are given to the keys. We need the name to assign another symbol to a key. You could also modify and use it directly, but you can also use the includes and just redefine what you want. The include are files in /usr/share/X11/xkb/, in directories corresponding to the sections.
The keymap file has multiple sections :
xkb_keycodes: the part that maps keyboard X keycodes to a key name used in other sections. You can get the X keycode with xev and find the associated name in this part.
xkb_types : the part that describe types and which level correspond to which keyboard modifiers (Shift, Control, Alt, any combination of those, etc ..)
xkb_compatibility : For "applications that aren't Xkb aware", from what I've read .. I'm not sure what goes here.
xkb_symbols: the part that maps the key names to keysyms, and the one where we'll rewrite one of the definitions to add that unicode character. You can see the current definition of the key you want to use.
xkb_geometry: the physical keyboard shape .. not sure what uses that.
If you look at key definitions in the dumped keymap, you'll see they have an associated type. The type of the key determine which modifiers are available and corresponding to which level. The combination of key and level correspond to a keysym. The type is one defined in the xkb_types section.
If you don't specify another type when redefining the key, it will be the one defined in the included xkb_symbols map.
If I take for example my I key, there are four levels, corresponding to : just the key, key + Shift, key + AltGr, key + Shift+AltGr.
For the group, if you aren't using more than one layout (in your keyboard configuration), you probably have just one, and don't need to specify it. (You can use multiple groups to switch between key definitions associated with that group).
Here is an example of modified keymap file :
xkb_keymap {
xkb_keycodes { include "evdev+aliases(azerty)"};
xkb_types { include "complete"};
xkb_compatibility {include "complete"};
xkb_symbols {
include "pc+fr+inet(evdev)"
key <AD08> {[ i, I, U2E2E, idotless]};
key <AD09> {[ o, O, oslash, U262F]};
};
xkb_geometry { include "pc(pc104)"};
};
With this keymap AltGr+I gives ⸮ and Shift+AltGr+O
gives ☯.
To set the keymap :
xkbcomp mykeymap.xkb $DISPLAY
The Archlinux wiki have more details, and some other links at the end.
| Remapping a keyboard key to print ⸮ (irony mark) |
1,471,004,309,000 |
I have user account on a linux machine which I do not know its exact IP address. But I know a range which it is ran on one of them.
I want to check which server is my desired server. There are some Microsoft servers, some Linux servers and some servers that are down as well.
I have a shell script to check each server:
#!/bin/sh
for i in $(seq 1 127)
do
echo "192.168.1.$i:"
ssh 192.168.1.$i -l user_name
done
This code goes to each IP. If it ran ssh, it prompts for password, if ssh did not run, it tries the next ip and if server is down, it waits for a long time. Also if the server has ssh and prompts for a password, I can not escape from it by keyboard from such a server.
How can I escape from these two types by keyboard and go to the next IP without terminating the program?
For example CTRL + C terminates the program.
|
Ctrl-C sends the SIGINT signal to all the processes of the foreground job of your interactive shell. So that sends it to the sh running the script and ssh.
You can make it not kill the shell by adding a:
trap : INT
to the beginning of your script.
You may also want to use the ConnectTimeout option of ssh:
ssh -o ConnectTimeout=2 ...
Note that you're giving away your password to all those machines you're trying to connect to. Not a good idea if you don't trust their administrators.
| Continue for loop by keyboard |
1,471,004,309,000 |
I am using XFCE Terminal emulator 0.4.8.
My ~/.inputrc file:
# Insert Key
"\e[2~": paste-from-clipboard
"\C-v": paste-from-clipboard
"\e[A":history-search-backward
"\e[B":history-search-forward
"\M-[3~": delete-char
When I click <Del> a tilde is printed instead of deleting the next character. When I remove .inputrc file, it starts working correctly. Googling showed, that this line:
"\M-[3~": delete-char
has helped people to cure this. But not me. I inserted this line into .inputrc, even deleted all the other lines. Doesn't work.
How to fix?
|
The line
"\M-[3~": delete-char
is incorrect because it tells bash to look for the meta character for [, which (according to bash) could be the escape character followed by [, or it could be the character formed by OR'ing [ with 0x80, i.e., 0xdb which is Û
The actual key would use just the escape character, so you should use this setting:
"\e[3~": delete-char
| Tilde when clicking <Del> key |
1,471,004,309,000 |
I'm trying to remap the Scroll Lock key so it produces the keycode of any of the Windows keys.
First of all, I dump the current keymap:
xkbcomp $DISPLAY original-dump
Then find the keycodes of the keys I'm interested in:
cat original-dump | grep SCLK
<SCLK> = 78;
cat original-dump | grep LWIN
<LWIN> = 133;
Now I print the component names into a file:
setxkbmap -print > original-components
Edit the file to add my keycode modification:
xkb_keymap {
xkb_keycodes {
include "evdev+aliases(qwerty)"
// Remap Scroll-lock to the keycode of LWIN(133)
<SCLK> = 133;
};
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+us+inet(evdev)" };
xkb_geometry { include "pc(pc105)" };
};
Saved the file above as modified-components and run:
xkbcomp modified-components $DISPLAY
Dump again:
xkbcomp $DISPLAY original-dump
Check the keycodes:
cat another-dump | grep SCLK
<SCLK> = 133;
So far so good, but when I run xev, the keycode of the Scroll Lock key is still 78.
If I run:
xmodmap -e "keycode 78 = Super_L"
xev still shows me 78, but at least the shortcuts that I created in XFCE for the LWIN and RWIN work.
I would like to know what am I doing wrong with xkb. Thanks.
|
Tried the following new approach (with success)
Created a new file named sclkfile in the /usr/share/X11/xkb/symbols/ directory, and added the following contents:
// Make the Scroll Lock key a left Super.
xkb_symbols "sclk_super" {
replace key <SCLK> { [ Super_L ] };
modifier_map Mod4 { <SCLK> };
};
Added the new rule in /usr/share/X11/xkb/rules/evdev:
sclkoption:sclk_super = +sclkfile(sclk_super)
And descriptions of the rule in /usr/share/X11/xkb/rules/evdev.lst:
! option
sclkoption Scroll Lock behaviour
sclkoption:sclk_super Scroll Lock is Super
Here too /usr/share/X11/xkb/rules/evdev.xml:
<configItem>
<name>sclkoption</name>
<description>Scroll Lock behaviour</description>
</configItem>
<option>
<configItem>
<name>sclkoption:sclk_super</name>
<description>Scroll Lock is Super</description>
</configItem>
</option>
Finally run:
$ setxkbmap -option sclkoption:sclk_super
No errors, and when I print the components of my layout:
$ setxkbmap -print
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+us+inet(evdev)+sclkfile(sclk_super)" };
xkb_geometry { include "pc(pc105)" };
};
The new rule is there.
Now, if I run xev:
keycode 78 (keysym 0xffeb, Super_R)
The keycode is still 78 but the keysym is Super_R. Success.
| Remapping a key for XKB |
1,471,004,309,000 |
I am using Gentoo and dwm. My keyboard is configured with the command
setxkbmap us -variant alt-intl
but whenever I need to use double or single quotes or cedilla, I need to press the alt key.
How can I configure my keyboard so I don't have to press alt, just the quote key?
|
Check if the dead_acute is set:
xmodmap -pke | grep dead_acute
Else, get the keycode: xev
And set the flag with:
xmodmap -e "keycode 48 = dead_acute dead_diaeresis dead_acute dead_diaeresis apostrophe quotedbl apostrophe"
Put this in your ~/.XCompose:
include "%L"
# Overriding C with acute:
<dead_acute> <C> : "Ç" Ccedilla # LATIN CAPITAL LETTER C WITH CEDILLA
<dead_acute> <c> : "ç" ccedilla # LATIN SMALL LETTER C WITH CEDILLA
And this in your ~/.xinitrc:
export GTK_IM_MODULE=xim # Make compose key work
export QT_IM_MODULE=xim
| How can I use quotes and cedilla without having to press the right alt key in the international American keyboard layout? |
1,471,004,309,000 |
When using a TTY login shell by entering e.g. Ctrl+Alt+F1 on Debian Jessie. There is an inhuman fast delay, specifically, these values are set (250ms):
root@VB-NB-Debian:~# kbdrate
Typematic Rate set to 10.9 cps (delay = 250 ms)
vlastimil@VB-NB-Debian:~$ sudo kbdrate
Typematic Rate set to 10.9 cps (delay = 250 ms)
I don't understand, since I have a "normal" 810ms set in my KDE system. Still, in Xterm the kbdrate says I have a delay of 250ms set.
Anyway, this is not the point. I need to permanently change the delay for all TTYs. Can you help me with that?
I found this: Adjusting keyboard sensitivity in a command line terminal? but it doesn't guide me. What exactly shall I do?
So, the question is, how to set the delay (not interested in the rate) once and for all?
|
I think the kbdrate program only affects the rate in the Linux console outside of X windows and I think has to do with the BIOS keyboard repeat rate. The program you can use from a terminal in X windows to set the one that will control X windows terminals like Xterm is called xset. Use it like this:
xset r rate 810 30
I don't use KDE so I'm not sure if this really works in KDE, but it works in Xfce.
| Adjusting keyboard delay in a TTY? |
1,471,004,309,000 |
It is bound to menu-complete in GNU readline.
$ bind -p|grep menu
"\e[Z": menu-complete
# menu-complete-backward (not bound)
# old-menu-complete (not bound)
I think it's Meta-something.
|
Look in the terminfo database for your terminal for the key that sends this escape sequence. The infocmp command dumps the terminfo entry for the current terminal.
$ infocmp | grep -oE ' k[[:alpha:]]+=\\E\[Z,'
kcbt=\E[Z,
The terminfo man page explains what cbt is the abbreviation of. (It also gives an example which corresponds to most terminals out there.)
$ man 5 terminfo | grep -w kcbt
key_btab kcbt kB back-tab key
kbs=^H, kcbt=\E[Z, kcub1=\E[D, kcud1=\E[B,
So you have it: \e[Z is backtab, i.e. Shift+Tab (on most terminals).
| How do I generate the sequence "\e[Z" in a terminal? |
1,471,004,309,000 |
Is it possible to assign mouse keys (left click 1, middle click 2, right click 3, etc) to keyboard keys by modifying a file in /etc/X11/xorg.conf.d? If so, how can I do that?
|
I had thought someone told me or I heard somewhere that xorg by default supports keyboard driven mouse emulation out of the box. The movement, etc. is bound to the numpad keys. This article I dug up quick seems to indicate I have heard correctly. No direct experience, so this may be incorrect.
See http://en.linuxreviews.org/HOWTO_use_the_numeric_keyboard_keys_as_mouse_in_XOrg
| Assigning mouse keys to keyboard |
1,471,004,309,000 |
I may be abusing the word console but I mean the mode without X i.e. pressing ^+Alt F1 and then log as other user where I want to use my chosen layout with USB keyboard.
X works, it configures the new USB keyboard to my choice when I plug it in. But the console keyboard layout is stuck to the setting specified by the kernel. I am trying to change that:
# usbhidctl -f /dev/uhid0 -w keyboard.encoding=us
usbhidctl: Failed to match: keyboard.encoding
Some info about the OpenBSD version:
# uname -rv
4.7 GENERIC.MP#449
|
Does
wsconsctl keyboard.encoding=us
work?
If yes, put that in /etc/wsconsctl.conf to make it persistent.
Or are you saying that that would only work for PS/2 keyboards? Maybe enabling USB legacy keyboard mode in the BIOS would help in that case?
wsconscfg -k
may also be of use.
Perhaps you need to change the device from
/dev/uhid0
to something like
/dev/wskbd0
or
/dev/wskbd1
| How to change the USB keyboard layout in an OpenBSD console? |
1,471,004,309,000 |
A few weeks ago, I decided to clean up my keyboard and ended up messing up a few keys as I was snapping them back onto the board. As a result, some characters have become annoyingly difficult to enter... And obviously I use a few of said characters in my password.
I am planning to replace my keyboard of course, but in the meantime, having to go through 4-5 login attempts a day on my ttys is starting to get on my nerves (I don't use a desktop manager).
I've managed to alleviate the issue a bit by setting pwfeedback in my sudo config. This allows me to "see" whenever my keyboard skips a character. However I couldn't find a similar option for the agetty and login combo.
Is there a way to activate password feedback for the tty login prompts?
|
Alright, to the source code we go!
util-linux's login program is in charge by the time my login prompt appears. Let's start there, more specifically in the login-utils/login.c file.
Now, login appears to be in charge of the login prompt, since it generates it in loginpam_get_prompt and registers it with PAM in init_loginpam. The loginpam_auth function then takes over, and control goes to PAM's pam_authenticate function. This means that login merely defines a prompt for the username and that's it.
To PAM then: what we're interested in clearly happens in pam_authenticate :
The pam_authenticate function is used to authenticate the user. The user is required to provide an authentication token depending upon the authentication service, usually this is a password, but could also be a finger print.
Now, shadow-based authentication (/etc/passwd, /etc/shadow) is handled by the pam_unix module. My distribution (Arch) provides PAM through the pam package, which means our journey continues over to linux-pam.org and its source code. modules/pam_unix/pam_unix_auth.c seems a good place to start. PAM modules provide their authentication mechanism through a pam_sm_authenticate function, which we find here. The password (or "authentication token", see above) is fetched with a call to PAM's pam_get_authtok function. It is declared in the security/pam_ext.h header file, so that's where we're going next.
extern int PAM_NONNULL((1,3))
pam_get_authtok (pam_handle_t *pamh,
int item,
const char **authtok,
const char *prompt);
Nothing too promising in those arguments but well... Let's see the definition. pam_unix passed NULL for the prompt argument and PAM_AUTHTOK for item, so we end up here. Now that hardcoded PAM_PROMPT_ECHO_OFF given to pam_prompt just doesn't look good for me...
retval = pam_prompt (pamh, PAM_PROMPT_ECHO_OFF, &resp[0], "%s", PROMPT);
By the way, the password PROMPT is also hardcoded (here), so there goes my dream of a more exotic password prompt... Anyway, let's go over to the pam_prompt function. The actual prompt happens here, where PAM calls a conversation function fetched a few lines above. A quick look at the pam_get_item and pam_set_item functions introduces us to the pam_conv structure defined here.
Now, finding information on the default PAM conversation function was a lot trickier than it should be (I think). Everywhere I looked, the structure remained uninitialised and pam_unix does not appear to define its own. However I managed to find the generic misc_conv function, which passes PAM_PROMPT_ECHO_OFF over to read_string and... here's where PAM deactivates input feedback.
Conclusion: the absence of password feedback is hardcoded. Too bad. A little digging got me to this GitHub issue and this Arch BBS thread. Apparently, the feature was available back when PAM wasn't a standard for authentication. I guess it makes sense not to have implemented it again - security and all - but you know, an option would have been nice.
Anyway, I've just ordered my new keyboard.
| Can I activate password feedback on a tty? |
1,471,004,309,000 |
CentOS 6.2, 2.6.32-220.el6.x86_64 laptop. SysRQ is enabled for keyboard input, as is witnessed by:
$ cat /proc/sys/kernel/sysrq
1
Common Magic SysRQ Keys are working such as alt-sysrq-h. However, other keystrokes do not appear to be working. Most notably, alt-sysrq-b for rebooting. However, I can get the reboot SysRQ option to work via echo "b" > /proc/sysrq-trigger
I realize that /proc/sys/kernel/sysrq does not need to be enabled in order for echoing options to sysrq-trigger to work, so I'm assuming that there's some problem with the Magic SysRQ key combination actually being signaled.
What would be causing the inability for some SysRQ keystrokes to work, but others not? And yet manually sending the option to sysrq-triggers will work?
EDIT 1
Shamefully, I left out some information in the above question. Yes, I'm using a laptop, but I'm also using an external keyboard. I don't think I've used the built-in keyboard on my Dell XPS 1530 for years so it didn't even register in my mind that the keyboard situation could be part of the issue.
On the Dell XPS 1530's built-in keyboard, the SysRQ key is technically a function key. "SysRQ" is printed in blue to signal that a person, theoretically, should press the Fn key to access it. However, when using the built-in keyboard, you merely have to press the standard alt-sysrq-b combination to cause a reboot! No function key required.
My external keyboard is a Logitech Illuminated Keyboard, and it has its own FN key on it. However, SysRQ is not apparently mapped as an alternate key. I say "apparently" because SysRQ isn't actually printed on any of the keys. Instead, I assumed that Print Screen was the SysRQ key because that's what SysRQ has shared a key with in recent years. That seems to have been a fair assumption because, as I tested things out, most Magic SysRQ key combinations work using that key as SysRQ.
Nevertheless, I've tried a plethora of combinations using the external keyboard, and none of them seem to work with the re[B]oot Magic SysRQ key. I know alt works and I know print screen works as the SysRQ key without need for the function key on the external keyboard. It just appears, at this moment anyway, that the b key is not being sent as be. Is there any way that I can see what key code is being sent to my terminal as I type on a keyboard?
|
On a typical laptop, you need to press the Fn key to press SysRq. If you also press the letter in the same movement, you end up pressing Fn+Alt+SysRq+letter. But several letters are mapped to numeric keypad keys when combined with Fn. For example, if you try to press Alt+SysRq+U, you end up pressing Alt+SysRq+Num4 instead.
To avoid this pitfall, press and hold Alt, then a press and release SysRq (using Fn if necessary), then press and release the magic SysRq function letter, and finally release Alt. For example: hold Alt, hold Fn, press and release Del, release Fn, press and release U, release Alt.
I'm not sure if that's your problem, as B is typically not a numpad key on laptops. It may be a vendor-specific key; if Fn+B is not equivalent to plain B, then you need to release Fn mid-sequence.
| sysrq won't reboot with a keystroke, but will with echo "b" > /proc/sysrq-trigger |
1,471,004,309,000 |
I'm using a computer running Ubuntu and I'm connected through ssh to a RedHat machine where I use Matlab in command line mode (matlab -nodesktop). Matlab version is 7.10.0.499 (R2010a).
My problem occurs when I type any key which produces "special characters", such
as ñ, á, etc...
I managed to solve this, by setting this alias to matlab:
alias mat 'xmodmap -e "keycode 47 = Escape" -e "keycode 34 = Escape"; matlab -nodesktop; setxkbmap;'
...but this solution makes these changes globally, and I cannot type those characters (as long as matlab is running) in any other application including terminals, browsers, etc.
I read that this is a problem for this version of Matlab, but in that case,
a new question arises: if I use xmodmap in a terminal (xterm) connected to
other machine, why are those changes spread globally to my session?
|
Check if your locale settings match on the local and remote machine: run echo $LC_CTYPE in a local terminal and in an ssh session. If they don't match, try again with Matlab with LC_CTYPE set to the correct value. If that doesn't work, try with export LC_CTYPE=C or with export LC_CTYPE=en_US (shot in the dark, I don't know the nature of the bug with Matlab).
If you're in a UTF-8 locale, try in an 8-bit locale such as latin1:
LC_CTYPE=en_US luit ssh redhat-host
If fiddling with locales doesn't help, try something more radical: run stty istrip in the terminal before starting Matlab. This strips the 8th bit off the characters you type. When you enter an accented letter, Matlab will receive a garbage ASCII character, but nothing that should confuse it. Note that you should do this in addition to switching to a latin-1 locale such as en_US; in other locales, in particular in UTF-8, the garbage characters can be control characters.
There are a lot of stty settings, but I can't think of one that would just cause non-ASCII characters to be ignored. If you experiment with stty, you can revert to sane defaults with stty sane. The changes are local to a terminal.
| Matlab gets "crazy" after type special characters |
1,471,004,309,000 |
I've seen several other posts similar to this issue, but I've not had luck implementing a solution. If someone can find an existing post that resolves this issue, I will gladly mark this as a duplicate.
I'm not exactly sure on the timing, but perhaps within the past week or so, the equal key no longer types the equal sign (=). I have to copy and paste it to write this post.
The same symptoms extend to the onboard keyboard as well (not to be confused with the virtual keyboard which doesn't seem to have an equal key), so it's certainly not a hardware problem.
Shift + equal key still types the plus sign (+), but no key combination on the physical keyboard results in the equal sign (=) in web browsers and most other applications. The two exceptions with the physical keyboard I've found so far is with the GNOME Terminal. In the terminal, the combination of Ctrl or Windows key and equal key results in the equal sign. In addition, the Windows key and equal key types an equal sign in most text editors (LibreOffice Writer, Visual Studio Code, Xed text editor).
I can also use the equal key normally without a modifier key when in tty (Ctrl + Alt + F2). It's only within Cinnamon that I have the issue.
I only have one keyboard layout - English (US).
System Specs:
System:
Host: {HostName}
Kernel: 5.3.0-28-generic x86_64
bits: 64
compiler: gcc
v: 7.4.0
Desktop: Cinnamon 4.4.8
wm: muffin
dm: LightDM
Distro: Linux Mint 19.3 Tricia
base: Ubuntu 18.04 bionic
Machine:
Type: Laptop
System: Acer
product: Aspire A717-72G
v: V1.19
serial: <filter>
Mobo: CFL
model: Charizard_CFS
v: V1.19
serial: <filter>
UEFI: Insyde
v: 1.19
date: 07/13/2018
There was a kernel update in the past few weeks. I have avoided rolling back the kernel to the previous version because I didn't want to start grasping at straws and getting myself into worse trouble, so I thought I'd post this first.
Updates:
This is exactly the issue I'm having, but this issue is in Windows.
I have rebooted several times and I have checked multiple modifiers multiple times for stuck keys, but to no avail. I messed with this for days before finally deciding to post the issue. If it was as simple as a reboot or stuck key, I would expect to have seen that resolve by now.
Using xev the following is revealed (I'm new to xev and still learning what this means):
Equal Key:
KeymapNotify event, serial 28, synthetic NO, window 0x0,
keys: 66 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Example of All Other Keypresses I tried (i.e. Shift + equal key):
KeyPress event, serial 28, synthetic NO, window 0x7800001,
root 0x242, subw 0x0, time 11019227, (-650,-317), root:(211,139),
state 0x10, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 28, synthetic NO, window 0x7800001,
root 0x242, subw 0x0, time 11019779, (-650,-317), root:(211,139),
state 0x11, keycode 21 (keysym 0x2b, plus), same_screen YES,
XLookupString gives 1 bytes: (2b) "+"
XmbLookupString gives 1 bytes: (2b) "+"
XFilterEvent returns: False
KeyRelease event, serial 28, synthetic NO, window 0x7800001,
root 0x242, subw 0x0, time 11019879, (-650,-317), root:(211,139),
state 0x11, keycode 21 (keysym 0x2b, plus), same_screen YES,
XLookupString gives 1 bytes: (2b) "+"
XFilterEvent returns: False
KeyRelease event, serial 28, synthetic NO, window 0x7800001,
root 0x242, subw 0x0, time 11020216, (-650,-317), root:(211,139),
state 0x11, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
The equal keypress registers as a KeymapNotify event rather than a KeyPress event. When specifying xev -event keyboard, the equal keypress (KeymapNotify event) results in the same output as when my mouse cursor crosses the xed window.
Interestingly, using a modifier other than Shift (e.g. Windows/Super, Ctrl, or Alt) + equal key results in an xev response indicating the equal sign:
KeyPress event, serial 28, synthetic NO, window 0x7800001,
root 0x242, subw 0x0, time 11051562, (-650,-317), root:(211,139),
state 0x10, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 28, synthetic NO, window 0x7800001,
root 0x242, subw 0x0, time 11051836, (-650,-317), root:(211,139),
state 0x18, keycode 21 (keysym 0x3d, equal), same_screen YES,
XLookupString gives 1 bytes: (3d) "="
XmbLookupString gives 1 bytes: (3d) "="
XFilterEvent returns: False
KeyRelease event, serial 28, synthetic NO, window 0x7800001,
root 0x242, subw 0x0, time 11051930, (-650,-317), root:(211,139),
state 0x18, keycode 21 (keysym 0x3d, equal), same_screen YES,
XLookupString gives 1 bytes: (3d) "="
XFilterEvent returns: False
KeyRelease event, serial 28, synthetic NO, window 0x7800001,
root 0x242, subw 0x0, time 11052111, (-650,-317), root:(211,139),
state 0x18, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
Using xev | gawk '/keycode/{if($0!=l)print;l=$0;}' to filter out excess data, each keypress results in a line returned except for the equal key (thought Shift + equal key does - see lines 3 and 4).
state 0x10, keycode 36 (keysym 0xff0d, Return), same_screen YES,
state 0x10, keycode 20 (keysym 0x2d, minus), same_screen YES,
state 0x10, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
state 0x11, keycode 21 (keysym 0x2b, plus), same_screen YES,
state 0x11, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
state 0x10, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
state 0x14, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
state 0x10, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
state 0x14, keycode 54 (keysym 0x63, c), same_screen YES,
state 0x14, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
It would seem that the X server isn't seeing this keypress, though the keycode is mapped:
xmodmap -pke | grep equal results in keycode 21 = equal plus equal plus.
Additional info:
$ setxkbmap -query
rules: evdev
model: pc105
layout: us
options: terminate:ctrl_alt_bksp`
|
I had the same problem in PuppyLinux where I could type ) but not the 0. I then tried another Linux distro to find it was working.
Here is how I made the mistake: I had recently added a new keybinding and mistakingly entered an invalid code (I don't remember which) but that's what interfered with the 0 character.
(Sidenote: my window manager is jwm or Joe's window manager, but actually, it does not matter which distro or window manager you use.)
Conclusion: check any new keybinding added since the trouble showed up, either from a new program setting its own keybindings or keybinding you added by
yourself.
| I suddenly can't type the equal sign (=) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.