xfce swap command and control keys

7,937

Solution 1

setxkbmap -option altwin:left_meta_win

Run echo -option altwin:left_meta_win >> ~/.Xkbmap to make it permanent.

Solution 2

If you try running man xkeyboard-config, you'll get tons of options for switching behaviors. My favorite is ctrl:swap_rwin_rctl, which makes (only) the right Command (a.k.a. Meta, Super, Win) work as a second Ctrl. So this is what you should run to make the switch:

setxkbmap -option ctrl:swap_rwin_rctl

If you also want to switch the left-side Ctrl and Meta keys, just run setxkbmap again with ctrl:swap_lwin_lctl.

Running this on terminal will make the changes only last until you log off, but you can have this command run on startup to make the change persistent.

Solution 3

I'm just starting over since the original response was too long and detailed.

I'd simply use xkeysnail, it is like xmodmap, or xkb, but more configurable, python based, easier to modify and it is usually in the distro repos.

You can also use my app kinto which makes use of xkeysnail and gives you mac like keybinds throughout. Kinto will also actually install xkeysnail as a systemd service, something that won't happen via the repo or github site for xkeysnail.

An example of a config created for xkeysnail.

# -*- coding: utf-8 -*-

import re
from xkeysnail.transform import *

terminals = ["gnome-terminal","konsole","io.elementary.terminal","terminator","sakura","guake","tilda","xterm","eterm","kitty"]
terminals = [term.casefold() for term in terminals]
termStr = "|".join(str(x) for x in terminals)

# [Conditional modmap] Change modifier keys in certain applications
define_conditional_modmap(lambda wm_class: wm_class.casefold() not in terminals,{
    # Default Mac/Win
    Key.LEFT_ALT: Key.RIGHT_CTRL,   # WinMac
    Key.LEFT_META: Key.LEFT_ALT,    # WinMac
    Key.LEFT_CTRL: Key.LEFT_META,   # WinMac
    Key.RIGHT_ALT: Key.RIGHT_CTRL,  # WinMac
    Key.RIGHT_META: Key.RIGHT_ALT,  # WinMac
    Key.RIGHT_CTRL: Key.RIGHT_META, # WinMac
})

# [Conditional modmap] Change modifier keys in certain applications
define_conditional_modmap(re.compile(termStr, re.IGNORECASE), {
    # Default Mac/Win
    Key.LEFT_ALT: Key.RIGHT_CTRL,   # WinMac
    Key.LEFT_META: Key.LEFT_ALT,    # WinMac
    Key.LEFT_CTRL: Key.LEFT_CTRL,   # WinMac
    Key.RIGHT_ALT: Key.RIGHT_CTRL,  # WinMac
    Key.RIGHT_META: Key.RIGHT_ALT,  # WinMac
    Key.RIGHT_CTRL: Key.LEFT_CTRL,  # WinMac
})

define_keymap(re.compile(termStr, re.IGNORECASE),{
    # Ctrl Tab - In App Tab Switching
    K("LC-Tab") : K("LC-PAGE_DOWN"),
    K("LC-Shift-Tab") : K("LC-PAGE_UP"),
    K("LC-Grave") : K("LC-PAGE_UP"),
    # Converts Cmd to use Ctrl-Shift
    K("RC-Tab"): K("RC-F13"),
    K("RC-Shift-Tab"): K("RC-Shift-F13"),
    K("RC-V"): K("C-Shift-V"),
    K("RC-MINUS"): K("C-Shift-MINUS"),
    K("RC-EQUAL"): K("C-Shift-EQUAL"),
    K("RC-BACKSPACE"): K("C-Shift-BACKSPACE"),
    K("RC-Q"): K("C-Shift-Q"),
    K("RC-W"): K("C-Shift-W"),
    K("RC-E"): K("C-Shift-E"),
    K("RC-R"): K("C-Shift-R"),
    K("RC-T"): K("C-Shift-t"),
    K("RC-Y"): K("C-Shift-Y"),
    K("RC-U"): K("C-Shift-U"),
    K("RC-I"): K("C-Shift-I"),
    K("RC-O"): K("C-Shift-O"),
    K("RC-P"): K("C-Shift-P"),
    K("RC-LEFT_BRACE"): K("C-Shift-LEFT_BRACE"),
    K("RC-RIGHT_BRACE"): K("C-Shift-RIGHT_BRACE"),
    K("RC-A"): K("C-Shift-A"),
    K("RC-S"): K("C-Shift-S"),
    K("RC-D"): K("C-Shift-D"),
    K("RC-F"): K("C-Shift-F"),
    K("RC-G"): K("C-Shift-G"),
    K("RC-H"): K("C-Shift-H"),
    K("RC-J"): K("C-Shift-J"),
    K("RC-K"): K("C-Shift-K"),
    K("RC-L"): K("C-Shift-L"),
    K("RC-SEMICOLON"): K("C-Shift-SEMICOLON"),
    K("RC-APOSTROPHE"): K("C-Shift-APOSTROPHE"),
    K("RC-GRAVE"): K("C-Shift-GRAVE"),
    K("RC-BACKSLASH"): K("C-Shift-BACKSLASH"),
    K("RC-Z"): K("C-Shift-Z"),
    K("RC-X"): K("C-Shift-X"),
    K("RC-C"): K("C-Shift-C"),
    K("RC-V"): K("C-Shift-V"),
    K("RC-B"): K("C-Shift-B"),
    K("RC-N"): K("C-Shift-N"),
    K("RC-M"): K("C-Shift-M"),
    K("RC-COMMA"): K("C-Shift-COMMA"),
    K("RC-DOT"): K("C-Shift-DOT"),
    K("RC-SLASH"): K("C-Shift-SLASH"),
    K("RC-KPASTERISK"): K("C-Shift-KPASTERISK"),
}, "terminals")
Share:
7,937

Related videos on Youtube

gadgetmo
Author by

gadgetmo

Updated on September 18, 2022

Comments

  • gadgetmo
    gadgetmo over 1 year

    What is the equivalent of this in Debian XFCE?:

    Go into System -> Preferences -> Keyboard

    Click on the "Layouts" tab and then click the "Layout Options" button.

    Click on "Alt/Win key behavior"

    Select "Control is mapped to Win keys (and the usual ctrl key).

    This will make your Apple command keys act like control, and keep your ctrl key as control as well. However, this will leave you without a Super key. I haven't found this a problem. I hope that's what you're looking for!

    I have tried the .Xmodmap method, but that doesn't work either.

    Also, would I be able to use the ctrl key to right click again like it does on mac?

    • hhaamu
      hhaamu over 12 years
      setxkbmap -option altwin:ctrl_win. The GUI should have an equal setting with an identical description.
  • Aleksandr Dubinsky
    Aleksandr Dubinsky about 4 years
    I think you should reword this answer. It is confusing, especially for readers who haven't carefully read the question. Otherwise, kudos for putting in the work.
  • R Ben R
    R Ben R about 4 years
    At this point I think I'd be fine with deleting it, but my account appears to have been banned for unknown or arbitrary reasons again. Can't even seem to pull up what got deleted, assuming I need to improve an answer. Surely I didn't get banned for the above? I have done a major update any ways so I will update it, but good grief the algorithm needs toning down.
  • R Ben R
    R Ben R about 4 years
    Just to clarify I don't believe I have ever deleted any of my answers, I either leave them or improve them. I was just expressing frustration with the site in general. It feels like it is playing wack-a-mole with me still.