kanata icon indicating copy to clipboard operation
kanata copied to clipboard

Bug: telegram-desktop (qt6) on archlinux does not work with unicode action

Open sekuba opened this issue 5 months ago • 6 comments

Requirements

Describe the bug

I am using the vanilla telegram-desktop package on archlinux. It is the only app so far that does not seem to work with kanata. Weirdly, instead of outputting ö, i get f6 and it is immediately sent (so probably the output includes a return.

each mapping yields a different message on telegram, like e4, fc and so on instead of the umlaut i would expect.

my config is quite simple, it's just the umlauts using altGr

Relevant kanata config

(defcfg
  process-unmapped-keys yes
  sequence-timeout 2000
)

(defsrc
  a    o    u    s
  ralt
)

(deflayer base
  _    _    _    _
  sldr  ;; sequence leader
)

(defseq
  ä (a)
  ö (o)
  ü (u)
  Ä (S-a)
  Ö (S-o)
  Ü (S-u)
  ß (s)
  ẞ (S-s)
)

(defvirtualkeys
  ä (unicode ä)
  ö (unicode ö)
  ü (unicode ü)
  Ä (unicode Ä)
  Ö (unicode Ö)
  Ü (unicode Ü)
  ß (unicode ß)
  ẞ (unicode ẞ)
)

To Reproduce

  1. install latest telegram-desktop package on arch with wayland
  2. use my kanata config
  3. use any of the remapped keys

Expected behavior

ralt + o: ö

Kanata version

1.9.0

Debug logs

here is me pressing ralt + o (should output ö but outputted f6 and return

➜  ~ sudo kanata --debug -c /home/sekuba/.config/kanata/kanata.kbd
19:25:27.5298 [INFO] kanata v1.9.0 starting
19:25:27.5300 [INFO] process unmapped keys: true
19:25:27.5301 [INFO] NOTE: kanata was compiled to never allow cmd
19:25:27.5301 [DEBUG] (1) kanata_parser::cfg::alloc: freeing allocations of length 0
19:25:27.5302 [INFO] config file is valid
19:25:27.5306 [INFO] Created device "/dev/input/event14"
19:25:27.5307 [DEBUG] (1) kanata_state_machine::kanata::output_logic::zippychord: zchd reset state
19:25:27.5307 [DEBUG] (1) kanata_state_machine::kanata::output_logic::zippychord: zchd soft reset state
19:25:27.5307 [DEBUG] (1) kanata_state_machine::kanata::output_logic::zippychord: zchd clear historical data
19:25:27.5307 [INFO] Sleeping for 2s. Please release all keys and don't press additional ones. Run kanata with --help to see how understand more and how to disable this sleep.
19:25:29.5309 [INFO] entering the processing loop
19:25:29.5311 [INFO] entering the event loop
19:25:29.5311 [INFO] looking for devices in /dev/input
19:25:29.5312 [INFO] Init: catching only releases and sending immediately
19:25:29.5532 [DEBUG] (1) kanata_state_machine::oskbd::linux: Use for input autodetect: false. Non-input device: HD-Audio Generic Headphone
19:25:29.5751 [DEBUG] (1) kanata_state_machine::oskbd::linux: Use for input autodetect: false. Non-input device: HD-Audio Generic HDMI/DP,pcm=9
19:25:29.6062 [DEBUG] (1) kanata_state_machine::oskbd::linux: Use for input autodetect: false. Non-input device: HD-Audio Generic HDMI/DP,pcm=8
19:25:29.6371 [DEBUG] (1) kanata_state_machine::oskbd::linux: Use for input autodetect: false. Non-input device: HD-Audio Generic HDMI/DP,pcm=7
19:25:29.6511 [DEBUG] (1) kanata_state_machine::oskbd::linux: Use for input autodetect: false. Non-input device: HD-Audio Generic HDMI/DP,pcm=3
19:25:29.6721 [DEBUG] (1) kanata_state_machine::oskbd::linux: Use for input autodetect: false. Non-input device: PIXA3854:00 093A:0274 Touchpad
19:25:29.6801 [DEBUG] (1) kanata_state_machine::oskbd::linux: Use for input autodetect: false. detect type KeyboardMice; device type Mouse, device name: PIXA3854:00 093A:0274 Mouse
19:25:29.6921 [DEBUG] (1) kanata_state_machine::oskbd::linux: Use for input autodetect: true. detect type KeyboardMice; device type Keyboard, device name: FRMW0004:00 32AC:0006 Consumer Control
19:25:29.6922 [DEBUG] (1) kanata_state_machine::oskbd::linux: Use for input autodetect: false. Non-input device: FRMW0004:00 32AC:0006 Wireless Radio Control
19:25:29.7041 [DEBUG] (1) kanata_state_machine::oskbd::linux: Use for input autodetect: false. Non-input device: PC Speaker
19:25:29.7281 [DEBUG] (1) kanata_state_machine::oskbd::linux: Use for input autodetect: false. Non-input device: Video Bus
19:25:29.7361 [DEBUG] (1) kanata_state_machine::oskbd::linux: Use for input autodetect: true. detect type KeyboardMice; device type Keyboard, device name: AT Translated Set 2 keyboard
19:25:29.7362 [DEBUG] (1) kanata_state_machine::oskbd::linux: Use for input autodetect: false. Non-input device: Power Button
19:25:29.7471 [DEBUG] (1) kanata_state_machine::oskbd::linux: Use for input autodetect: false. Non-input device: Lid Switch
19:25:29.7552 [INFO] registering /dev/input/event6: "FRMW0004:00 32AC:0006 Consumer Control"
19:25:29.7801 [INFO] registering /dev/input/event2: "AT Translated Set 2 keyboard"
19:25:30.0580 [INFO] Starting kanata proper
19:25:30.0581 [INFO] You may forcefully exit kanata by pressing lctl+spc+esc at any time. These keys refer to defsrc input, meaning BEFORE kanata remaps keys.
19:25:39.8899 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_RIGHTALT (100), value: Press }
19:25:39.8900 [DEBUG] (3) kanata_state_machine::kanata: entering sequence mode
19:25:40.0198 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_O (24), value: Press }
19:25:40.0198 [DEBUG] (3) kanata_state_machine::kanata::sequences: sequence got O
19:25:40.0198 [DEBUG] (3) kanata_state_machine::kanata::sequences: overlap seq is invalid; filling with standard seq
19:25:40.0198 [DEBUG] (3) kanata_state_machine::kanata::sequences: sequence complete; tapping fake key
19:25:40.0209 [DEBUG] (3) kanata_state_machine::kanata: key release   O
19:25:40.0209 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_O), value: 0 }
19:25:40.0209 [DEBUG] (3) kanata_state_machine::oskbd::linux: sending unicode ö
19:25:40.0209 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTCTRL), value: 1 }
19:25:40.0209 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTSHIFT), value: 1 }
19:25:40.0209 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_U), value: 1 }
19:25:40.0210 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_U), value: 0 }
19:25:40.0210 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTSHIFT), value: 0 }
19:25:40.0210 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTCTRL), value: 0 }
19:25:40.0210 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_F), value: 1 }
19:25:40.0210 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_F), value: 0 }
19:25:40.0210 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_6), value: 1 }
19:25:40.0210 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_6), value: 0 }
19:25:40.0210 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_ENTER), value: 1 }
19:25:40.0210 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_ENTER), value: 0 }
19:25:40.0512 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_RIGHTALT (100), value: Release }
19:25:40.1224 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_O (24), value: Release }

### Operating system

archlinux

### Additional context

_No response_

sekuba avatar Jul 22 '25 17:07 sekuba

You might want to try the clipboard actions for pasting unicode instead of the actual unicode action.

jtroo avatar Jul 23 '25 05:07 jtroo

hmm interesting thanks!

my actual usecase is just a more robust, cross-platform .XCompose where i can use my US keyboards to type german and french and occasional characters like the euro symbol. so editing my clipboard is not robust enough and interrupts the flow too often if i need it for every umlaut.

sekuba avatar Jul 23 '25 06:07 sekuba

I'm curious what specifically about the example is not robust enough / interrupts too much for your workflow? I am aware of some limitations, but unsure if those are what's impacting you.

E.g.

  • The 300 delay in the example may be too slow for your typing; and your system may respond to clipboard updates quickly enough that this could be shortened.
  • Macros execute in parallel and instead it might be worth having a blocking version of a macro, so that rapid use of clipboard actions do not interfere with each other, and also don't get become out of order with respect to other keypresses.

https://jtroo.github.io/config.html#clipboard-actions

(deftemplate text-paste (text)
 (macro
  (clipboard-save 0)
  20
  (clipboard-set $text)
  300
  C-v
  (clipboard-restore 0)
 ))

(defalias
 myalias1 (t! text-paste "Hello world")
 myalias2 (t! text-paste "Goodbye my old friend")
)

jtroo avatar Jul 24 '25 05:07 jtroo

i should try it out. i just imagine that it will break in weird ways, say my clipboard contains a large payload (will it restore nicely?) or some apps don't accept clipboard pastes the way that they would accept a keyboard input (neovim comes to mind or password fields).

on windows i am using the unmaintained wincompose and it just always works, no exceptions.

on linux i was using .XCompose and it worked sometimes but struggled with electron and some random other frameworks.

sekuba avatar Jul 24 '25 10:07 sekuba

I am finding this same issue with:

  • Kate
  • Konsole
  • Alacritty

and on Firefox I very clearly see a flash of the unicode (for example, it flashes 237a before changing to an ⍺ when doing the "(unicode ⍺)" action.

However, it works quite well in gedit and gnome-console on the same system.

Operating System: CachyOS Linux KDE Plasma Version: 6.5.1 KDE Frameworks Version: 6.19.0 Qt Version: 6.10.0 Kernel Version: 6.17.6-2-cachyos (64-bit) Graphics Platform: Wayland Processors: 8 × Intel® Core™ i5-8250U CPU @ 1.60GHz Memory: 16 GiB of RAM (15.5 GiB usable) Graphics Processor: Intel® UHD Graphics 620

rikedyp avatar Nov 07 '25 23:11 rikedyp

To be clear the problem with the unicode action is a problem of applications not supporting ibus unicode, which is why this issue is marked as blocked.

jtroo avatar Nov 09 '25 10:11 jtroo