dwm-scheme_switch-20170804-ceac8c9.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dwm-scheme_switch-20170804-ceac8c9.diff (3618B)
---
1 diff --git a/config.def.h b/config.def.h
2 index a9ac303..b047735 100644
3 --- a/config.def.h
4 +++ b/config.def.h
5 @@ -12,10 +12,26 @@ static const char col_gray2[] = "#444444";
6 static const char col_gray3[] = "#bbbbbb";
7 static const char col_gray4[] = "#eeeeee";
8 static const char col_cyan[] = "#005577";
9 +
10 +/* solarized colors http://ethanschoonover.com/solarized */
11 +static const char s_base03[] = "#002b36";
12 +static const char s_base02[] = "#073642";
13 +static const char s_base01[] = "#586e75";
14 +static const char s_base00[] = "#657b83";
15 +static const char s_base0[] = "#839496";
16 +static const char s_base1[] = "#93a1a1";
17 +static const char s_base2[] = "#eee8d5";
18 +static const char s_base3[] = "#fdf6e3";
19 +
20 +
21 static const char *colors[][3] = {
22 /* fg bg border */
23 - [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
24 - [SchemeSel] = { col_gray4, col_cyan, col_cyan },
25 + { s_base0, s_base03, s_base2 }, /* SchemeNorm dark */
26 + { s_base0, s_base02, s_base2 }, /* SchemeSel dark */
27 + { s_base00, s_base3, s_base02 }, /* SchemeNorm light */
28 + { s_base00, s_base2, s_base02}, /* SchemeSel light */
29 + { col_gray3, col_gray1, col_gray2 }, /* SchemeNorm orig */
30 + { col_gray4, col_cyan, col_cyan }, /* SchemeSel orig */
31 };
32
33 /* tagging */
34 @@ -84,6 +100,8 @@ static Key keys[] = {
35 { MODKEY, XK_period, focusmon, {.i = +1 } },
36 { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
37 { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
38 + { MODKEY|ShiftMask, XK_t, schemeToggle, {0} },
39 + { MODKEY|ShiftMask, XK_z, schemeCycle, {0} },
40 TAGKEYS( XK_1, 0)
41 TAGKEYS( XK_2, 1)
42 TAGKEYS( XK_3, 2)
43 diff --git a/dwm.c b/dwm.c
44 index a5ce993..3935efc 100644
45 --- a/dwm.c
46 +++ b/dwm.c
47 @@ -60,7 +60,6 @@
48
49 /* enums */
50 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
51 -enum { SchemeNorm, SchemeSel }; /* color schemes */
52 enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
53 NetWMFullscreen, NetActiveWindow, NetWMWindowType,
54 NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
55 @@ -195,6 +194,8 @@ static void resizemouse(const Arg *arg);
56 static void restack(Monitor *m);
57 static void run(void);
58 static void scan(void);
59 +static void schemeCycle(const Arg*);
60 +static void schemeToggle(const Arg*);
61 static int sendevent(Client *c, Atom proto);
62 static void sendmon(Client *c, Monitor *m);
63 static void setclientstate(Client *c, long state);
64 @@ -264,6 +265,7 @@ static Atom wmatom[WMLast], netatom[NetLast];
65 static int running = 1;
66 static Cur *cursor[CurLast];
67 static Scm *scheme;
68 +static int SchemeNorm = 0, SchemeSel = 1;
69 static Display *dpy;
70 static Drw *drw;
71 static Monitor *mons, *selmon;
72 @@ -1410,6 +1412,42 @@ scan(void)
73 }
74
75 void
76 +schemeCycle(const Arg *arg) {
77 +
78 + if ((SchemeSel + 2) < LENGTH(colors))
79 + {
80 + SchemeNorm += 2;
81 + SchemeSel += 2;
82 + } else {
83 + SchemeNorm = 0;
84 + SchemeSel = 1;
85 + }
86 +
87 + drawbars();
88 +}
89 +
90 +void
91 +schemeToggle(const Arg *arg) {
92 +
93 + int numThemePairs = LENGTH(colors) / 4;
94 + int sheme = SchemeNorm / 2;
95 +
96 + if (sheme / 2 > numThemePairs-1) {
97 + return;
98 + }
99 +
100 + if (sheme % 2 == 0) {
101 + SchemeNorm += 2;
102 + SchemeSel += 2;
103 + } else {
104 + SchemeNorm -= 2;
105 + SchemeSel -= 2;
106 + }
107 +
108 + drawbars();
109 +}
110 +
111 +void
112 sendmon(Client *c, Monitor *m)
113 {
114 if (c->mon == m)