1

I'd like to swap Ctrl & Super so that I can use the physical super/meta key for copy/paste/select-all/find/etc. without application-specific configuration, which often doesn't exist.

However, I'd like to keep SIGINT, EOF, suspend, and the like on the physical control key.

I've tried setting URxvt.keysym.M-c: ^C, and I'm aware that stty can change it to be e.g. ^K, but as far as I've been able to tell it can't change the modifier key - either to a different keysym or to the keycode directly.

Is this possible?

5
  • How do you suggest making the computer know the distinction between the two uses? Commented Aug 13, 2016 at 16:20
  • @ThomasDickey I don't understand - the distinction between what? I've swapped the keys, that's fine, but I want to have SIGINT and the like mapped to Meta-C (physical Ctrl-C) instead.
    – OJFord
    Commented Aug 13, 2016 at 16:29
  • I'm confused: in what way does URxvt.keysym.M-c: ^C not do what you want? Commented Aug 13, 2016 at 21:47
  • @Gilles In the way that it just doesn't perform that mapping - it has no effect. I'm not confident of the syntax - I couldn't find a particularly fitting example. Does it work for you, if you use urxvt?
    – OJFord
    Commented Aug 14, 2016 at 0:07
  • @OllieFord ^C needs to be \003, and M-c is of course Meta-C and not Super-C. I've edited my answer. Commented Aug 14, 2016 at 0:14

1 Answer 1

2

The conversion of certain keystrokes into a signal is performed at a very low level: it's done by the generic terminal driver in the kernel, when it relays between the terminal emulator process or physical terminal hardware and the program running in the terminal. This driver only understands characters (and by characters, I mean bytes — back when these interfaces were designed, multibyte character sets weren't a thing).

Most keystrokes involving modifiers other than Shift or involving function keys have no corresponding character, so the terminal must send a multi-character escape sequence (beginning with the ASCII escape character). See bash - wrong key sequence bindings with control+alt+space and How do keyboard input and text output work? for more background on this topic.

There are characters corresponding to Ctrl+letter (the ASCII control characters), but not to Super+letter. Meta+C sends the two-character sequence ESC C, and Super+C sends just C by default in most terminals. So you can rebind the signals on Ctrl+letter (and a few punctuation symbols), to a single-byte printable character, and that's about it (also to a non-ASCII byte but that would wreak havoc with UTF-8).

The only solution is to configure your terminal emulator to send Ctrl+C for whatever keystroke you want to cause to trigger SIGINT. For Rxvt, you're on the right track, but ^C inserts the two characters ^ and C, you need the control-c character instead, which you can specify with an octal escape. Furthermore M-c is Meta+C, not Super+C; for Super+C, run xmodmap -pm, note which of mod1 through mod5 is Super, and use the corresponding digit as the modifier character, e.g.

URxvt.keysym.5-c: \003
2
  • Thank you! How did you find or know that it was \003, and that ModX is mapped by .X? All the meta/super/hyper stuff continually confuses me - I did in fact mean meta (other bindings are working) - but I'd thought it was the same. It's a Mac Cmd key in this case, but I thought it and the Win key were each referred to as super/meta interchangeably.
    – OJFord
    Commented Aug 14, 2016 at 15:06
  • @OllieFord That's described in the docuentation of the keysym resource in the urxvt man page. You need to have a bit of background to understand what it's talking about. Modifiers get names and numbers; Control, CapsLock and Shift are always on the same number but the others (Alt, Meta, Hyper, Super, NumLock, AltGR) move around on Mod1–Mod5. And the correspondence between X11 modifier names and physical keys on a PC/Mac isn't standard, so you need to check how yours are configured. Commented Aug 14, 2016 at 15:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .