Go to file
Takashi Kokubun a3b99f1d0c Fix typo
2016-12-03 09:52:37 +09:00
examples Add include_config directive 2016-12-03 09:49:04 +09:00
mrblib/xkremap Add include_config directive 2016-12-03 09:49:04 +09:00
src Experimentally add press and release DSL 2016-11-30 05:41:01 +09:00
tools/xkremap Complete basic remap implementation 2016-11-30 04:00:12 +09:00
.gitignore Create Makefile to generate xkremap binary 2016-11-29 00:15:10 +09:00
build_config.rb Allow building xkremap on darwin 2016-12-03 08:56:31 +09:00
CHANGELOG.md Fix typo 2016-12-03 09:52:37 +09:00
LICENSE Initial commit 2016-11-26 07:55:22 +09:00
Makefile Add make install 2016-11-30 08:28:54 +09:00
mrbgem.rake Better logging to detect window class 2016-11-30 06:52:41 +09:00
README.md Note about build dependency 2016-12-01 19:48:51 +09:00

xkremap

Dynamic key remapper for X Window System

Description

xkremap is a key remapper for X Window System. With xkremap's Ruby DSL, you can simply write configuration of key bindings.

remap 'C-b', to: 'Left'

And you can configure application-specific key bindings, which is dynamically applied based on a current window.

window class_only: 'slack' do
  remap 'Alt-k', to: 'Alt-Up'
  remap 'Alt-j', to: 'Alt-Down'
end

While xkremap's configuration is written in Ruby, you can run xkremap without Ruby installation because it embeds mruby to evaluate configuration.

Installation

Build dependencies

  • ruby
  • bison

While ruby is not runtime dependency for xkremap, mruby embedded in xkremap requires ruby to build. And bison is required to build ruby.

From source code

$ git clone https://github.com/k0kubun/xkremap
$ cd xkremap
$ make
$ sudo make install # or `make DESTDIR=~/bin install`

Arch Linux

$ yaourt -S xkremap

Usage

$ xkremap /path/to/config

See examples to write config file.

Emacs-like bindings

window class_not: 'urxvt' do
  remap 'C-b', to: 'Left'
  remap 'C-f', to: 'Right'
  remap 'C-p', to: 'Up'
  remap 'C-n', to: 'Down'

  remap 'M-b', to: 'Ctrl-Left'
  remap 'M-f', to: 'Ctrl-Right'

  remap 'C-a', to: 'Home'
  remap 'C-e', to: 'End'

  remap 'C-k', to: ['Shift-End', 'Ctrl-x']

  remap 'C-d', to: 'Delete'
  remap 'M-d', to: 'Ctrl-Delete'
end

Simulate macOS's command key

Following configuration works fine with above Emacs-like bindings.

%w[a z x c v w t].each do |key|
  remap "Alt-#{key}", to: "C-#{key}"
end

Application launcher

You can start an application by a shortcut key. See examples/window_switcher too.

remap 'C-o', to: execute('nocturn')
remap 'C-u', to: execute('google-chrome-stable')
remap 'C-h', to: execute('urxvt')

Application-specific key bindings

See xkremap's stdout to find a window class name of your application.

window class_only: 'slack' do
  remap 'Alt-n', to: 'Ctrl-k'
  remap 'Alt-k', to: 'Alt-Up'
  remap 'Alt-j', to: 'Alt-Down'
  remap 'Ctrl-Alt-k', to: 'Alt-Shift-Up'
  remap 'Ctrl-Alt-j', to: 'Alt-Shift-Down'
end

Project status

Experimental. It's working but not tested well.

Note

xkremap is designed to have similar functionality with Karabiner and karabiner-dsl for Linux environments.

Author

Takashi Kokubun