Go to file
Seiei Miyagi 6ceda05568
Generate X11 constants from headers at build-time.
The X11 constants are different between versions.

For example, Debian doesn't have XF86XK_WWAN
https://salsa.debian.org/xorg-team/proto/x11proto-core/blob/debian-unstable/XF86keysym.h

But Arch Linux does.
https://www.archlinux.org/packages/extra/any/xorgproto/

I've got following error on Debian stretch

```
 /home/sei/src/github.com/k0kubun/xremap/src/x11_constants.c:2710:20: error: ‘XF86XK_WWAN’ undeclared (first use in this function)
    define_x11_const(XF86XK_WWAN);
```

To avoid macro undeclared error, wrap the `define_x11_const` with #ifdef

```
#ifdef XF86XK_WWAN
define_x11_const(XF86XK_WWAN)
#endif
```

Or generate code at build-time.
2018-09-13 09:39:37 +09:00
examples Example for Asus ROG Keyboard 2018-09-05 00:45:42 -03:00
mrblib/xremap Don't use exception for branching 2018-09-05 22:58:38 +09:00
src Generate X11 constants from headers at build-time. 2018-09-13 09:39:37 +09:00
tools/xremap Better logging 2017-06-17 03:14:40 +09:00
.gitignore Generate X11 constants from headers at build-time. 2018-09-13 09:39:37 +09:00
build_config.rb Allow building xkremap on darwin 2016-12-03 08:56:31 +09:00
CHANGELOG.md Version 0.0.3 2017-01-04 00:10:05 +09:00
LICENSE Initial commit 2016-11-26 07:55:22 +09:00
Makefile Generate X11 constants from headers at build-time. 2018-09-13 09:39:37 +09:00
mrbgem.rake Rename xkremap to xremap 2017-01-09 15:18:22 +09:00
README.md Update project status 2018-06-23 22:00:14 +09:00

xremap

Dynamic key remapper for X Window System

Project status

This is an experimental project to achieve a comfortable configuration experience of key remap on Linux.

Some issues are reported and some of them are hard to reproduce or resolve immediately. If you can fix any open issues on these platforms, you'll be welcomed as a maintainer of xremap.

Description

xremap is a key remapper for X Window System. With xremap'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 xremap's configuration is written in Ruby, you can run xremap without Ruby installation because it embeds mruby to evaluate configuration.

Installation

Build dependencies

  • ruby
  • bison
  • libx11-dev

While ruby is not runtime dependency for xremap, mruby embedded in xremap requires ruby to build.

From source code

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

Usage

$ xremap /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 xremap'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

Note

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

Author

Takashi Kokubun