How to have X recognize my keyboard layout? - layout

I've recently installed Arch on my machine and used Luke Smith's LARBS script to set things up. However, I don't know how to enable the question mark key (I'm using a Lenovo laptop, which has the slash, question mark and degree symbols where the right control usually is), since the key currently works as a right control. On my usr/share/X11/xkb/symbols folder there's the brfile in which there are the lines
// The ABNT2 keyboard on IBM/Lenovo Thinkpads,
// by Piter PUNK <piterpk#terra.com.br>.
//
partial alphanumeric_keys
xkb_symbols "thinkpad" {
include "br(abnt2)"
name[Group1]="Portuguese (Brazil, IBM/Lenovo ThinkPad)";
key <RCTL> { [ slash, question, degree, questiondown ] };
};
But I think Xorg doesn't recognize it or something like that. Running localectl returns the following:
System Locale: LANG=en_US.UTF-8
VC Keymap: br
X11 Layout: br
X11 Model: pc102
X11 Options: terminate:ctrl_alt_bksp

Related

Manjaro linux compose key gives incorrect behavior

I installed Cinnamon Manjaro linux on my 2017 QWERTY Macbook Air. Kernel: 5.4.27-1-MANJARO.
I've tried changing my keyboard languages, but my compose key always produces the same behavior -- that of a US (intl) keyboard. I don't know why.
I've tried setting my compose key to different things, like LWin or RAlt, no luck.
Ideally, I want the same key behavior as that on Mac. My current keyboard layout is English (Macintosh). Everything works, except for all of the compose key combos / accents, which all seem to produce US(intl) dead key outputs.
Things I've tried:
changing my keyboard layouts, from GUI to setxkbmap.
changing my compose key
manually setting the value of Option "Xkblayout" "mac" in /etc/X11/xorg.conf.d/00-keyboard.conf
Failing to understand how to manually force set the accent keys I want via xmodmap :(
Thanks for the help.
Solved: I realized that there was another keyboard which Xorg was somehow (I don't know how) set to, other than English (Macbook). I ran setxbmap -option which had the effect of "resetting" my keyboard to the layout I'd correctly chosen via the GUI.
I don't much understand how / why Xorg persisted in using another keyboard layout despite what I had entered in the GUI keyboard settings -- somehow it survived a reset through multiple computer restarts throughout these past days. But it works.

how to type at sign (#) in Linux guest operating system

I have Linux (Backtrack5) running as guest operating system in IOS.
There seems to be some problems with certain keys, I can't type the # sign.. instead, it gives 2 (in superscript).
I have tried hex (%40) but it won't compile.
I have reinstalled it with another keyboard layouts but problem reproduces.
Is there a file where i can reconfigure certain keys?
I am afraid I may sound trivial, but maybe this is your case.It might be that the keymap your system loads by default does not match the one your physical keyboard actually has.
You can change the keyboard layout you're using with setxkbmap it Return typed in a console in your graphical environment (X11), be it under KDE, GNOME, or what you have. With that command you would use an Italian keyboard layout, it looks like the two-letter code for a Danish one is da.
If you're not working with a graphical environment you can set your keyboard layout with loadkeys it Return

How to implement proper mouse support in a terminal / terminfo entry?

I've implemented a terminal emulator and a corresponding terminfo entry that allows me to run ncurses programs like emacs, mc (midnight commander) or tig (git browser). I want to add mouse support to the terminal, most notably to position the cursor in emacs by clicking into the window. After a lot of googling and some help on stackoverflow I learned about the required terminfo fields (most notably kmous) and control (e.g. \E[?1000h) and "key" (\E[M...) sequences and implemented mouse button events in my terminal. I've written a small ncurses program that goes something like this:
initscr ();
clear ();
noecho ();
cbreak ();
keypad (stdscr, TRUE);
mousemask (ALL_MOUSE_EVENT, NULL);
if (has_mouse ())
{
while (1)
{
switch (getch ())
{
case KEY_MOUSE:
if (getmouse (&event) == OK)
{
printf ("mouse event 0x%x at %i,%i\n", event.bstate, event.x, event.y);
This program works fine on xterm and my terminal, so both my terminal and its terminfo entry can't be completely wrong.
However, mc appears to not recognize mouse support in my terminal, does not even issue any \E[?1000h sequence to activate it and is therefore utterly confused by the mouse button events my terminal sends (even without \E[?1000hactivation).
What am I missing?
Someone pointed out this problem recently (though the question was not mentioned):
20181124
+ modify the initialization checks for mouse so that the xterm+sm+1006
block will work with terminal descriptions not mentioning xterm
(report by Tomas Janousek).
The problem was that the code would use the kmous capability if TERM had "xterm", and otherwise would default to the original xterm mouse protocol (which didn't have "any event" capability). That probably was overlooked for quite a while due to inertia (people using the "xterm" terminal descriptions with other terminals).
The ncurses manual page does say what's intended:
Because there are no standard terminal responses that would serve to
identify terminals which support the xterm mouse protocol, ncurses assumes that if your $TERM environment variable contains "xterm", or
kmous is defined in the terminal description, then the terminal may
send mouse events.

Solaris 10 keyboard problem

Im runing Solaris 10 - but im having problems with the keyboard.
Instead of - i get /, and instead of y i get z, etc. I tried changing every option in the menu "Keyboard Behaviour". I also tried changing kmdconfig from xorg to xsun, but then the graphics goes all wild and ugly - although the keyboard works fine then. Also cant change resolution in xsun mode.
By the way, im runing Solaris from Vmware, but i doubt this has anything to do with this.
Leave the graphic environment to the console:
dtconfig -d
dtconfig -reset
Select the correct keyboard layout you use:
kbd -s
Load it:
loadkeys
Check the keys are working properly. If okay, enable the graphical environment again:
dtconfig -e
If that still works, make that choice persistent after a reboot by updating your eeprom. eg:
eeprom kbd-type=Spanish
This should be migrated to superuser.com
It seems that you are expecting a german keyboard layout but are getting a US layout - at least the differences you are seeing are differences between those layouts. I don't know where to change that in openSolaris, but maybe it helps you find the correct place to look. Whatever desktop environment that you are using, it should have a tool to change the keyboard layout, probably somewhere with the other internationalization settings.

Making Mac shortcuts (e.g. Cmd-C) work on linux

Is there a way to map Cmd+C to Copy in linux? (instead of Ctrl+C)
Would be nice if I could also have the emacs style ones, like Ctrl+B to move left by one character.
Is there a way, on Linux/X, to map certain key combos to other key combos?
In the tradition of all open source projects, there's not a way, there are several. At the lowest level you've got kernel keybindings, which is probably not what you want. At the X server level you've got xkb with its myriad utilities. And then it seems that every window manager - gnome, kde, xfce or other - also has a keymapping utility. xkb seems to have lots of utils and such around it, and is likely more complete than any random window manager's keymapping utils, so I'd look at that first.
KDE 3 is probably the most flexible here; there's a pre-defined keyboard shortcut scheme named "Mac Scheme". You can set it through KControl Control Center > Regional & Accessibility > Keyboard Shortcuts or kcmshell keys and it will have effect on almost all KDE applications immediately. You might miss some of those Emacs-like "Ctrl-*" shortcuts that OS X has, but that aside, it works well (as long as your X modifiers are mapped correctly). And if it's not to your liking, it's easily customizable.
You can also set Control Center > Desktop > Behavior to enable a Mac OS-like menubar; all KDE applications will then share a menubar at the top of the screen instead of being individually attached to each window.
Update 02/03/2020
Kinto has now been rewritten in C for Ubuntu/Debian systems using x11. It also uses json config files, making it easier to manage and extend to other applications than just terminals. The app no longer maps to Super in the Terminal apps, it will now properly map to Ctrl+Shift to create the exact same feel as having a Cmd key.
Please checkout the latest release.
https://github.com/rbreaves/kinto
The main change to allow for the Super = Ctrl+Shift change is in this symbols file.
default partial xkb_symbols "mac_levelssym" {
key <LWIN> {
repeat= no,
type= "ONE_LEVEL",
symbols[Group1]= [ Hyper_L ],
actions[group1]=[ SetMods(modifiers=Shift+Control) ]
};
key <RWIN> {
repeat= no,
type= "ONE_LEVEL",
symbols[Group1]= [ Hyper_R ],
actions[group1]=[ SetMods(modifiers=Shift+Control) ]
};
};
Pjz's answer is correct in saying that an xkb solution would be ideal, sadly few have taken that route, most likely due to the difficulty of learning xkb and it seems many have gone the route of using Xmodmap files which is being deprecated while we are on our way to Wayland.
This answer may be several years too late, but here it is any ways.
Kinto is a tool I recently created that will address this problem and does so by using xkb and by listening to what app you are currently using, as it also changes the keymap while using terminals so the mac like experience can be consistent.
https://github.com/rbreaves/kinto
https://medium.com/#benreaves/kinto-a-mac-inspired-keyboard-mapping-for-linux-58f731817c0
Here's a Gist as well, if you just want to see what is at the heart of it all, it will not alternate your keymap when needed though. The Gist also does not include custom xkb keymap files that setup macOS style cursors/word-wise manipulations that use Cmd and the arrow keys.
https://gist.github.com/rbreaves/f4cf8a991eaeea893999964f5e83eebb
Edit: Posting the contents of the gist as well. I cannot realistically post the contents of Kinto.
# permanent apple keyboard keyswap
echo "options hid_apple swap_opt_cmd=1" | sudo tee -a /etc/modprobe.d/hid_apple.conf
update-initramfs -u -k all
# Temporary & instant apple keyboard keyswap
echo '1' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd
# Windows and Mac keyboards - GUI (Physical Alt is Ctrl, Physical Super is Alt, Physical Ctrl is Super)
setxkbmap -option;setxkbmap -option altwin:ctrl_alt_win
# Windows and Mac keyboards - Terminal Apps (Physical Alt is Super, Physical Super is Alt, Physical Ctrl is Ctrl)
setxkbmap -option;setxkbmap -option altwin:swap_alt_win
#
# If you want a systemd service and bash script to help toggle between
# GUI and Terminal applications then look at project Kinto.
# https://github.com/rbreaves/kinto
#
# Note: The above may not work for Chromebooks running Linux, please look
# at project Kinto for that.
#
# If anyone would like to contribute to the project then please do!
#
You'll get almost all of the way there if you switch Cmd and Ctrl
xmodmap -e "keycode 63 = Control_L"
That way Cmd will be Control. No other keys will be swapped
Edited: I forgot the "-e"

Resources