Skip to content

smkniazi/keyremaplinux

 
 

Repository files navigation

Introduction

Define your keyboard layout as C++ class. Primarily focused on implementing my keyboard layout.

Why use it instead of xmodmap/xcape

  • Just single representation for a key to deal with - input_event code from input_event_codes.h. No need to distinguish between scancode, keysym or keycode.
  • For complex layouts, xmodmap/xcape gets hard to maintain: https://github.com/kozikow/kozikow-layout-linux.
  • Thread per keyboard lets you have different layout per keyboard.
  • Unit test your layout.

Installation

Install bazel

apt-get install -y software-properties-common python-software-properties

# C++
apt-get install -y g++

# Java 8
echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections
add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
apt-get install -y oracle-java8-installer

# Bazel dependencies
apt-get install -y pkg-config zip zlib1g-dev unzip git

# Build bazel
git clone https://github.com/google/bazel.git ~/bazel && cd ~/bazel
~/bazel/compile.sh
sudo cp ~/bazel/bazel-bin/src/bazel /usr/local/bin

Build from source on Arch Linux

pacman -S jdk8-openjdk zip unzip zlib pkg-config

mkdir -p ~/git_repos/github/google
cd ~/git_repos/github/google
git clone https://github.com/google/bazel.git  
cd bazel
./compile.sh
sudo cp /home/kozikow/git_repos/github/google/bazel/output/bazel /usr/local/bin/

Build keyremaplinux

git clone https://github.com/kozikow/keyremaplinux ~/keyremaplinux
cd ~/keyremaplinux
bazel build //keyremaplinux:keyremaplinux

Running on Linux

Run one-of:

sudo nice -n -20 ./bazel-bin/keyremaplinux/keyremaplinux kozikow_standard

Enable automatic restarts

sudo cp keyremaplinux.service /etc/systemd/system/multi-user.target.wants/keyremaplinux.service
sudo systemctl enable keyremaplinux.service
sudo systemctl restart keyremaplinux.service

Implementing the new layout

  1. Extend Remapper and implement function Remap.
  2. For example KozikowLayoutRemapper.
  3. In function Remap, consume and produce Linux input event from input.h. What you consume is what user have typed. What you produce is what OS will see.
  4. Event codes are defined in input-event-codes.h

Run tests

bazel test //keyremaplinux:all --test_output=errors

About

Define your keyboard layout as C++ class.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 89.3%
  • Python 10.7%