Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asahi: fn keycode in defsrc results in file parse error #828

Open
montchr opened this issue Mar 21, 2024 · 1 comment
Open

asahi: fn keycode in defsrc results in file parse error #828

montchr opened this issue Mar 21, 2024 · 1 comment

Comments

@montchr
Copy link

montchr commented Mar 21, 2024

I copied the template from https://github.com/kmonad/kmonad/blob/master/keymap/template/apple.kbd with some slight alterations in an attempt to get KMonad working with the internal Apple keyboard on an M2 MacBook Air running Asahi-NixOS.

I am configuring the defcfg block via the provided NixOS module. Then, I try this configuration:

(defsrc
 esc  f1   f2   f3   f4   f5   f6   f7   f8   f9   f10  f11  f12
 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 up
 fn   lctl lmet lalt           spc            ralt rmet left down rght
 )

(defalias fn (around (layer-toggle apple) fn))

(deflayer default
          _    f1   f2   f3   f4   f5   f6   f7   f8   f9   f10  f11  f12
          _    _    _    _    _    _    _    _    _    _    _    _    _    _
          _    _    _    _    _    _    _    _    _    _    _    _    _    _
          _    _    _    _    _    _    _    _    _    _    _    _    _
          _    _    _    _    _    _    _    _    _    _    _    _    _
          @fn  _    _    _              _              _    _    _    _    _
          )

(defalias
  dsh dashboard
  rec record
  )

(deflayer apple
          _    brdn brup @dsh find @rec XX   prev pp   next mute vold volu
          _    _    _    _    _    _    _    _    _    _    _    _    _    _
          _    _    _    _    _    _    _    _    _    _    _    _    _    _
          _    _    _    _    _    _    _    _    _    _    _    _    _
          _    _    _    _    _    _    _    _    _    _    _    _    _
          _    _    _    _              _              _    _    _    _    _
          )

And the build fails every time when it gets to fn in the defsrc:

kmonad: Parse error at 16:2:
   |
16 |  fn   lctl lmet lalt           spc            ralt rmet left down rght
   |  ^
unexpected 'f'
expecting ')'

Based on what I see in the keycodes file, the fn keycode is only allowed on Darwin, so I imagine that's why there's a parse error.

If it helps, here's the output of wev when I press the Fn key:

[14:     wl_keyboard] key: serial: 24579; time: 13972728; key: 472; state: 1 (pressed)
                      sym: XF86Fn       (268964304), utf8: ''

Edit:

If I omit fn from the defsrc, an error occurs in the defalias where I also tried to use fn:

kmonad: Parse error at 29:44:
   |
29 | (defalias fn (around (layer-toggle apple) fn))
   |                                            ^
Unrecognized compose-char

Once I remove all traces of fn, the file parses and the build succeeds.

@slotThe
Copy link
Member

slotThe commented Apr 27, 2024

Seems like Keycode.hs has a conditional that prevents this key from being available on non-darwin hosts:

data Keycode#ifdef darwin_HOST_OS
  | KeyFn
  | KeyLaunchpad
  | KeyMissionCtrl
  | KeySpotlight
  | KeyDictation
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants