Skip to content

Instantly share code, notes, and snippets.

@skeleten
Created June 19, 2018 20:51
Show Gist options
  • Save skeleten/2cf6176b3c4ff834f9c82bb001d02632 to your computer and use it in GitHub Desktop.
Save skeleten/2cf6176b3c4ff834f9c82bb001d02632 to your computer and use it in GitHub Desktop.
diff --git a/dwm/config.h b/dwm/config.h
index c9db82f..7887a47 100644
--- a/dwm/config.h
+++ b/dwm/config.h
@@ -118,8 +118,8 @@ static const char *scrot[] = { "nougat", "-f", NULL };
static Key keys[] = {
/* modifier key function argument */
-
- { Super, 27, /* r */ spawn, {.v = ranger } },
+ { Alt, 27, /* r */ setup_theme_arg, {.i = THEME_ARIZONA_ID } },
+ { Alt, 40, /* d */ setup_theme_arg, {.i = THEME_MINT_ID } },
{ Super, 40, /* d */ spawn, {.v = dmenucmd } },
{ Alt, 36, /* Return */ spawn, {.v = terminal } },
{ Alt, 56, /* b */ togglebar, {0} },
diff --git a/dwm/drw.o b/dwm/drw.o
index 2c60e48..d3fc350 100644
Binary files a/dwm/drw.o and b/dwm/drw.o differ
diff --git a/dwm/dwm b/dwm/dwm
index eb04e7b..76bd82e 100755
Binary files a/dwm/dwm and b/dwm/dwm differ
diff --git a/dwm/dwm.c b/dwm/dwm.c
index ef12e7f..28984ea 100644
--- a/dwm/dwm.c
+++ b/dwm/dwm.c
@@ -204,6 +204,8 @@ static void setfullscreen(Client *c, int fullscreen);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setup(void);
+static void setup_theme(const Theme* theme);
+static void setup_theme_arg(const Arg *arg);
static void showhide(Client *c);
static void sigchld(int unused);
static void spawn(const Arg *arg);
@@ -1574,12 +1576,13 @@ setup(void)
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
/* init appearance */
- scheme[SchemeNorm].border = drw_clr_create(drw, normbordercolor);
- scheme[SchemeNorm].bg = drw_clr_create(drw, normbgcolor);
- scheme[SchemeNorm].fg = drw_clr_create(drw, normfgcolor);
- scheme[SchemeSel].border = drw_clr_create(drw, selbordercolor);
- scheme[SchemeSel].bg = drw_clr_create(drw, selbgcolor);
- scheme[SchemeSel].fg = drw_clr_create(drw, selfgcolor);
+ setup_theme(&Mint);
+ // scheme[SchemeNorm].border = drw_clr_create(drw, normbordercolor);
+ // scheme[SchemeNorm].bg = drw_clr_create(drw, normbgcolor);
+ // scheme[SchemeNorm].fg = drw_clr_create(drw, normfgcolor);
+ // scheme[SchemeSel].border = drw_clr_create(drw, selbordercolor);
+ // scheme[SchemeSel].bg = drw_clr_create(drw, selbgcolor);
+ // scheme[SchemeSel].fg = drw_clr_create(drw, selfgcolor);
/* init bars */
updatebars();
updatestatus();
@@ -1597,6 +1600,33 @@ setup(void)
focus(NULL);
}
+void
+setup_theme(const Theme* theme)
+{
+ printf("Setting up a theme\n");
+ scheme[SchemeNorm].border = drw_clr_create(drw, theme->normbordercolor);
+ scheme[SchemeNorm].bg = drw_clr_create(drw, theme->normbgcolor);
+ scheme[SchemeNorm].fg = drw_clr_create(drw, theme->normfgcolor);
+ scheme[SchemeSel].border = drw_clr_create(drw, theme->selbordercolor);
+ scheme[SchemeSel].bg = drw_clr_create(drw, theme->selbgcolor);
+ scheme[SchemeSel].fg = drw_clr_create(drw, theme->selfgcolor);
+}
+
+void
+setup_theme_arg(const Arg* arg)
+{
+ switch (arg->i) {
+ case THEME_MINT_ID:
+ setup_theme(THEME_MINT_PTR);
+ break;
+ case THEME_ARIZONA_ID:
+ setup_theme(THEME_ARIZONA_PTR);
+ break;
+ default:
+ printf("Unknown theme id %d!\n", arg->i);
+ }
+}
+
void
showhide(Client *c)
{
diff --git a/dwm/dwm.o b/dwm/dwm.o
index 8862bcb..23db1d8 100644
Binary files a/dwm/dwm.o and b/dwm/dwm.o differ
diff --git a/dwm/themes.h b/dwm/themes.h
index c46f3e5..baf5108 100644
--- a/dwm/themes.h
+++ b/dwm/themes.h
@@ -3,25 +3,42 @@
// themes.h
+#ifndef __THEMES_H
+#define __THEMES_H __THEMES_H
-#define Mint
+typedef struct s_Theme {
+ char* normbordercolor;
+ char* normbgcolor;
+ char* normfgcolor;
+ char* selbordercolor;
+ char* selbgcolor;
+ char* selfgcolor;
+} Theme;
-#ifdef Mint
-static const char normbordercolor[] = "#949093";
-static const char normbgcolor[] = "#151b1e";
-static const char normfgcolor[] = "#d4ced2";
-static const char selbordercolor[] = "#d4ced2";
-static const char selbgcolor[] = "#619668";
-static const char selfgcolor[] = "#d4ced2";
-#endif
+#define THEME_MINT_ID (0)
+#define THEME_MINT_PTR (&Mint)
+
+static const Theme Mint =
+ {
+ .normbordercolor = "#949093",
+ .normbgcolor = "#151b1e",
+ .normfgcolor = "#d4ced2",
+ .selbordercolor = "#d4ced2",
+ .selbgcolor = "#619668",
+ .selfgcolor = "#d4ced2",
+ };
+#define THEME_ARIZONA_ID (1)
+#define THEME_ARIZONA_PTR (&Arizona)
+static const Theme Arizona =
+ {
+ .normbordercolor = "#949093",
+ .normbgcolor = "#151b1e",
+ .normfgcolor = "#d4ced2",
+ .selbordercolor = "#d4ced2",
+ .selbgcolor = "#689990",
+ .selfgcolor = "#d4ced2",
+ };
-#ifdef Arizona
-static const char normbordercolor[] = "#949093";
-static const char normbgcolor[] = "#151b1e";
-static const char normfgcolor[] = "#d4ced2";
-static const char selbordercolor[] = "#d4ced2";
-static const char selbgcolor[] = "#689990";
-static const char selfgcolor[] = "#d4ced2";
#endif
diff --git a/dwm/util.o b/dwm/util.o
index 6082083..07922eb 100644
Binary files a/dwm/util.o and b/dwm/util.o differ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment