mirror of
https://git.sr.ht/~calebccff/pbsplash
synced 2026-01-12 20:48:40 -09:00
getopt: make logo_size_max configurable with -q
This commit is contained in:
parent
67c9a10db4
commit
f94f3269da
1 changed files with 16 additions and 6 deletions
|
|
@ -51,13 +51,14 @@ int usage()
|
||||||
fprintf(stderr, "pbsplash: postmarketOS bootsplash generator\n");
|
fprintf(stderr, "pbsplash: postmarketOS bootsplash generator\n");
|
||||||
fprintf(stderr, "-------------------------------------------\n");
|
fprintf(stderr, "-------------------------------------------\n");
|
||||||
fprintf(stderr, "pbsplash [-v] [-h] [-f font] [-s splash image] [-m message]\n");
|
fprintf(stderr, "pbsplash [-v] [-h] [-f font] [-s splash image] [-m message]\n");
|
||||||
fprintf(stderr, " [-p font size] [-d]\n\n");
|
fprintf(stderr, " [-p font size] [-q max logo size] [-d]\n\n");
|
||||||
fprintf(stderr, " -v enable verbose logging\n");
|
fprintf(stderr, " -v enable verbose logging\n");
|
||||||
fprintf(stderr, " -h show this help\n");
|
fprintf(stderr, " -h show this help\n");
|
||||||
fprintf(stderr, " -f path to SVG font file (default: %s)\n", DEFAULT_FONT_PATH);
|
fprintf(stderr, " -f path to SVG font file (default: %s)\n", DEFAULT_FONT_PATH);
|
||||||
fprintf(stderr, " -s path to splash image to display\n");
|
fprintf(stderr, " -s path to splash image to display\n");
|
||||||
fprintf(stderr, " -m message to show under the splash image\n");
|
fprintf(stderr, " -m message to show under the splash image\n");
|
||||||
fprintf(stderr, " -p font size in pt (default: %d)\n", FONT_SIZE_PT);
|
fprintf(stderr, " -p font size in pt (default: %d)\n", FONT_SIZE_PT);
|
||||||
|
fprintf(stderr, " -q max logo size in mm (default: %d)\n", LOGO_SIZE_MAX_MM);
|
||||||
fprintf(stderr, " -d custom DPI (for testing)\n");
|
fprintf(stderr, " -d custom DPI (for testing)\n");
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
|
@ -212,6 +213,7 @@ int main(int argc, char **argv)
|
||||||
NSVGimage *font = NULL;
|
NSVGimage *font = NULL;
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
float font_size = FONT_SIZE_PT;
|
float font_size = FONT_SIZE_PT;
|
||||||
|
float logo_size_max = LOGO_SIZE_MAX_MM;
|
||||||
int optflag;
|
int optflag;
|
||||||
long dpi = 0;
|
long dpi = 0;
|
||||||
|
|
||||||
|
|
@ -223,7 +225,7 @@ int main(int argc, char **argv)
|
||||||
sigaction(SIGTERM, &action, NULL);
|
sigaction(SIGTERM, &action, NULL);
|
||||||
sigaction(SIGINT, &action, NULL);
|
sigaction(SIGINT, &action, NULL);
|
||||||
|
|
||||||
while ((optflag = getopt(argc, argv, "hvf:s:m:p:d:")) != -1) {
|
while ((optflag = getopt(argc, argv, "hvf:s:m:p:q:d:")) != -1) {
|
||||||
char *end = NULL;
|
char *end = NULL;
|
||||||
switch (optflag) {
|
switch (optflag) {
|
||||||
case 'h':
|
case 'h':
|
||||||
|
|
@ -248,6 +250,14 @@ int main(int argc, char **argv)
|
||||||
return usage();
|
return usage();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'q':
|
||||||
|
logo_size_max = strtof(optarg, &end);
|
||||||
|
if (end == optarg) {
|
||||||
|
fprintf(stderr, "Invalid max logo size: %s\n",
|
||||||
|
optarg);
|
||||||
|
return usage();
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
dpi = strtol(optarg, &end, 10);
|
dpi = strtol(optarg, &end, 10);
|
||||||
if (end == optarg) {
|
if (end == optarg) {
|
||||||
|
|
@ -300,12 +310,12 @@ int main(int argc, char **argv)
|
||||||
float logo_size_px = (float)(screenWidth < screenHeight ? screenWidth : screenHeight) * 0.75f;
|
float logo_size_px = (float)(screenWidth < screenHeight ? screenWidth : screenHeight) * 0.75f;
|
||||||
if (w_mm > 0 && h_mm > 0) {
|
if (w_mm > 0 && h_mm > 0) {
|
||||||
if (w_mm < h_mm) {
|
if (w_mm < h_mm) {
|
||||||
if (w_mm > (float)LOGO_SIZE_MAX_MM * 1.2f)
|
if (w_mm > logo_size_max * 1.2f)
|
||||||
logo_size_px = (float)LOGO_SIZE_MAX_MM *
|
logo_size_px = logo_size_max *
|
||||||
pixels_per_milli;
|
pixels_per_milli;
|
||||||
} else {
|
} else {
|
||||||
if (h_mm > (float)LOGO_SIZE_MAX_MM * 1.2f)
|
if (h_mm > logo_size_max * 1.2f)
|
||||||
logo_size_px = (float)LOGO_SIZE_MAX_MM *
|
logo_size_px = logo_size_max *
|
||||||
pixels_per_milli;
|
pixels_per_milli;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue