keyd icon indicating copy to clipboard operation
keyd copied to clipboard

"macro2" fires the macro immediately instead of after <timeout>, causing timing inconsistencies

Open ETHREAL1 opened this issue 1 month ago • 0 comments

Hello!

System info of relevance;

  • keyd version: v2.5.0
  • OS: Manjaro
  • Kernal: 6.12.48-1-MANJARO (64-bit)
  • Desktop env.: KDE Plasma v6.3.6, KDE framework v6.18.0
  • graphics Platform: Wayland

The macro2 function appears to trigger the first macro execution immediately on key press rather than waiting for the timeout period to expire. This leads to inconsistent timing behavior where the first run of the macro runs instantly, and the first repeat begins after the timeout, often overlapping or creating a stutter depending on macro duration.

The expected behavior is that macro2 should delay the first macro execution until after the timeout of the key being held, then repeat every <repeat_timeout> while the key remains pressed. An example of the expected logic is as follows;

on hold:

  1. wait (timeout)
  2. run macro
  3. after repeat timeout: start repeating every repeat timeout

Currently it behaves like;

on hold:

  1. run macro
  2. after timeout: start repeating every repeat timeout

This causes:

  • An instant first macro (ignoring the hold delay).
  • The first repeat firing ms after keypress (not after macro completion, or very quickly after first run).
  • Overlap/stutter when the macro duration is near the timeout threshold.

This can be easily reproduced with the line;

A = macro2(600, 1000, macro(B 500ms C)) and monitored with keyd monitor

Observed sequence:

  1. On pressing A, "B > 500ms > C" occurs immediately.
  2. ~600 ms after the key stared to be held, the macro triggers again, causing a stutter in this case when the second run of the macro is but 100ms after the first.
  3. Further repeats continue every 1000ms as intended.

In a pure timeline based output of events since the key started to be held it would be as follows;

  • 0000ms = B
  • 0500ms = C
  • 0600ms = B
  • 1100ms = C
  • 1600ms = B
  • 2100ms = C

and so on. Note the second and third line. since What is expected is;

  • 0600ms = B
  • 1100ms = C
  • 1600ms = B
  • 2100ms = C
  • 2600ms = B
  • 3100ms = C

Setting both values equal (macro2(1000, 1000, ...)) makes it fire immediately, then repeat cleanly, confirming that affects only repeat scheduling.

ETHREAL1 avatar Nov 10 '25 08:11 ETHREAL1