main: add --background command line argument
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Daniel Eklöf · committed by Daniel Eklöf · parent 32cfbdd · Browse files · 1 file·+23 added−9 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+23 added−9 removed
- other:+23 added−9 removed
Provenance
- Commit
2e652d8- Tree
c1d47eb- Author
Daniel Eklöf <daniel@ekloef.se>- Committer
Daniel Eklöf <daniel@ekloef.se>- Parent
32cfbdd
1 file changed+23 added−9 removed
modified:main.c+23 added-9 removed
1027 unmodified lines1028 int1029 main(int argc, char *const *argv)1030 {1031 static const struct option longopts[] = {1032- {"output" , required_argument, 0, 'o'},1033- {"font", required_argument, 0, 'f'},1034- {"geometry", required_argument, 0, 'g'},1035- {"text-color", required_argument, 0, 't'},1036- {"match-color", required_argument, 0, 'm'},1037- {NULL, no_argument, 0, 0},1032+ {"output" , required_argument, 0, 'o'},1033+ {"font", required_argument, 0, 'f'},1034+ {"geometry", required_argument, 0, 'g'},1035+ {"background-color", required_argument, 0, 'b'},1036+ {"text-color", required_argument, 0, 't'},1037+ {"match-color", required_argument, 0, 'm'},1038+ {NULL, no_argument, 0, 0},1039 };1040 1041 const char *output_name = NULL;1042 const char *font_name = "monospace";1 unmodified line1044 int width = 500;1045 int height = 300;1046 uint32_t text_color = 0xffffffff;1047 uint32_t match_color = 0xcc9393ff;1048+ uint32_t background = 0x000000ff;1049 1050 while (true) {1049- int c = getopt_long(argc, argv, ":o:f:g:t:m:", longopts, NULL);1051+ int c = getopt_long(argc, argv, ":o:f:g:b:t:m:", longopts, NULL);1052 if (c == -1)1053 break;1054 1055 switch (c) {11 unmodified lines1067 return EXIT_FAILURE;1068 }1069 break;1070 1071+ case 'b':1072+ if (sscanf(optarg, "%08x", &background) != 1) {1073+ LOG_ERR("%s: invalid color", optarg);1074+ return EXIT_FAILURE;1075+ }1076+ break;1077+1078 case 't':1070- if (sscanf(optarg, "%x", &text_color) != 1) {1079+ if (sscanf(optarg, "%08x", &text_color) != 1) {1080 LOG_ERR("%s: invalid color", optarg);1081 return EXIT_FAILURE;1082 }1083 break;41 unmodified lines1125 .height = height,1126 .x_margin = 20,1127 .y_margin = 4,1128 .border_size = 1,1120- .background = {0.247, 0.247, 0.247, 0.9},1129+ .background = {1130+ (double)((background >> 24) & 0xff) / 255.0,1131+ (double)((background >> 16) & 0xff) / 255.0,1132+ (double)((background >> 8) & 0xff) / 255.0,1133+ (double)((background >> 0) & 0xff) / 255.0,1134+ },1135 };1136 1137 mtx_init(&c.repeat.mutex, mtx_plain);1138 cnd_init(&c.repeat.cond);234 unmodified lines