Ins key on a mac keyboard in Linux - linux

I am on a Linux (fluxbox/Mint) with urxvt using an external Mac keyboard. I can't find an ins key. In urxvt you can select a part of text, it automatically copies, and with other types of keyboards I could use Shift+Insert and it pastes the text. How can I paste the text with a mac keyboard running in a Linux? Needless to say, that I tried the standard variations of Ctrl+C and Ctrl+V, Ctrl+0, Shift+0, in combination with fn key.

Try Fn+Shift+return.
This works as middle-click paste under both Gnome (Wayland) and i3wm (Xorg) in Fedora 28 with my 2016 MacBook Pro 13,1 built-in keyboard (using an out-of-tree SPI driver). Hopefully it's the same situation for external Mac keyboards under other specific environments.

Maybe you can try fn + return to simulate the Insert key.
Another way, install AutoKey :
apt-get install autokey-gtk
and set a phrase to:
Phrase Text: <ctrl>+C (actually type out the <ctrl>+ here)
Paste Using: Keyboard
Abbreviation: None
Hotkey: <super>+v
Window Filter: None
If you want to use your Apple keyboard like a regular US-layout keyboard, with Alt on the left side of Meta, you can use the AUR package un-apple-keyboard. Currently it only works for the aluminium USB model.
The package does the following things:
Adds a /etc/modprobe.d/hid_apple.conf file which enables the F num keys by default, as in #Function keys do not work.
Uses keyfuzz to remap F13-15 to PrintScreen/SysRq, Scroll Lock, and Pause, respectively.
Swaps the ordering of the Alt and Meta (Command) keys to match all other keyboards, again using /etc/modprobe.d/hid_apple.conf, as in #Swap the Alt key and Command key (Meta/Super).
Applies these changes automatically when you plug in your keyboard, with a udev rule.
See more information from Archlinux wiki Apple Keyboard.

Try Fn+Opt+Return. Works for me.

Related

Using ALT+Click to select text in columns with Notepad++ (Linux)

I run Notepad++ both in Windows, and in Linux under Wine. In Windows, I can hold Alt and click/drag to select characters in a column rather than line-by-line.
In Linux, holding Alt and clicking doesn't select anything. Rather, it makes the cursor a hand tool which drags the window around.
Is there a setting to toggle on the alt-click column highlighting? I've poked around in the settings and keyboard shortcuts, but didn't find anything that looked relevant.
Thank you.
In case anyone else runs into this:
For Cinnamon desktop: go to Preferences > System Settings > Windows. Click on the Behavior tab. Change the "Special key to move and resize windows" from Alt to Disabled (or a different key).
Voila, alt-select works again in Notepad++!
(The Mint Forums answer linked above is for an older version but I have confirmed that this works on Mint 20.1 with Cinnamon 4.8.6.)

Assign Keyboard shortcut per application in Linux Desktop Environment

I would like to inquire if there is a program in Linux that we can use to assign new keyboard shortcut per application. For example, if I'm in FeatherPad I would like to assign Super+S to save. If I'm in terminal, I would like to use Super+V to paste.
Or a program that cab map/assign new shortcut and translate that to an existing shortcut. If in terminal I can paste with Shift+Insert then I would like to map Super+V to Shift+Insert
The closest analogy would be a program like Autohotkey in Microsoft Windows. How do I do this in Linux Desktop environment regardless it is Gnome2/Unity/XFCE etc. ?
There used to be a way to do this called "custom accelerators" or "editable accelerators". It used to be supported in GNOME 2 and XFCE (maybe in others). But since the move to gtk3, this functionality seems to have been removed in GTK-based desktop environments.
In KDE/Plasma, you can use System Settings -> Shortcuts -> Global Shortcuts and then the plus symbol to add specific shortcuts that only apply to certain applications, but unfortunately, not all applications support it.
In FeatherPad itself, there should be Options -> Preferences -> Shortcuts, but I've had no luck getting it to register any shortcut consisting of just Super and a key.
I'm unfamiliar with Autohotkey but it seems that AutoKey is sometimes mentioned as an alternative on Linux?

Remap one of the keyboards

I have a notebook which sometimes I use with an external keyboard. Its built-in keyboard has some keys which I'd like to remap, however, I don't want to make any changes to the external keyboard.
I am aware of this question from 2012, but I'd like to have a different solution (a more user-friend one) if possible.
I use Win 10 on an Acer Aspire E 13.
You can use SharpKeys to remap any key you want. I also use Win 10 and it work verry nice. Don't forget to restart your computer after Write to Registry.

How to emulate integrated numeric keypad cursor keys in linux

On many older laptops and some compact keyboards there is an integrated numeric keypad in the main keyboard area. This alternate keypad is activated with a special 'Fn' key next to the left Ctrl key.
As a programmer I learned to use the cursor movement keys (arrows, PgUp, PgDn etc.) and found it greatly improved my programming speed. And the benefits were not bound to just a single application as is the case with specialised shortcut keys.
On conventional PC keyboards, the 'Windows Key' can be used to emulate the 'Fn' key and a corresponding integrated numeric keypad. When I used to use MS Windows I found Autohotkey was able to map the keys using a simple script.
Recently I learned about xkb and how it can be used to map keystrokes at a very low level.
What is the xkb keyboard mapping profile that will emulate an integrated numeric keypad using the windows key as the fn key?
Hint(?): I suspect the file will look a lot like the '/usr/share/X11/xkb/symbols/keypad' file on a Debian-derivative linux distro. This 'keypad' file is included at the top of the '/usr/share/X11/xkb/symbols/pc' file.
The corresponding autohotkey script for reference (# == WinKey):
#8::Up
#k::Down
#u::Left
#o::Right
#7::Home
#j::End
#9::PgUp
#l::PgDn
#m::Insert
#.::Delete
;(Scroll with the left-over keys)
#i::WheelUp
#,::WheelDown
Note that all these keys need to work with any combination of Ctrl, Alt, Shift as well as the Windows Key.
Steps to install numeric keypad-like cursor keys on the main keyboard in Linux / XKB...
xkbcomp $DISPLAY original.xkb (just in case ;)
xkbcomp $DISPLAY custom.xkb
Edit custom.xkb
Add the following at the end of section: xkb_types "..." {
type "WinKeyAsFnKey" {
modifiers = Shift+Super;
map[Shift] = level2;
map[Super] = level3;
map[Super+Shift] = level3;
level_name[Level1] = "Base";
level_name[Level2] = "Caps";
level_name[Level3] = "Fn";
};
Add the following at the end of section xkb_symbols "..." {
key <AE07> {type="WinKeyAsFnKey",symbols[Group1]=[7,ampersand,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<HOME>,clearmods=Super)]};
key <AE08> {type="WinKeyAsFnKey",symbols[Group1]=[8,asterisk,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<UP>,clearmods=Super)]};
key <AE09> {type="WinKeyAsFnKey",symbols[Group1]=[9,parenleft,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<PGUP>,clearmods=Super)]};
key <AD07> {type="WinKeyAsFnKey",symbols[Group1]=[u,U,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<LEFT>,clearmods=Super)]};
key <AD09> {type="WinKeyAsFnKey",symbols[Group1]=[o,O,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<RGHT>,clearmods=Super)]};
key <AC07> {type="WinKeyAsFnKey",symbols[Group1]=[j,J,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<END>,clearmods=Super)]};
key <AC08> {type="WinKeyAsFnKey",symbols[Group1]=[k,K,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<DOWN>,clearmods=Super)]};
key <AC09> {type="WinKeyAsFnKey",symbols[Group1]=[l,L,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<PGDN>,clearmods=Super)]};
key <AB07> {type="WinKeyAsFnKey",symbols[Group1]=[m,M,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<INS>,clearmods=Super)]};
key <AB09> {type="WinKeyAsFnKey",symbols[Group1]=[period,greater,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<DELE>,clearmods=Super)]};
Save custom.xkb
xkbcomp custom.xkb $DISPLAY
I'm still working on the mouse scroll with 'i' and ','.
EDIT:
The above solution does not play nice with Google Chrome and Chrome-based apps (like Slack).
Alternative approach is to use a programmable keyboard. I use an after-market PCB for a CoolerMaster Masterkeys S keyboard. The Easy AVR layout is available online (although currently the left win-key now doesn't work by itself...I use the right one).

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