jtroo / kanata

Improve keyboard comfort and usability with advanced customization
GNU Lesser General Public License v3.0
2.64k stars 123 forks source link

Bug: fn does not toggle Touch Bar change on Mac #1311

Open rkosmala opened 5 days ago

rkosmala commented 5 days ago

Requirements

Describe the bug

Mac OS allows configuring Touch Bar stripe to change it's state depending on fn being pressed or not. When kanata is executing Touch Bar becomes frozen in the state it was upon kanata startup and no longer respond to fn being pressed. It seems irrelevant what functions are assigned to both Touch Bar states in OSX System Preferences. Mapping standard keys in layer triggered with fn works fine.

Relevant kanata config

(defcfg
  danger-enable-cmd yes
  process-unmapped-keys yes
)

(defvar
  tap-timeout   250
  hold-timeout  250
)

(deftemplate tap-hold-tmpl (tap-key early-hold-release-list hold-action)
  (tap-hold-release-keys $tap-timeout $hold-timeout (multi $tap-key @tap) $hold-action $early-hold-release-list)
)

(defalias
    fn (tap-hold $tap-timeout $hold-timeout fn (layer-toggle function))
)

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

(deflayer base
  @bl  brdn brup _    @spt bldn blup prev pp   next mute vold volu            _    _    _
       _    _    _    _    _    _    _    _    _    _    _    _    @bl        _    _    _
  @bl  _    @w   @e   @r   _    _         _    @i   @o   _    _    _    @bl   _    _    _
  lctl @a   @s   @d   @f   _    _         _    @k   @l   @;   @'   _
  @bl  _    _    _    @c   _    _    _    _    _    _    _    @bl                  @bl
  @fn  caps @bl  @bl            @sp                 @bl  @ct  @bl  @bl        @bl  @bl  @bl
)

(deflayer function
  _    f1   f2   f3   f4   f5   f6   f7   f8   f9   f10  f11  f12             _    _    _
       _    _    _    _    _    _    _    _    _    _    _    _    del        _    _    _
  _    _    _    _    _    _    _         _    _    _    _    _    _    _     _    _    _
  _    _    _    _    _    _    _         _    _    _    _    _    _
  _    lrld _    _    _    _    _    _    _    _    _    _    _                    pgup
  _    _    _    _              _                   _    _    _    _          home pgdn end
)

To Reproduce

  1. set up OS X preferences for Touch Bar to: Touch Bar shows: Extended Control Strip, Press and hold fn key to: Show F1, F2, etc. keys
  2. run kanata (fn key released upon startup)
  3. press fn key

Expected behavior

Touch Bar shows F1, F2 keys

Kanata version

1.7.0

Debug logs

No response

Operating system

Mac OS Sonoma 14.6.1

Additional context

No response

jtroo commented 4 days ago

Does karabiner handle this correctly? Is there any insight to be gained from this ticket: https://github.com/jtroo/kanata/issues/975 ?

rkosmala commented 3 days ago

To my understanding #975 only proposes some workaround to put different functions which Touch Bar provides (volume, brightness control, etc), as a programatic layer under F1-F12 keys with Fn modifier. I have found this description in Karabiner Elements docs. Does it means kanata is also unable to signal Mac to change Touch Bar as it acts upon KE virtual keyboard? Don't know if it's relevant, but on System preferences->Keyboard Shortcuts->Modifier Keys I see KE virtual driver provides Globe key, whereas on older Macs with Touch Bar internal keyboard shows Function Key instead.