feat: Adds mouse and arrow layer to voyager keyboard layouts, adds config subcommand to kanatactl to copy the appropriate config based on keyboard type.

This commit is contained in:
2025-10-13 12:48:14 -04:00
parent f1202d77f3
commit ee2898053b
3 changed files with 56 additions and 27 deletions

View File

@@ -1,3 +1,6 @@
;; Macbook-Pro configuration file.
;;
;; Adapted from https://github.com/linkarzu/dotfiles-latest/blob/main/kanata/configs/macbook-subl.kbd
;; Video related to this file
;; https://youtu.be/jvJ3f4HHiMY

View File

@@ -1,3 +1,6 @@
;; ZSA Voyager configuration file.
;;
;; Adapted from https://github.com/linkarzu/dotfiles-latest/blob/main/kanata/configs/macbook-subl.kbd
;; Video related to this file
;; https://youtu.be/jvJ3f4HHiMY
@@ -67,8 +70,8 @@
mrnums (tap-hold-press $tap-time-plus $hold-time-plus spc (layer-while-held nums_and_symbols))
;; mouse layer trigger keys.
;;mlms (tap-hold-press $tap-time $hold-time lsft (layer-while-held mouse))
;;mrms (tap-hold-press $tap-time $hold-time rsft (layer-while-held mouse))
mlms (tap-hold-press $tap-time $hold-time esc (layer-while-held mouse))
mrms (tap-hold-press $tap-time $hold-time ' (layer-while-held mouse))
;; Multi
mhypr (tap-hold $tap-time $hold-time bspc (multi lsft lctl lalt lmet)) ;; Hyper key
@@ -100,27 +103,17 @@
(deflayer main
= 1 2 3 4 5 6 7 8 9 0 -
grv q w e r t y u i o p \
esc @mlctl @mlalt @mlmet @mlsft g h @mrsft @mrmet @mralt @mrctl '
@mlms @mlctl @mlalt @mlmet @mlsft g h @mrsft @mrmet @mralt @mrctl @mrms
lsft z x c v b n m , . / rsft
@mlnums tab @mhypr @mrnums
)
;; Number and Symbols layer
;; (deflayer nums_and_symbols
;; esc XX XX XX XX XX XX XX XX XX XX XX XX
;; grv XX XX XX XX XX XX XX XX XX XX - = bspc
;; S-grv S-1 S-9 S-0 S-2 XX XX 1 2 3 \ XX XX XX
;; XX [ ] S-[ S-] XX XX 4 5 6 . XX ret
;; lsft S-7 S-8 S-4 S-3 XX XX 7 8 9 / XX rsft
;; lctl lalt lmet 0 rmet ralt ◀ ▼ ▶
;; )
;; Number and Symbols layer
(deflayer nums_and_symbols
= XX XX XX XX XX XX XX XX XX XX -
S-grv S-1 S-9 S-0 S-2 XX - 1 2 3 \ \
XX [ ] S-[ S-] XX S-= 4 5 6 . '
lsft S-7 S-8 S-4 S-3 XX S-8 7 8 9 / rsft
lsft S-7 S-8 S-3 S-4 XX S-8 7 8 9 / rsft
@mlnums tab @mhypr 0
)
@@ -146,13 +139,10 @@
)
;; Mouse and arrow layer
;; (deflayer mouse
;; esc XX XX XX XX XX XX XX XX XX XX XX XX ;; function row
;; grv XX XX XX XX XX XX XX XX XX XX XX XX bspc ;; number row
;; tab XX XX XX XX @mwl @mwd @mwu @mwr XX XX XX XX ;; top letter row
;; caps XX ◀ ▼ ▶ XX @ma← @ma↓ @ma↑ @ma→ XX XX mrtp ;; home row
;; lsft XX XX XX XX XX XX XX XX XX XX XX rsft ;; bottom letter row
;; lctl lalt lmet mltp rmet ralt XX XX XX ;; control row
;; )
;;
(deflayer mouse
XX XX XX XX XX XX XX XX XX XX XX XX
XX XX XX XX XX @mwl @mwd @mwu @mwr XX XX
XX XX XX @ma← @ma↓ @ma↑ @ma→ XX XX
XX XX XX XX XX XX XX XX XX XX XX XX
ret tab mltp mrtp
)

View File

@@ -12,12 +12,13 @@ LOG_FILE=${LOG_FILE:-"$LOG_LABEL.log"}
XDG_DATA_HOME=${XDG_DATA_HOME:-"$HOME/.local/share"}
XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-"$HOME/.config"}
DEV_ENV=${DEV_ENV:-""}
KBD=${KBD:-""} # Keyboard config to use, either "voyager" or "macbook"
usage() {
cat <<EOF
Manages kanata qmk keyboard program, which needs to be built locally. Currently the linux builds
are only for x86. Also can manage as a systemd service.
are only for x86. Also manages the kanata systemd service.
USAGE:
@@ -28,6 +29,7 @@ FLAGS:
COMMANDS:
bootstrap: Bootstrap a new machine, performs installation, enables, and starts kanata systemd service.
config <kbd>: Copy the keyboard configuration files for the keyboard type (macbook or voyager).
disable: Stop and disable the kanata systemd service.
install: Build and install kanata, prompts you to choose the version to install.
logs: View the log file.
@@ -228,6 +230,37 @@ bootstrap() {
enable_and_start_service
}
# Copy the configuration files based on keyboard type (either macbook or voyager).
copy_config() {
local kbd=${1:-""}
if [[ -z $kbd ]] && [[ -n $KBD ]]; then
kbd=$KBD
fi
if [[ -z $DEV_ENV ]]; then
log --error "DEV_ENV not set properly." && exit 1
fi
if [[ -z $kbd ]]; then
log --error "Keyboard not set." && exit 1
fi
log "Copying configuration: '$kbd'..."
mkdir $XDG_CONFIG_HOME/kanata &>/dev/null
if [[ $kbd == "macbook" ]]; then
log "Copying macbook configuration."
cp "$DEV_ENV/env/.config/kanata/config.kbd" "$XDG_CONFIG_HOME/kanata/config.kbd"
elif [[ $kbd == "voyager" ]]; then
log "Copying voyager configuration."
cp "$DEV_ENV/env/.config/kanata/voyager.kbd" "$XDG_CONFIG_HOME/kanata/config.kbd"
else
log --error "Invalid keyboard: '$kbd'" && exit 1
fi
}
################################################################################
# MAIN
################################################################################
@@ -241,6 +274,9 @@ while [[ $# -gt 0 ]]; do
usage && exit 0
elif [[ $1 == "bootstrap" ]]; then
bootstrap && exit 0
elif [[ $1 == "config" ]]; then
shift
copy_config "$@" && exit $?
elif [[ $1 == "disable" ]]; then
disable_service && exit $?
elif [[ $1 == "start" ]]; then