48 lines
1.9 KiB
Bash
Executable file
48 lines
1.9 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
|
|
# See LICENSE.md for license information.
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
# verify-win32-icon.sh - a Win32 program's icon on its window.
|
|
#
|
|
# make links every Win32 program's icon into it (make/win32.mk:
|
|
# tools/iconBake.py ico, 16, 32 and 48 pixels in 256 colours and in 32-bit,
|
|
# resource HOSTED_ICON_ID), and the backend gives its window class that
|
|
# icon. DRAW (examples/draw) runs under Wine (scripts/lib/wineGate.sh), which
|
|
# hands a window's class icon to X as its _NET_WM_ICON; that must be the
|
|
# baked 32x32 32-bit picture (scripts/lib/netWmIcon.py).
|
|
#
|
|
# Usage: scripts/verify-win32-icon.sh
|
|
# Exit: 0 PASS, 1 FAIL, 2 SKIP (Wine not installed, or DRAW not built)
|
|
# Requires: Wine, Xvfb, xdotool, xprop, python3 + PIL; DRAW.EXE and its icon
|
|
# (make win32).
|
|
set -uo pipefail
|
|
|
|
repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
|
source "$repo/scripts/lib/joeyEnv.sh"
|
|
source "$repo/scripts/lib/wineGate.sh"
|
|
|
|
label=verify-win32-icon
|
|
wineNeed
|
|
program=$(joeyExampleProgram draw win32)
|
|
icon=$repo/build/win32/icon/DRAW/icon.ico
|
|
# The size Wine gives X: the class's icon, Windows' standard icon size.
|
|
ICON_SIZE=32
|
|
[ -f "$program" ] && [ -f "$icon" ] || { echo "$label: build DRAW.EXE first (make win32)" >&2; exit 2; }
|
|
|
|
work=$(mktemp -d -t joeylib-win32-icon.XXXXXX)
|
|
cleanup() {
|
|
wineStop
|
|
rm -rf "$work"
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
mkdir -p "$work/program"
|
|
cp "$program" "$work/program/DRAW.EXE"
|
|
wineStart "$work"
|
|
wineRun "$work/program/DRAW.EXE"
|
|
win=$(wineWindow DRAW) || { echo "$label: FAIL - DRAW's window never appeared" >&2; exit 1; }
|
|
# Wine sets the property as the window is mapped; a moment for it.
|
|
sleep 2
|
|
xprop -id "$win" -f _NET_WM_ICON 32c ' = $0+' _NET_WM_ICON > "$work/icon.txt" 2>&1
|
|
python3 "$repo/scripts/lib/netWmIcon.py" "$work/icon.txt" "$icon" "$ICON_SIZE" "$label"
|