Remap a key combination to another combination, e. g. Super+Ctrl+Shift+J -> Ctrl+Shift+Left

5,116

Give a combination of xbindkeys and xvkbd a try. xbindkeys listens for the keys and sends the translation to xvkbd.

sudo apt-get install xbindkeys xvkbd
xbindkeys --defaults > ~/.xbindkeysrc

Open .xbindkeysrc in your favourite editor. I commented everything else out, but it's good to refer to if required.

To check it out, I tried mapping Ctrl+; to Ctrl+V

"xvkbd -xsendevent -text "\Cv""
   control + semicolon

I expect you're after something like this

"xvkbd -xsendevent -text "\C\S\[Left]""
  Super+Control+Shift+J

Save the file, then run xbindkeys.

In order to reload any configuration changes, I killed the xbindkeys process then restarted.

xbindkeys syntax

I worked out the key combination by using a GUI for xbindkeys

sudo apt-get install xbindkeys-config
xbindkeys-config

Once you run that, press Get Key for the combination to put into the second line of your .xbindkeysrc file.

xvkbd syntax

From the manual:

\r - Return
\t - Tab
\b - Backspace
\e - Escape
\d - Delete
\S - Shift (modify the next character; please note that modify with ``\S'' will be ignored in many cases. For example, ``a\Cb\ScD\CE'' will be interpreted as a, Control-b, c, Shift-D, and Control-Shift-E.)
\C - Control (modify the next character)
\A - Alt (modify the next character)
\M - Meta (modify the next character)
\[keysym] - the keysym keysym (e.g., \[Left]), which will be processed in the similar matter with other general characters
\{keysym} - the keysym keysym (e.g., \{Left}), which will be processed in more primitive matter and can also be used for modofier keys such as Control_L, Meta_L, etc.; also, \{+keysym} and \{+keysym} will simulate press and release of the key, respectively [Version 3.3]
\Ddigit - delay digit * 100 ms
\xvalue - move mouse pointer (use "+" or "-" for relative motion)
\yvalue - move mouse pointer (use "+" or "-" for relative motion)
\mdigit - simulate click of the specified mouse button

Love to hear how it works out and if the combination was fit for your purpose. It looks good as a keymapper, but not necessarily a macro runner.

Share:
5,116

Related videos on Youtube

lolmaus - Andrey Mikhaylov
Author by

lolmaus - Andrey Mikhaylov

Looking for full-time remote job as a senior EmberJS dev, preferably with relocation perspectives. Personality At work I'm a passionate developer; strong supporter of best practices and patterns; serious about code readability, maintainability and scalability; believe in testing. On the scale from quick-n-dirty to slow-but-thorough, I lean toward the latter. Off duty, I'm a loving husband and father, an avid debater, a board game geek, a retired recreational cyclist, a crazy Russian and an affable guy with a slightly twisted sense of humor. I live in Moscow, Russia. Love working remotely from other beautiful places. Able to adjust to your timezone for partial or full work hours overlap. Skills Frontend development Over five years in frontend development Solid JavaScript skill, love modern tools, practices and patterns Sass enthusiast Highly experienced in Responsive Web Design, modular grids, mobile first, etc Using a BEM-like methodology to scale infinitely and prevent style leaks Not a visual designer EmberJS Over two years working exclusively with complex Ember apps Have a gut feeling for the Ember Way and best practices Focus on building robust, maintainable and scalable codebases Strong believer in the Test-Build-Refactor cycle Into testing: unit & user acceptance, work in TDD/BDD style, API/model layer mocking, CI Experience with advanced features: polymorphic relationships, FastBoot, Concurrency, Element Queries, etc Active member of the Ember community with humble open source contributions Other tech skills Proficient in using dev tools: git, terminal, SSH, Docker, package managers, build tools, StackOverflow/Google, etc Linux user, not a DevOps guy but have basic sysadmin skills Experience in distributed teams, SCRUM Know Ruby and looking into Elixir Active GitHub and StackOverflow profiles Non-tech skills Fluent English Fast typist Aware of own drawbacks and will let you know of them

Updated on September 18, 2022

Comments

  • lolmaus - Andrey Mikhaylov
    lolmaus - Andrey Mikhaylov over 1 year

    I want to implement an addition key layer, so that I can access non-alphanumeric keys without having to move my wrists.

    I've been using Autokey for this purpose, but the experience was unsatisfactory: it had occasional lags and let original keystrokes slip into certain apps.

    So I need a low-level solution.

    • Amias
      Amias over 7 years
      you might have to create custom virtual input driver to do this which i would guess would be written in C
    • lolmaus - Andrey Mikhaylov
      lolmaus - Andrey Mikhaylov over 7 years
      @Amias, can you please elaborate?
    • Amias
      Amias over 7 years
      you could have a xinput driver that runs the normal keyboard driver but interprets the keystrokes before passing them on to xorg , this would give you complete control but would be a moderately complex couple of days work for a C programmer.
  • lolmaus - Andrey Mikhaylov
    lolmaus - Andrey Mikhaylov over 7 years
    I need a specific example.
  • David
    David over 7 years
  • lolmaus - Andrey Mikhaylov
    lolmaus - Andrey Mikhaylov over 7 years
    Hey @MarkHewitt! Thank you so much for the detailed response! Unfortunately, this doesn't work for me very well: the original keypress keeps coming through, which ruins the whole thing.