(defcfg
  ;; For Linux
  ;; input  (device-file "$DEVICE") ;; gets dynamically replaced by nix
  ;; input  (device-file "/dev/input/by-path/pci-0000:00:14.0-usb-0:1:1.0-event-kbd") 
  input  (device-file "/dev/input/by-path/platform-i8042-serio-0-event-kbd") 
  output (uinput-sink "My KMonad output"
    ;; To understand the importance of the following line, see the section on
    ;; Compose-key sequences at the near-bottom of this file.
    "/run/current-system/sw/bin/sleep 1 && /run/current-system/sw/bin/setxkbmap -option compose:ralt")
  cmp-seq ralt    ;; Set the compose key to `RightAlt'
  cmp-seq-delay 5 ;; 5ms delay between each compose-key sequence press

  ;; Comment this is you want unhandled events not to be emitted
  fallthrough true

  ;; Set this to false to disable any command-execution in KMonad
  allow-cmd false
)

#|
(deflayer qwerty
  _    _    _    _    _    _    _    _    _    _    _    _    _    _    
  _    _    _    _    _    _    _    _    _    _    _    _    _    _    
  _    _    _    _    _    _    _    _    _    _    _    _    _    _    
  _    _    _    _    _    _    _    _    _    _    _    _    _ 
  _    _    _    _    _    _    _    _    _    _    _    _   
  _    _    _    _              _              _    _ 
)
|#

(defalias
  ga    #(ralt a h) ;; alpha
  gb    #(ralt b h) ;; beta
  gg    #(ralt g h) ;; gamma
  ge    #(ralt e h) ;; epsilon
  gt    #(ralt t h) ;; tau
  gl    #(ralt l h) ;; lambda
  gm    #(ralt m h) ;; miu
  gp    #(ralt p h) ;; pi
  gx    #(ralt x h) ;; xi
  gs    #(ralt s h) ;; sigma
  go    #(ralt o h) ;; omega
  gu    #(ralt u h) ;; uspilon

  gph   #(ralt l p h h) ;; phi
  gth   #(ralt l t h h) ;; theta
  gps   #(ralt l p s h) ;; psi

  Gu    #(ralt u j) ;; UPSILON
  Gg    #(ralt g j) ;; GAMMA
  Gd    #(ralt d j) ;; DELTAJ
  Gp    #(ralt p j) ;; PI
  Gs    #(ralt s j) ;; SIGMA
  Go    #(ralt o j) ;; OMEGA
  Gx    #(ralt x j) ;; XI

  neg   #(ralt l -) ;; ¬
  fal   #(ralt l v) ;; ∀
  ex    #(ralt l e) ;; ∃ 
  lar   #(ralt < -) ;; ←
  rar   #(ralt - >) ;; →
  and   #(ralt l c) ;; and symbol
  or    #(ralt l d) ;; or symbol
  eq    #(ralt e q) ;; Equivalence

  alp   #(ralt f \( ) ;; angled left parenthesis
  arp   #(ralt f \) ) ;; angled right parenthesis

  shrugFace #(ralt l s h r) ;; shrug face
  topBar #(ralt t -) ;; ¯
)

;; layers
(defalias
  mth  (layer-toggle math)
  Mth  (layer-toggle capital-math)
  mov  (layer-toggle movement)
  mathExtra (layer-toggle math-extra)
  sft (tap-macro lsft (layer-toggle shiftedQwerty)) ;; make this work differently based on the next key pressed
  j (tap-macro 7 lsft)
)

;; more "special" stuff
(defalias
  shr   #(@topBar \ \_ \_ \( @shrugFace \) \_ / @topBar) ;; ¯\_(ツ)_/¯

  ml    @gl
)

(defsrc
  esc  f1   f2   f3   f4   f5   f6   f7   f8   f9   f10  f11  f12  del
  grv  1    2    3    4    5    6    7    8    9    0    -    =    bspc
  tab  q    w    e    r    t    y    u    i    o    p    [    ]    \
  caps a    s    d    f    g    h    j    k    l    ;    '    ret
  lsft z    x    c    v    b    n    m    ,    .    /    rsft
  lctl lsgt lmet lalt           spc            ralt rctl
)

(deflayer qwerty
  esc  f1   f2   f3   f4   f5   f6   f7   f8   f9   f10  f11  f12  del
  grv  1    2    3    4    5    6    @j   8    9    0    -    =    bspc
  tab  q    w    e    r    t    y    u    i    o    p    [    ]    \
  @mth a    s    d    f    g    h    j    k    l    ;    '    ret
  @sft z    x    c    v    b    n    m    ,    .    /    rsft
  @mov lsgt lmet lalt           spc            ralt rctl
)

(deflayer shiftedQwerty
  _     _    _    _    _    _    _    _    _    _    _    _    _    _    
  _     !    @    #    $    %    ^    &    8    \(   \)   _    +    S-bspc
  S-tab Q    W    E    R    T    Y    U    I    O    P    {    }    |
  @Mth  A    S    D    F    G    H    J    K    L    :    "    S-ret
  XX    Z    X    C    V    B    N    M    <    >    ?    _
  _     _    _    _              S-spc          S-ralt S-rctl
)

(deflayer movement
  _    _    _    _    _    _    _    _    _    _    _    _    _    _    
  _    _    _    _    _    _    _    _    _    _    _    _    _    _    
  _    _    _    _    _    _    _    _    _    _    _    _    _    _    
  _    _    _    _    _    _    lft  down up   rght _    _    _ 
  _    _    _    _    _    _    _    _    _    _    _    _   
  _    _    _    _              _              _    _ 
)

(deflayer math-extra
  _    _    _    _    _    _    _    _    _    _    _    _    _    _    
  _    _    _    _    _    _    _    _    _    _    _    _    _    _    
  _    _    _    @eq  _    _    _    _    _    @or  _    _    _    _    
  _    @and _    _    _    _    _    _    _    _    _    _    _ 
  _    _    _    _    _    _    _    _    _    _    _    _   
  _    _    _    _              _              _    _ 
)

(deflayer math
  _    _    _    _    _    _    _    _    _    _    _    _    _    _    
  _    _    _    @ex  _    _    _    _    _    @alp @arp @neg _    _    
  _    @shr @go  @ge  _    @gt  _    @gu  _    @go  @gp  _    _    _    
  _    @ga  @gs  _    _    @gg  @gth @gps @gph @ml  _    _    _ 
  @Mth _    @gx  _    @fal @gb  _    @gm  @lar @rar _    _   
  _    _    _    _              @mathExtra          _    _ 
)

(deflayer capital-math
  _    _    _    _    _    _    _    _    _    _    _    _    _    _    
  _    _    _    _    _    _    _    _    _    _    _    _    _    _    
  _    _    _    _    _    _    _    @Gu  _    @Go  @Gp  _    _    _    
  _    _    @Gs  @Gd  _    @Gg  _    _    _    _    _    _    _ 
  _    _    @Gx  _    _    _    _    _    _    _    _    _   
  _    _    _    _              _              _    _ 
)