Skip to content

Instantly share code, notes, and snippets.

View axelkar's full-sized avatar

Axel Karjalainen axelkar

View GitHub Profile
@axelkar
axelkar / README.md
Last active August 17, 2025 15:29
Decompress transparently compressed files on Windows

Using NTFS's/Window's transparent compression was a mistake for a media library. Here's a Nushell script to decompress all files recursively.

./decompress-dir.nu ./dir

# or natively in Nushell, with tab-completions

use ./decompress-dir.nu
decompress-dir ./dir
@axelkar
axelkar / diagram.md
Last active August 17, 2025 13:53
Diagram of Linux keycodes, XKB keysyms, and scancodes

Keycodes don't change with the keyboard layout. For example, the key labeled Y on a QWERTY keyboard will result in the same evdev keycode (KEY_Y in input-event-codes.h) as the key labeled Z on a QWERTZ keyboard.

X11 reserves keycodes 0-7, and as such it offsets Linux/evdev keycodes by 8 values to make space for them. Wayland doesn't do this12, and usually compositors just pass the keycodes from libinput/evdev as-is.

xkbcommon is provided with a keymap, and it's used to get modifier states from keycodes and to convert from X11 keycodes (offset by 8 from Linux/evdev keycodes; termed as "Raw keycodes" in xkbcommon) to keysyms.

Footnotes

  1. wev, a wayland event viewer does manually offset the keycodes to make them into X11 keycodes

  2. [Smithay](https://github.com/Smithay/sm

@axelkar
axelkar / usbmuxd.lua
Last active June 19, 2024 00:16
Usbmuxd protocol dissector for Wireshark. Passes TCP to Wireshark's built-in TCP dissector
local proto_usbmuxd = Proto("usbmuxd", "Usbmuxd Protocol")
proto_usbmuxd.fields.protocol = ProtoField.uint32("usbmuxd.protocol", "Message Kind", base.DEC)
proto_usbmuxd.fields.length = ProtoField.uint32("usbmuxd.length", "Length", base.DEC)
proto_usbmuxd.fields.magic = ProtoField.uint32("usbmuxd.magic", "Magic", base.HEX)
proto_usbmuxd.fields.tx_seq = ProtoField.uint16("usbmuxd.tx_seq", "Transmit sequence", base.DEC)
proto_usbmuxd.fields.rx_seq = ProtoField.uint16("usbmuxd.rx_seq", "Receive sequence", base.DEC)
proto_usbmuxd.fields.version_major = ProtoField.uint32("usbmuxd.version_major", "Major version", base.DEC)
proto_usbmuxd.fields.version_minor = ProtoField.uint32("usbmuxd.version_minor", "Minor version", base.DEC)