i3help
i3help copied to clipboard
Nixos compilation fix and Dark mode :)
Hey!! So, I had a few spare moments on my hands.. I grabbed your i3help and tried to compile it under Nixos. There has been a recent gcc change that causes this error when compiling (at least under nix-shell -p autoreconfHook gtk3 pkgconfig)
main.c: In function ‘print2’:
main.c:68:3: error: format not a string literal and no format arguments [-Werror=format-security]
68 | g_print(b);
| ^~~~~~~
Since it's not needed, I jst remarked the print2 out. I also made sure that it was 'dark mode' friendly, rather than jarring white (plus I am white/yellow colourblind anyway so, double oopsie for me :) with the attached patch below.
(ins)[nix-shell:~/i3/i3help]$ git diff
diff --git a/main.c b/main.c
index 68cafe8..2b9e185 100644
--- a/main.c
+++ b/main.c
@@ -64,9 +64,9 @@ void strip_extra_spaces(gchar *str) {
str[x] = '\0';
}
-void print2(gchar *b) {
- g_print(b);
-}
+// void print2(gchar *b) {
+// g_print(b);
+// }
void print_binding(struct binding *b) {
g_print("%s - %s\n", b->keys, b->cmd);
@@ -149,7 +149,7 @@ void addPageLabel(GtkWidget *grid, int cols){
gtk_widget_set_hexpand (label, TRUE);
gtk_widget_set_valign (label, GTK_ALIGN_END);
gtk_widget_set_halign (label, GTK_ALIGN_END);
- gtk_label_set_markup(GTK_LABEL(label), "<span foreground='#808080'><space> : next page</span>");
+ gtk_label_set_markup(GTK_LABEL(label), "<span foreground='#000000'><space> : next page</span>");
gtk_grid_attach (GTK_GRID (grid), label, 0, 1, cols, 1);
@@ -189,10 +189,16 @@ static void activate (GtkApplication* app, gpointer user_data)
{
GtkWidget *window;
GtkWidget *grid;
+ GdkColor bgcolor;
+ GdkColor fgcolor;
+ gdk_color_parse("#333333", &bgcolor);
+ gdk_color_parse("#aaaaaa", &fgcolor);
GSList *text = (GSList *) user_data;
window = gtk_application_window_new (app);
+ gtk_widget_modify_bg(window, GTK_STATE_NORMAL, &bgcolor);
+ gtk_widget_modify_fg(window, GTK_STATE_NORMAL, &fgcolor);
gtk_window_set_title (GTK_WINDOW (window), "i3-help");
gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG);
gtk_window_set_keep_above(GTK_WINDOW(window), TRUE);
@@ -241,8 +247,8 @@ gchar* clean(gchar *text){
gchar *formatKeys(gchar *text){
if(text == NULL) return "";
- return g_strdup_printf("<span foreground='#dd0'>%s</span>",
- g_strjoinv("</span> + <span foreground='#dd0'>", g_strsplit(text, "+", -1)));
+ return g_strdup_printf("<span foreground='#aa0'>%s</span>",
+ g_strjoinv("</span> + <span foreground='#aa0'>", g_strsplit(text, "+", -1)));
}