#!/usr/bin/env bash

# The Interception Tools is a small set of utilities for operating on input
# events of evdev devices:
# * udevmon
# * intercept
# * uinput
# * mux

sudo apt-get update -qq
sudo apt install -y interception-tools

# Plugins

# *   caps2esc: transforming the most useless key ever in the most useful one
#       <https://gitlab.com/interception/linux/plugins/caps2esc>
# *   space2meta: turn your space key into the meta key when chorded to another key (on key release only)
#       <https://gitlab.com/interception/linux/plugins/space2meta>
# *   hideaway: move the mouse pointer out of sight after a couple of seconds
#       <https://gitlab.com/interception/linux/plugins/hideaway>
# *   dual-function-keys: tap for one key, hold for another
#       <https://gitlab.com/interception/linux/plugins/dual-function-keys>

# *   ralt2hyper: Remap Right Alt (commonly AltGr) to Hyper (i.e. Control, Alt and Super)
#       <https://gitlab.com/oarmstrong/ralt2hyper>
# *   chorded_keymap
#       <https://gitlab.com/wsha/chorded_keymap>
# *   interception-vimproved
#       <https://github.com/maricn/interception-vimproved>
# *   interception-k2k
#       <https://github.com/zsugabubus/interception-k2k>

# openrc
conf_print_openrc_init() {
  cat <<EOF
#!/sbin/openrc-run
depend() {
	want udev-settle
	after udev-settle
}
command=/usr/bin/udevmon
command_args='-c /etc/interception/udevmon.yaml'
start_stop_daemon_args='-N -20'
pidfile=/var/run/udevmon.pid
command_background=true
EOF
}
conf_print_openrc_init | sudo tee /etc/init.d/udevmon

# Config: /etc/interception/udevmon.d/*.yaml
