Running foot generate-alt-random-writes.py --sixel would occasionally fail with a ValueError: empty range for randrange() here.
This happened whenever generate-alt-random-writes.py started fast enough for it to do the TIOCGWINSZ ioctl before the foot window had been mapped. At this point, the TIOCGWINSZ response is a hardcoded lines=24, cols=80, width/height=0. The lines/cols are basically placeholders - we don't have a window size yet, thus we don't have an actual lines/cols count yet. Width/height being zero is due to the fonts not yet having been loaded - we don't have a cell geometry yet.
This PR updates the generate-alt-random-writes.py script to detect width/height=0, and then wait for a SIGWINCH signal before trying again. Not all terminals fill in anything in the ws_xpixel and ws_ypixel fields in the TIOCGWINSZ response; generate-alt-random-writes.py will now hang on these terminals. But this is ok, because a) it isn't intended to be run on anything else, and b) it used to crash in those terminals anyway.
Alternatives: if we decide to implement #453, we could use that in the PKGBUILD. Perhaps rather than an alternative, it should be considered an enhancement to this PR; with this PR, we typically don't get the final window size (when run on a tiling compositor) - we get an intermediate window size: foot's initial-widow-size-{pixels,chars}. For our purposes, generating profiling data, this should be ok.
Running `foot generate-alt-random-writes.py --sixel` would occasionally fail with a `ValueError: empty range for randrange()` [here](https://codeberg.org/dnkl/foot/src/commit/4044b6fa99d6cd464ad926993059c6e76fc81d14/scripts/generate-alt-random-writes.py#L179).
This happened whenever `generate-alt-random-writes.py` started fast enough for it to do the `TIOCGWINSZ` ioctl **before** the foot window had been mapped. At this point, the `TIOCGWINSZ` response is a hardcoded lines=24, cols=80, width/height=0. The lines/cols are basically placeholders - we don't have a window size yet, thus we don't have an actual lines/cols count yet. Width/height being zero is due to the fonts not yet having been loaded - we don't have a cell geometry yet.
This PR updates the `generate-alt-random-writes.py` script to detect width/height=0, and then wait for a `SIGWINCH` signal before trying again. Not all terminals fill in anything in the `ws_xpixel` and `ws_ypixel` fields in the `TIOCGWINSZ` response; `generate-alt-random-writes.py` will now hang on these terminals. But this is ok, because a) it isn't intended to be run on anything else, and b) it used to crash in those terminals anyway.
Alternatives: if we decide to implement https://codeberg.org/dnkl/foot/issues/453, we could use that in the PKGBUILD. Perhaps rather than an alternative, it should be considered an enhancement to this PR; with this PR, we typically don't get the **final** window size (when run on a tiling compositor) - we get an intermediate window size: foot's `initial-widow-size-{pixels,chars}`. For our purposes, generating profiling data, this _should_ be ok.