#!/usr/bin/env bash output=$(sed -n 's/^#define XKB_KEY_\([a-zA-Z_0-9]\+\)\s\+\(0x[0-9a-f]\+\).*/\t{"\1", {\2}},/p' /usr/include/xkbcommon/xkbcommon-keysyms.h) len=$(wc -l <<<"$output") if [[ $1 = --source ]]; then cat <, $len> keysym_table{{ $output }}; EOF elif [[ $1 = --header ]]; then cat < #include #include "xutil.h" extern const std::array, $len> keysym_table; EOF else echo >&2 "$0: invalid flags" exit 1 fi