Hello
I've been playing around with hastinbe's command-line options patch
And I've come down to this version to compile herbe with a set of colorschemes,
and an option to chose from them at runtime.
In the example config.def, there's a blue-ish default color, a gray-ish "low" mode and a red-ish "high" mode.
I can enjoy playing around with C, but I'm sorry, I still will not learn git while the manpages are such a mess.
I've already spent more than an hour today trying to submit a pull request with my patch, and I give up :
Below is the content of the patch, feel free to put it somewhere it belongs, I don't even ask that you mention me as author.
commit 0de261c94a8dc209e4c20194151ba75b6647f0bd
Author: Arsaell
Date: Tue Apr 18 17:50:41 2023 +0200
[Arsaell] Creation of patch: multiple_color_schemes.diff
Depends on diff "Add minimalistic command-line options" #18
which should be applied prior.
Default option is `herbe -c [0-n] BODY` to switch between
pre-defined color schemes
diff --git a/config.def.h b/config.def.h
index 86b7e76..4056484 100644
--- a/config.def.h
+++ b/config.def.h
@@ -1,6 +1,16 @@
-static const char *background_color = "#3e3e3e";
-static const char *border_color = "#ececec";
-static const char *font_color = "#ececec";
+#define COLOR_SCHEMES_COUNT 3
+
+//Color schemes
+enum {SchemeNorm, SchemeHigh, SchemeLow};
+
+static char *colors[COLOR_SCHEMES_COUNT][3] = {
+/* Name background border font */
+ [SchemeNorm] = { "#152544", "#005577", "#00bbdd" },
+ [SchemeHigh] = { "#442222", "#cc0000", "#ccbbbb" },
+ [SchemeLow] = { "#222222", "#444444", "#bbbbbb" }
+};
+static unsigned int default_color_scheme=SchemeNorm;
+
static const char *font_pattern = "monospace:size=10";
static const unsigned line_spacing = 5;
static const unsigned int padding = 15;
@@ -15,5 +25,13 @@ enum corners corner = TOP_RIGHT;
static const unsigned int duration = 5; /* in seconds */
+
+
#define DISMISS_BUTTON Button1
#define ACTION_BUTTON Button3
+
+#define VERSION_STRING "1.0.0"
+
+#define EXIT_ACTION 0
+#define EXIT_FAIL 1
+#define EXIT_DISMISS 2
diff --git a/herbe.c b/herbe.c
index 389a2df..cf1b0df 100644
--- a/herbe.c
+++ b/herbe.c
@@ -68,8 +68,8 @@ static void die(const char *format, ...)
static int handle_options(const char ***argv, int *argc)
{
- const char **orig_argv = *argv;
+ const int orig_argc = *argc;
while (*argc > 0) {
const char *cmd = (*argv)[0];
if (cmd[0] != '-')
@@ -82,6 +82,13 @@ static int handle_options(const char ***argv, int *argc)
print_version();
exit(0);
}
+
+ else if (!strcmp(cmd, "-c")) {
+ default_color_scheme=atoi((*argv)[1]);
+ (*argv)++;
+ (*argc)--;
+ }
+
else {
fprintf(stderr, "Unknown option: %s\n", cmd);
usage(herbe_usage_string);
@@ -90,7 +97,8 @@ static int handle_options(const char ***argv, int *argc)
(*argv)++;
(*argc)--;
}
- return (*argv) - orig_argv;
+
+ return orig_argc - *argc;
}
int get_max_len(char *string, XftFont *font, int max_text_width)
@@ -246,7 +254,13 @@ int main(int argc, char *argv[])
/* Look for flags.. */
av++;
- handle_options(&av, &argc);
+
+ int options_count=handle_options(&av, &argc);
+
+ char *background_color=colors[default_color_scheme][0];
+ char *border_color=colors[default_color_scheme][1];
+ char *font_color=colors[default_color_scheme][2];
+
const char* id =getenv("HERBE_ID");
mqd_t mqd=-1;
@@ -322,7 +336,7 @@ int main(int argc, char *argv[])
attributes.border_pixel = color.pixel;
font = XftFontOpenName(display, screen, font_pattern);
- constructLines(argv+1, argc-1);
+ constructLines(argv+1+options_count, argc-1);
int y_offset_id;
unsigned int *y_offset;
Hello
I've been playing around with hastinbe's command-line options patch
And I've come down to this version to compile herbe with a set of colorschemes,
and an option to chose from them at runtime.
In the example config.def, there's a blue-ish default color, a gray-ish "low" mode and a red-ish "high" mode.
I can enjoy playing around with C, but I'm sorry, I still will not learn git while the manpages are such a mess.
I've already spent more than an hour today trying to submit a pull request with my patch, and I give up :
Below is the content of the patch, feel free to put it somewhere it belongs, I don't even ask that you mention me as author.
commit 0de261c94a8dc209e4c20194151ba75b6647f0bd
Author: Arsaell
Date: Tue Apr 18 17:50:41 2023 +0200