Skip to content

DavRack/skr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Key Remap

SKR is a low level, low latency way to remap keys to:

  • Other keys
  • Shell commands or scripts
  • Sequences of keys, commands and scripts (A.K.A Macros) (needs to be documented but it's there)
  • Function Layers

SKR sits very low in the keyboard stack just above the kernel so its independent of desktop environments, window manager or graphical environments in general, even works in tty.

Table of Contents

Installation

Arch Linux

Install git and interception-tools from the aur

example using yay AUR helper

yay -S git interception-tools

Install skr

git clone https://github.com/DavRack/skr.git
cd skr
./install.sh

Ubuntu 20.04

First install interception-tools and git

sudo apt install git libudev-dev libevdev-dev libyaml-cpp-dev cmake build-essential
git clone https://gitlab.com/interception/linux/tools.git
cd tools
mkdir build
cd build
cmake ..
make
sudo make install
cd

Install skr

git clone https://github.com/DavRack/skr.git
cd skr
./install.sh

Fedora 32

First install interception-tools and git

sudo dnf install git cmake yaml-cpp-devel libevdev-devel systemd-devel gcc-c++ @development-tools
git clone https://gitlab.com/interception/linux/tools.git
cd tools
mkdir build
cd build
cmake ..
make
sudo make install
cd

Install skr

git clone https://github.com/DavRack/skr.git
cd skr
./install.sh

Uninstall skr

./install.sh -u

Configuration

SKR is configured through ~/.config/skr/skr.config you can find an example config file here

Once skr is installed run:

skr --init

This command will prompt you to press a key. skr will find the path of the keyboard used to press the key and will create a config file

Editing the config file

First we need to define the keyboard path that skr will intercept:

if you run skr --init the keyboard path will be already defined

KeyboardPath -> /dev/input/event3

Key remap

A key remap takes one key and convert its to another key and has this syntax:

[keyToRemap] -> [targetKey]

Example: Remap CapsLock to Esc

CapsLock -> Esc

skr takes its key names from /usr/include/linux/input-event-codes.h

Here's a key code table with all valid key names: keycode table

Key swap

A Key Swap the function of two keys and has this syntax:

[Key1] <-> [Key2]

A key swap its equivalent to two remaps

[Key1] -> [Key2]

[Key2] -> [Key1]

Example: Swap Meta/Super ("Windows" key) with left alt:

META <-> ALT

Scripts

SKR can use any key to launch a script or shell command and has this syntax:

[KeyToRemap] -> Script=[your command or full path to a script]

Example: log memory usage to a file located in /tmp/memlog

[KeyToRemap] -> Script=free -h > /tmp/memlog

Warning! all commands launched from skr will be executed as root

Layers

A Layer is a set of additional key bindings achieved by holding down a predefined key on the keyboard, its easier to understand with an example:

Let's say you want to use H J K L as arrow keys (vim style), you can set capsLock as a fnKey so when you hold it down and press H,J,K or L this keys will act as arrow keys, but when the fnKey is not press H J K L will work normally.

The syntax for layers is:

NewLayer -> [fnKey]
    # all remaps after NewLayer will activate when [fnKey] is hold down

    # remap 1

    # remap 2
    .
    .
    .


# you can define multiple layers
NewLayer -> [fnKey2]
    # all remaps after NewLayer will activate when [fnKey2] is hold down

    # remap 1

    # remap 2
    .
    .
    .

The H J K L as arrows example would look like this on the config file:

NewLayer -> CapsLock

    H -> LEFT
    J -> DOWN
    K -> UP
    L -> RIGHT
Some things to keep in mind about layers
  • When a Layer is defined its function key stops working as a normal key

  • You can define anything inside a layer: Remaps, Scripts and Macros

Auto start (systemd)

To run skr on boot first we need to create a unit file at /etc/systemd/system/skr.service with the following content:

replace your username where indicated

[Unit]
Description=undervolt

[Service]
User=root
Environment=USER=putUserNameHere
Environment=SUDO_USER=putUserNameHere
ExecStart=/usr/bin/skr

[Install]
WantedBy=multi-user.target

Then enable the unit running:

sudo systemctl enable skr.service

this will start the service at boot. to start skr imediatly run:

sudo systemctl start skr.service

Dependencies

Donations

if you like my work you can send me crypto to these wallets:

BTC: 17u6NAodc6GrQPRGNy92xF6pmzDFaq2EuC

ETH: 0xa85c356d396A80Afc49B6B281E4a9a897fdfa152

TODO

  • MD custom macros
  • Don't run non sudo commands as root
  • Remove dependencies

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •