Rename xkremap to xremap

pull/17/head
Takashi Kokubun 8 years ago
parent ea34e7504e
commit 6e8e1f2128

2
.gitignore vendored

@ -1,2 +1,2 @@
/xkremap
/xremap
/mruby

@ -1,26 +1,26 @@
current_dir := $(shell pwd)
CSRCS := $(wildcard tools/xkremap/*.[ch])
MRBSRCS := $(wildcard mrblib/xkremap/*.rb)
CSRCS := $(wildcard tools/xremap/*.[ch])
MRBSRCS := $(wildcard mrblib/xremap/*.rb)
MRBCSRCS := $(wildcard src/*.[ch])
# Using master to apply https://github.com/mruby/mruby/pull/3192
REVISION=0ff3ae1fbaed62010c54c43235e29cdc85da2f78
DESTDIR := /usr/local/bin
.PHONY: all clean install
all: xkremap
all: xremap
clean:
rm -rf mruby/build/host
install: xkremap
mv xkremap $(DESTDIR)/xkremap
install: xremap
mv xremap $(DESTDIR)/xremap
xkremap: mruby/build/host/bin/xkremap
cp mruby/build/host/bin/xkremap xkremap
xremap: mruby/build/host/bin/xremap
cp mruby/build/host/bin/xremap xremap
mruby:
git clone https://github.com/mruby/mruby
git -C mruby reset --hard $(REVISION)
mruby/build/host/bin/xkremap: mruby build_config.rb $(CSRCS) $(MRBSRCS) $(MRBCSRCS)
mruby/build/host/bin/xremap: mruby build_config.rb $(CSRCS) $(MRBSRCS) $(MRBCSRCS)
cd mruby && MRUBY_CONFIG="$(current_dir)/build_config.rb" make

@ -1,11 +1,11 @@
# xkremap
# xremap
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.
xremap is a key remapper for X Window System.
With xremap's Ruby DSL, you can simply write configuration of key bindings.
```rb
remap 'C-b', to: 'Left'
@ -21,7 +21,7 @@ window class_only: 'slack' do
end
```
While xkremap's configuration is written in Ruby, you can run xkremap without Ruby installation
While xremap's configuration is written in Ruby, you can run xremap without Ruby installation
because it embeds mruby to evaluate configuration.
## Installation
@ -31,13 +31,13 @@ because it embeds mruby to evaluate configuration.
- ruby
- bison
While ruby is not runtime dependency for xkremap, mruby embedded in xkremap requires ruby to build.
While ruby is not runtime dependency for xremap, mruby embedded in xremap requires ruby to build.
### From source code
```bash
$ git clone https://github.com/k0kubun/xkremap
$ cd xkremap
$ git clone https://github.com/k0kubun/xremap
$ cd xremap
$ make
$ sudo make install # or `make DESTDIR=~/bin install`
```
@ -45,13 +45,13 @@ $ sudo make install # or `make DESTDIR=~/bin install`
### Arch Linux
```bash
$ yaourt -S xkremap
$ yaourt -S xremap
```
## Usage
```
$ xkremap /path/to/config
$ xremap /path/to/config
```
See [examples](./examples) to write config file.
@ -101,7 +101,7 @@ remap 'C-h', to: execute('urxvt')
### Application-specific key bindings
See xkremap's stdout to find a window class name of your application.
See xremap's stdout to find a window class name of your application.
```rb
window class_only: 'slack' do
@ -119,7 +119,7 @@ Experimental. It's working but not tested well.
## Note
xkremap is designed to have similar functionality with
xremap is designed to have similar functionality with
[Karabiner](https://github.com/tekezo/Karabiner) and
[karabiner-dsl](https://github.com/k0kubun/karabiner-dsl)
for Linux environments.

@ -1,15 +0,0 @@
# 1. Copy this to ~/.config/systemd/user/xkremap.service
# 2. systemctl --user enable xkremap
[Unit]
Description=xkremap
[Service]
KillMode=process
ExecStart=/usr/bin/xkremap /home/k0kubun/.xkremap
ExecStop=/usr/bin/killall xkremap
Restart=always
Environment=DISPLAY=:0.0
[Install]
WantedBy=graphical.target

@ -0,0 +1,15 @@
# 1. Copy this to ~/.config/systemd/user/xremap.service
# 2. systemctl --user enable xremap
[Unit]
Description=xremap
[Service]
KillMode=process
ExecStart=/usr/bin/xremap /home/k0kubun/.xremap
ExecStop=/usr/bin/killall xremap
Restart=always
Environment=DISPLAY=:0.0
[Install]
WantedBy=graphical.target

@ -1,8 +1,8 @@
MRuby::Gem::Specification.new('xkremap') do |spec|
MRuby::Gem::Specification.new('xremap') do |spec|
spec.license = 'MIT'
spec.author = 'Takashi Kokubun'
spec.summary = 'Dynamic key remapper for X Window System'
spec.bins = ['xkremap']
spec.bins = ['xremap']
spec.add_dependency 'mruby-eval', core: 'mruby-eval'

@ -1,9 +1,9 @@
module Xkremap
module Xremap
class ActiveWindow
# @param [Fixnum] current_window
attr_reader :current_window
# @param [Xkremap::Display] display
# @param [Xremap::Display] display
def initialize(display)
@display = display
@current_window = fetch_active_window

@ -1,4 +1,4 @@
module Xkremap
module Xremap
class Config
# FIXME: :to_keys should be :to_actions, and Key and Execute should be adapted.
Remap = Struct.new(:from_key, :to_keys)

@ -1,6 +1,6 @@
module Xkremap
module Xremap
class ConfigDSL
# @param [Xkremap::Config] config
# @param [Xremap::Config] config
def initialize(config, win = Config::AnyWindow)
@config = config
@window = win

@ -1,7 +1,7 @@
module Xkremap
module Xremap
class EventHandler
# @param [Xkremap::Config] config
# @param [Xkremap::Display] display
# @param [Xremap::Config] config
# @param [Xremap::Display] display
def initialize(config, display)
@active_window = ActiveWindow.new(display)
@grab_manager = GrabManager.new(config, display)

@ -1,7 +1,7 @@
module Xkremap
module Xremap
class GrabManager
# @param [Xkremap::Config] config
# @param [Xkremap::Display] display
# @param [Xremap::Config] config
# @param [Xremap::Display] display
def initialize(config, display)
@config = config
@display = display

@ -1,8 +1,8 @@
module Xkremap
module Xremap
module KeyExpression
class << self
# @param [String] exp
# @return [Xkremap::Config::Key] key
# @return [Xremap::Config::Key] key
def compile(exp)
keyexp, modifiers = split_into_key_and_mods(exp)
Config::Key.new(to_keysym(keyexp), modifier_mask(modifiers))

@ -1,4 +1,4 @@
module Xkremap
module Xremap
class KeyRemapCompiler
def initialize(config, display)
@config = config

@ -20,8 +20,8 @@ struct mrb_data_type mrb_display_type = { "Display", mrb_display_free };
mrb_value
mrb_wrap_x_display(mrb_state *mrb, Display *display)
{
struct RClass *mXkremap = mrb_module_get(mrb, "Xkremap");
struct RClass *cDisplay = mrb_class_get_under(mrb, mXkremap, "Display");
struct RClass *mXremap = mrb_module_get(mrb, "Xremap");
struct RClass *cDisplay = mrb_class_get_under(mrb, mXremap, "Display");
struct mrb_display *display_ptr = (struct mrb_display *)mrb_malloc(mrb, sizeof(struct mrb_display));
display_ptr->display = display;
@ -39,7 +39,7 @@ extract_x_display(mrb_state *mrb, mrb_value display_obj)
}
void
mrb_xkremap_display_init(mrb_state *mrb, struct RClass *mXkremap)
mrb_xremap_display_init(mrb_state *mrb, struct RClass *mXremap)
{
mrb_define_class_under(mrb, mXkremap, "Display", mrb->object_class);
mrb_define_class_under(mrb, mXremap, "Display", mrb->object_class);
}

@ -3,9 +3,9 @@
#include "mruby.h"
void
mrb_xkremap_x11_constants_init(mrb_state *mrb, struct RClass *mXkremap)
mrb_xremap_x11_constants_init(mrb_state *mrb, struct RClass *mXremap)
{
struct RClass *mX11 = mrb_define_module_under(mrb, mXkremap, "X11");
struct RClass *mX11 = mrb_define_module_under(mrb, mXremap, "X11");
# define define_x11_const(name) mrb_define_const(mrb, mX11, #name, mrb_fixnum_value(name))
// original constant.

@ -1,21 +0,0 @@
#include "mruby.h"
extern void mrb_xkremap_xlib_wrapper_init(mrb_state *mrb, struct RClass *mXkremap);
extern void mrb_xkremap_display_init(mrb_state *mrb, struct RClass *mXkremap);
extern void mrb_xkremap_x11_constants_init(mrb_state *mrb, struct RClass *mXkremap);
void
mrb_xkremap_gem_init(mrb_state *mrb)
{
struct RClass *mXkremap = mrb_define_module(mrb, "Xkremap");
mrb_xkremap_xlib_wrapper_init(mrb, mXkremap);
mrb_xkremap_display_init(mrb, mXkremap);
mrb_xkremap_x11_constants_init(mrb, mXkremap);
mrb_gc_arena_restore(mrb, 0);
}
void
mrb_xkremap_gem_final(mrb_state *mrb)
{
}

@ -176,9 +176,9 @@ mrb_xw_ungrab_keys(mrb_state *mrb, mrb_value self)
}
void
mrb_xkremap_xlib_wrapper_init(mrb_state *mrb, struct RClass *mXkremap)
mrb_xremap_xlib_wrapper_init(mrb_state *mrb, struct RClass *mXremap)
{
struct RClass *cXlibWrapper = mrb_define_class_under(mrb, mXkremap, "XlibWrapper", mrb->object_class);
struct RClass *cXlibWrapper = mrb_define_class_under(mrb, mXremap, "XlibWrapper", mrb->object_class);
mrb_define_class_method(mrb, cXlibWrapper, "input_key", mrb_xw_input_key, MRB_ARGS_REQ(3));
mrb_define_class_method(mrb, cXlibWrapper, "press_key", mrb_xw_press_key, MRB_ARGS_REQ(3));
mrb_define_class_method(mrb, cXlibWrapper, "release_key", mrb_xw_release_key, MRB_ARGS_REQ(3));

@ -0,0 +1,21 @@
#include "mruby.h"
extern void mrb_xremap_xlib_wrapper_init(mrb_state *mrb, struct RClass *mXremap);
extern void mrb_xremap_display_init(mrb_state *mrb, struct RClass *mXremap);
extern void mrb_xremap_x11_constants_init(mrb_state *mrb, struct RClass *mXremap);
void
mrb_xremap_gem_init(mrb_state *mrb)
{
struct RClass *mXremap = mrb_define_module(mrb, "Xremap");
mrb_xremap_xlib_wrapper_init(mrb, mXremap);
mrb_xremap_display_init(mrb, mXremap);
mrb_xremap_x11_constants_init(mrb, mXremap);
mrb_gc_arena_restore(mrb, 0);
}
void
mrb_xremap_gem_final(mrb_state *mrb)
{
}

@ -6,8 +6,8 @@
mrb_value
load_config(mrb_state *mrb, char *filename)
{
struct RClass *mXkremap = mrb_module_get(mrb, "Xkremap");
struct RClass *cConfig = mrb_class_get_under(mrb, mXkremap, "Config");
struct RClass *mXremap = mrb_module_get(mrb, "Xremap");
struct RClass *cConfig = mrb_class_get_under(mrb, mXremap, "Config");
mrb_value config = mrb_funcall(mrb, mrb_obj_value(cConfig), "load", 1, mrb_str_new_cstr(mrb, filename));
if (mrb->exc) {

@ -6,8 +6,8 @@ extern mrb_value mrb_wrap_x_display(mrb_state *mrb, Display *display);
mrb_value
new_event_handler(mrb_state *mrb, mrb_value config, Display *display)
{
struct RClass *mXkremap = mrb_module_get(mrb, "Xkremap");
struct RClass *cEventHandler = mrb_class_get_under(mrb, mXkremap, "EventHandler");
struct RClass *mXremap = mrb_module_get(mrb, "Xremap");
struct RClass *cEventHandler = mrb_class_get_under(mrb, mXremap, "EventHandler");
mrb_value display_obj = mrb_wrap_x_display(mrb, display);
return mrb_funcall(mrb, mrb_obj_value(cEventHandler), "new", 2, config, display_obj);
}

@ -3,7 +3,7 @@
#include <signal.h>
#include <mruby.h>
#include <X11/Xlib.h>
#include "xkremap.h"
#include "xremap.h"
int
error_handler(Display *display, XErrorEvent *event)
@ -43,7 +43,7 @@ int
main(int argc, char **argv)
{
if (argc != 2) {
fprintf(stderr, "Usage: xkremap <file>\n");
fprintf(stderr, "Usage: xremap <file>\n");
return 1;
}
Loading…
Cancel
Save