69a1cdac1d
screencast_icon/ holds the single source icon set; meson install ships the 256 px PNG into the hicolor theme for the GTK panel (themed icon name) and the waybar CSS, and a custom target embeds it as icon_png_data.h so the SDL receiver window sets it via SDL_SetWindowIcon with an optional SDL3_image dependency (built-in find_library, since no pkg-config file ships with it).
40 lines
881 B
Python
Executable File
40 lines
881 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""Generate a C++ header that embeds an image file as a byte array.
|
|
|
|
Usage: icon_to_header.py INPUT_IMAGE OUTPUT_HEADER
|
|
"""
|
|
|
|
import sys
|
|
|
|
|
|
def main() -> int:
|
|
if len(sys.argv) != 3:
|
|
print(f"usage: {sys.argv[0]} INPUT_IMAGE OUTPUT_HEADER", file=sys.stderr)
|
|
return 2
|
|
|
|
with open(sys.argv[1], "rb") as src:
|
|
data = src.read()
|
|
|
|
words = ", ".join(f"0x{byte:02x}" for byte in data)
|
|
header = f"""// GENERATED FILE - do not edit by hand.
|
|
// Produced by scripts/icon_to_header.py from screencast_icon/screencast_256.png.
|
|
|
|
#pragma once
|
|
|
|
#include <array>
|
|
#include <cstdint>
|
|
|
|
namespace sc {{
|
|
inline constexpr std::array<std::uint8_t, {len(data)}> app_icon_png = {{
|
|
{words}
|
|
}};
|
|
}} // namespace sc
|
|
"""
|
|
with open(sys.argv[2], "w") as dst:
|
|
dst.write(header)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|