feat: added keyd

This commit is contained in:
Klesh Wong 2022-05-23 01:41:26 +08:00
parent 83809467f9
commit a699d5a038
3 changed files with 70 additions and 0 deletions

22
cli/keyd.sh Normal file
View File

@ -0,0 +1,22 @@
#!/bin/sh
set -e
DIR=$(dirname "$(readlink -f "$0")")
. "$DIR/../env.sh"
log 'Setting up keyd'
# setup package mirror for CHINA
case "$UNAMEA" in
*Ubuntu*)
;;
*artix*)
yay -S keyd
sudo mkdir /etc/runit/sv/keyd/
sudo cp "$DIR/keyd/run" /etc/runit/sv/keyd/
sudo ln -s /etc/runit/sv/keyd/ /run/runit/service/
;;
esac
# configuration
sudo cp "$DIR/keyd/default.conf" /etc/keyd/default.conf

45
cli/keyd/default.conf Normal file
View File

@ -0,0 +1,45 @@
# NOTE: to use this, rename this file to default.conf and put in /etc/keyd/
# Advanced use of capslock as a triple function key:
#
# - when 'capslock' is tapped (pressed + released), it behaves as ESC key
#
# - when 'capslock' is held, and used in combination with another key, it
# behaves like a 'ctrl' key modifier (just like xcape)
#
# - when 'capslock' is held, and the 'space' key is tapped, we enter a 3rd
# state for "VIM mode" where hjkl keys become arrow keys until capslock
# is released.
#
[ids]
*
[main]
capslock = overload(vim_mode, `)
# ctrl_vim modifier layer; inherits from 'Ctrl' modifier layer
[ctrl_vim:C]
space = swap(vim_mode)
# vim_mode modifier layer; also inherits from 'Ctrl' modifier layer
[vim_mode]
h = left
j = down
k = up
l = right
# forward word
w = C-right
# backward word
b = C-left
u = C-pageup
i = C-pagedown
a = home
e = end
y = back
o = forward

3
cli/keyd/run Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
sv check keyd >/dev/null || exit 1
exec /usr/bin/keyd >/dev/null