moses-palmer / pynput

Sends virtual input commands
GNU Lesser General Public License v3.0
1.79k stars 248 forks source link

Don't parse compose lines from dumpkeys (uinput) #355

Closed puschkin closed 3 years ago

puschkin commented 3 years ago

Compose can contain unicode characters. for example: compose '�' 'A' to Aring

Reading them with subprocess.check_output(..).decode('utf-8') leads to: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 0: invalid start byte

dumpkeys has a parameter --keys-only, that avoids printing the compose keys. More information here: https://man7.org/linux/man-pages/man1/dumpkeys.1.html

Since only the lines that begin with 'keycode' are used, the usage of --keys-only is safe.

puschkin commented 3 years ago

I had the issue on 2 systems: Archlinux with python 3.9 Debian 9 with python 3.5

Is there more information/testing required?

moses-palmer commented 3 years ago

Thank you very much for your contribution!

I have merged this into master.