# example.yaml
#
# Commands are defined like so:
#
#     id: command
# or  id: [ keydown-command, keyup-command ]
#
# Commands can take parameters substituted into $ placeholders,
# where $0 is the first parameter, $1 the second, etc.
#
# Sidechain rules are defined as above but with the id
# replaced by a regular-expression /regexp/: command
#

# key chords denoted by infix +
#
# modifier aliases (like S+ for Shift_L+) are defined in ../io/command.yaml
type-an-asterisk: S+8

# key sequences
#
# integers 0..9 are digits, otherwise time delay in milliseconds
# a trailing delay denotes auto repeat
345: 3 500 4 500 5 1000
#
# separate up and down sequences denoted by array [down, up]
#
# explicit keydown denoted by prefix +
# explicit keyup denoted by prefix -
#
# emit 'Hello' on rkeydown and 'World' on rkeyup
HelloWorld: [ H e l l o, +Shift_L w -Shift_L o r l d ]

# scripts
#
0to9: livescript [0 to 9].join ','
jkl : javascript var s=_.repeat('j k l,', $0); _.trimRight(s, ',')
now : livescript _.map(new Date!toString!, -> it.replace ' ' \space).join ','

# compose key sequences for special characters
#
# compose key alias (system dependent so redefine as required)
COMPOSE: alias Super_L
#
# example sequences for US keyboard layout
# see https://help.ubuntu.com/community/ComposeKey#Compose%20key%20sequences
#
'£': COMPOSE l XK_minus
'¶': COMPOSE p XK_exclam
'½': COMPOSE 1 2

# exec shell command
echo : exec echo $0 and $1 with $2
xterm: exec xterm -fg red

# sound sidechain
#
/.*/:
  /^d$/: PLAY-SOUND SFX-BLIP
  /^e$/: PLAY-SOUND SFX-CHIRP
  /^f$/: PLAY-SOUND SFX-DROID
  /^g$/: PLAY-SOUND SFX-NOISE
  /^h$/: [ PLAY-SOUND SFX-TICK, PLAY-SOUND SFX-TOCK ]
# uncomment the following line to make any abc sequence chirp
#  /^abc/: PLAY-SOUND SFX-CHIRP
# uncomment the following line to play a noise on any other key
#  /.*/: PLAY-SOUND SFX-NOISE
#
# set up the shell command to play a sound. This is heavily
# dependent on the sytem so you may need to tweak it.
# Here we use alsa's aplay command and suppress output.
PLAY-SOUND: alias exec aplay --quiet
