1
0
Fork 0
mirror of https://github.com/Horhik/dotfiles.git synced 2024-11-25 17:41:32 +00:00

configure dwm colors

This commit is contained in:
horhik 2020-10-08 01:30:23 +03:00
parent c585c140d7
commit 6c38cb9d80
10 changed files with 246 additions and 32 deletions

View file

@ -12,12 +12,22 @@ static const char col_gray1[] = "#282828";
static const char col_gray2[] = "#928374";
static const char col_gray3[] = "#d5c4a1";
static const char col_gray4[] = "#ebdbb2";
static const char col_cyan[] = "#d65d0e";
//static const char col_cyan[] = "#d79921";
static const char col_cyan[] = "#3c3836";
static const char col_norm[] = "#d65d0e";
static const char col_norm2[] = "#b16286";
static const char col_norm3[] = "#d79921";
static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
[SchemeNorm] = { col_norm, col_cyan, col_cyan},
[SchemeSel] = { col_gray4, col_norm2, col_norm3 },
[SchemeStatus] = { col_norm2, col_cyan, "#000000" }, // Statusbar right {text,background,not used but cannot be empty}
[SchemeTagsSel] = { col_gray1, col_norm3, "#000000" }, // Tagbar left selected {text,background,not used but cannot be empty}
[SchemeTagsNorm] = { col_norm2, col_cyan, "#000000" }, // Tagbar left unselected {text,background,not used but cannot be empty}
[SchemeInfoSel] = { col_gray4, col_cyan, "#000000" }, // infobar middle selected {text,background,not used but cannot be empty}
[SchemeInfoNorm] = { col_norm2, col_cyan, "#000000" }, // infobar middle unselected {text,background,not used but cannot be empty}
};
static const char *const autostart[] = {

View file

@ -13,6 +13,7 @@ static const char col_gray2[] = "#928374";
static const char col_gray3[] = "#d5c4a1";
static const char col_gray4[] = "#ebdbb2";
static const char col_cyan[] = "#d65d0e";
//static const char col_cyan[] = "#d79921";
static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
@ -20,27 +21,30 @@ static const char *colors[][3] = {
};
static const char *const autostart[] = {
"pulsemixer", "-k", NULL,
//"$HOME/.dwm/autostart.sh", NULL,
/*"pulsemixer", "-k", NULL,
"firefox", NULL,
"variety", NULL,
"redshift", NULL,
"picom", "--experimental-backends", "--detect-rounded-corners", NULL,
"setxkbmap","us,ru,fi",",winkeys","grp:alt_shift_toggle", NULL,
"xrandr", "--output", "HDMI1", "--above", "eDP1", NULL,
"$HOME/.local/scripts/status/launch", NULL,
"enact", "--pos", "top", NULL,
"pulseaudio","-k", NULL,
*/
NULL /* terminate */
};
/* tagging */
static const char *tags[] = { "", "", "", "", "", "", "", "", "" };
static const char *tags[] = { "", "", "", "", "", "", "", "", "" };
static const char *tagsalt[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
/* launcher commands (They must be NULL terminated) */
static const char* surf[] = { "surf", "duckduckgo.com", NULL };
static const char* spotify[] = { "spotify", "spotify", NULL };
static const Launcher launchers[] = {
/* command name to display */
{ surf, "surf" },
{ spotify, "" },
};
@ -49,11 +53,13 @@ static const Rule rules[] = {
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
*/
/* class instance title tags mask isfloating monitor scratch key */
/* class instance title tags mask isfloating monitor scratch key */
{ "Gimp", NULL, NULL, 0, 1, -1, 0 },
{ "firefox", NULL, NULL, 0 << 2, 0, -1, 0 },
{ "firefox", NULL, NULL, 1 << 1, 0, -1, 0 },
{ "spotify", NULL, NULL, 7 , 0, -1, 0 },
{ NULL, NULL, "scratchpad", 0, 1, -1, 's' },
{ NULL, NULL, "sp_volume", 0, 1, -1, 'v' },
{ NULL, NULL, "sp_volume", 0, 1, -1, 'v' },
{ NULL, NULL, "ScratchEmacs", 0, 1, -1, 'e' },
};
@ -85,8 +91,11 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, "-c", "-l", "20", NULL};
static const char *termcmd[] = { "alacritty", NULL };
static const char *flameshot[] = { "flameshot","gui", NULL };
/*First arg only serves to match against key in rules*/
static const char *scratchpadcmd[] = {"s", "alacritty", "-t", "scratchpad", NULL};
static const char *sp_emacs[] = {"e", "emacs", "-T", "ScratchEmacs", NULL};
static const char *sp_volume_control[] = {"v","alacritty", "-t", "sp_volume","-e", "pulsemixer", NULL};
@ -94,6 +103,7 @@ static Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ MODKEY|ShiftMask, XK_s, spawn, {.v = flameshot } },
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
@ -119,8 +129,10 @@ static Key keys[] = {
{ MODKEY, XK_equal, setgaps, {.i = +5 } },
{ MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
/*SCRATCHPADS*/
{ MODKEY, XK_u, togglescratch, {.v = scratchpadcmd } },
{ MODKEY, XK_u, togglescratch, {.v = scratchpadcmd } },
{ MODKEY|ShiftMask, XK_m, togglescratch, {.v = sp_volume_control } },
{ MODKEY, XK_e, togglescratch, {.v = sp_emacs } },
{ MODKEY, XK_n, togglealttag, {0} },
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)

View file

@ -12,12 +12,22 @@ static const char col_gray1[] = "#282828";
static const char col_gray2[] = "#928374";
static const char col_gray3[] = "#d5c4a1";
static const char col_gray4[] = "#ebdbb2";
static const char col_cyan[] = "#9e7117";
//static const char col_cyan[] = "#d79921";
static const char col_cyan[] = "#3c3836";
static const char col_norm[] = "#d65d0e";
static const char col_norm2[] = "#b16286";
static const char col_norm3[] = "#d79921";
static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
[SchemeNorm] = { col_norm, col_cyan, col_cyan},
[SchemeSel] = { col_gray4, col_norm2, col_norm3 },
[SchemeStatus] = { col_norm2, col_cyan, "#000000" }, // Statusbar right {text,background,not used but cannot be empty}
[SchemeTagsSel] = { col_gray1, col_norm3, "#000000" }, // Tagbar left selected {text,background,not used but cannot be empty}
[SchemeTagsNorm] = { col_norm2, col_cyan, "#000000" }, // Tagbar left unselected {text,background,not used but cannot be empty}
[SchemeInfoSel] = { col_gray4, col_cyan, "#000000" }, // infobar middle selected {text,background,not used but cannot be empty}
[SchemeInfoNorm] = { col_norm2, col_cyan, "#000000" }, // infobar middle unselected {text,background,not used but cannot be empty}
};
static const char *const autostart[] = {

Binary file not shown.

View file

@ -60,7 +60,7 @@
/* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
enum { SchemeNorm, SchemeSel }; /* color schemes */
enum { SchemeNorm, SchemeSel, SchemeStatus, SchemeTagsSel, SchemeTagsNorm, SchemeInfoSel, SchemeInfoNorm }; /* color schemes */
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
@ -772,7 +772,7 @@ drawbar(Monitor *m)
/* draw status first so it can be overdrawn by tags later */
if (m == selmon) { /* status is only drawn on selected monitor */
drw_setscheme(drw, scheme[SchemeNorm]);
drw_setscheme(drw, scheme[SchemeStatus]);
tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
}
@ -786,7 +786,7 @@ drawbar(Monitor *m)
for (i = 0; i < LENGTH(tags); i++) {
w = TEXTW(tags[i]);
wdelta = selmon->alttag ? abs(TEXTW(tags[i]) - TEXTW(tagsalt[i])) / 2 : 0;
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeTagsSel : SchemeTagsNorm]);
drw_text(drw, x, 0, w, bh, wdelta + lrpad / 2, (selmon->alttag ? tagsalt[i] : tags[i]), urg & 1 << i);
if (occ & 1 << i)
drw_rect(drw, x + boxs, boxs, boxw, boxw,
@ -811,12 +811,12 @@ drawbar(Monitor *m)
int mid = (m->ww - (int)TEXTW(m->sel->name)) / 2 - x;
/* make sure name will not overlap on tags even when it is very long */
mid = mid >= lrpad / 2 ? mid : lrpad / 2;
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
drw_setscheme(drw, scheme[m == selmon ? SchemeInfoSel : SchemeInfoNorm]);
drw_text(drw, x, 0, w, bh, mid, m->sel->name, 0);
if (m->sel->isfloating)
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
} else {
drw_setscheme(drw, scheme[SchemeNorm]);
drw_setscheme(drw, scheme[SchemeInfoNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1);
}
}

View file

@ -29,6 +29,7 @@
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <X11/cursorfont.h>
#include <X11/keysym.h>
@ -204,6 +205,7 @@ static void resizeclient(Client *c, int x, int y, int w, int h);
static void resizemouse(const Arg *arg);
static void restack(Monitor *m);
static void run(void);
static void runautostart(void);
static void scan(void);
static int sendevent(Client *c, Atom proto);
static void sendmon(Client *c, Monitor *m);
@ -251,7 +253,11 @@ static void zoom(const Arg *arg);
static void autostart_exec(void);
/* variables */
static const char autostartblocksh[] = "autostart_blocking.sh";
static const char autostartsh[] = "autostart.sh";
static const char broken[] = "broken";
static const char dwmdir[] = "dwm";
static const char localshare[] = ".local/share";
static char stext[256];
static int screen;
static int sw, sh; /* X display screen geometry width, height */
@ -1470,6 +1476,83 @@ run(void)
handler[ev.type](&ev); /* call handler */
}
void
runautostart(void)
{
char *pathpfx;
char *path;
char *xdgdatahome;
char *home;
struct stat sb;
if ((home = getenv("HOME")) == NULL)
/* this is almost impossible */
return;
/* if $XDG_DATA_HOME is set and not empty, use $XDG_DATA_HOME/dwm,
* otherwise use ~/.local/share/dwm as autostart script directory
*/
xdgdatahome = getenv("XDG_DATA_HOME");
if (xdgdatahome != NULL && *xdgdatahome != '\0') {
/* space for path segments, separators and nul */
pathpfx = ecalloc(1, strlen(xdgdatahome) + strlen(dwmdir) + 2);
if (sprintf(pathpfx, "%s/%s", xdgdatahome, dwmdir) <= 0) {
free(pathpfx);
return;
}
} else {
/* space for path segments, separators and nul */
pathpfx = ecalloc(1, strlen(home) + strlen(localshare)
+ strlen(dwmdir) + 3);
if (sprintf(pathpfx, "%s/%s/%s", home, localshare, dwmdir) < 0) {
free(pathpfx);
return;
}
}
/* check if the autostart script directory exists */
if (! (stat(pathpfx, &sb) == 0 && S_ISDIR(sb.st_mode))) {
/* the XDG conformant path does not exist or is no directory
* so we try ~/.dwm instead
*/
char *pathpfx_new = realloc(pathpfx, strlen(home) + strlen(dwmdir) + 3);
if(pathpfx_new == NULL) {
free(pathpfx);
return;
}
pathpfx = pathpfx_new;
if (sprintf(pathpfx, "%s/.%s", home, dwmdir) <= 0) {
free(pathpfx);
return;
}
}
/* try the blocking script first */
path = ecalloc(1, strlen(pathpfx) + strlen(autostartblocksh) + 2);
if (sprintf(path, "%s/%s", pathpfx, autostartblocksh) <= 0) {
free(path);
free(pathpfx);
}
if (access(path, X_OK) == 0)
system(path);
/* now the non-blocking script */
if (sprintf(path, "%s/%s", pathpfx, autostartsh) <= 0) {
free(path);
free(pathpfx);
}
if (access(path, X_OK) == 0)
system(strcat(path, " &"));
free(pathpfx);
free(path);
}
void
scan(void)
{
@ -2298,6 +2381,7 @@ main(int argc, char *argv[])
die("pledge");
#endif /* __OpenBSD__ */
scan();
runautostart();
run();
cleanup();
XCloseDisplay(dpy);

View file

@ -1,11 +1,41 @@
--- dwm.c
+++ dwm.c
@@ -697,7 +699,7 @@ dirtomon(int dir)
void
drawbar(Monitor *m)
{
- int x, w, sw = 0;
+ int x, w, wdelta, sw = 0;
int boxs = drw->fonts->h / 9;
int boxw = drw->fonts->h / 6 + 2;
unsigned int i, occ = 0, urg = 0;
@@ -703,7 +703,7 @@ drawbar(Monitor *m)
/* draw status first so it can be overdrawn by tags later */
if (m == selmon) { /* status is only drawn on selected monitor */
- drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_setscheme(drw, scheme[SchemeStatus]);
sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0);
}
@@ -716,7 +716,7 @@ drawbar(Monitor *m)
x = 0;
for (i = 0; i < LENGTH(tags); i++) {
w = TEXTW(tags[i]);
- drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
+ drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeTagsSel : SchemeTagsNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
if (occ & 1 << i)
drw_rect(drw, x + boxs, boxs, boxw, boxw,
@@ -725,17 +725,17 @@ drawbar(Monitor *m)
x += w;
}
w = blw = TEXTW(m->ltsymbol);
- drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_setscheme(drw, scheme[SchemeTagsNorm]);
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
if ((w = m->ww - sw - x) > bh) {
if (m->sel) {
- drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
+ drw_setscheme(drw, scheme[m == selmon ? SchemeInfoSel : SchemeInfoNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
if (m->sel->isfloating)
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
} else {
- drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_setscheme(drw, scheme[SchemeInfoNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1);
}
}

Binary file not shown.

View file

@ -0,0 +1,68 @@
diff --git a/config.def.h b/config.def.h
index 1c0b587..a516645 100644
--- a/config.def.h
+++ b/config.def.h
@@ -16,6 +16,11 @@ static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
+ [SchemeStatus] = { col_gray3, col_gray1, "#000000" }, // Statusbar right {text,background,not used but cannot be empty}
+ [SchemeTagsSel] = { col_gray4, col_cyan, "#000000" }, // Tagbar left selected {text,background,not used but cannot be empty}
+ [SchemeTagsNorm] = { col_gray3, col_gray1, "#000000" }, // Tagbar left unselected {text,background,not used but cannot be empty}
+ [SchemeInfoSel] = { col_gray4, col_cyan, "#000000" }, // infobar middle selected {text,background,not used but cannot be empty}
+ [SchemeInfoNorm] = { col_gray3, col_gray1, "#000000" }, // infobar middle unselected {text,background,not used but cannot be empty}
};
/* tagging */
diff --git a/dwm.c b/dwm.c
index 4465af1..0d1d2f7 100644
--- a/dwm.c
+++ b/dwm.c
@@ -59,7 +59,7 @@
/* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
-enum { SchemeNorm, SchemeSel }; /* color schemes */
+enum { SchemeNorm, SchemeSel, SchemeStatus, SchemeTagsSel, SchemeTagsNorm, SchemeInfoSel, SchemeInfoNorm }; /* color schemes */
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
@@ -703,7 +703,7 @@ drawbar(Monitor *m)
/* draw status first so it can be overdrawn by tags later */
if (m == selmon) { /* status is only drawn on selected monitor */
- drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_setscheme(drw, scheme[SchemeStatus]);
sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0);
}
@@ -716,7 +716,7 @@ drawbar(Monitor *m)
x = 0;
for (i = 0; i < LENGTH(tags); i++) {
w = TEXTW(tags[i]);
- drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
+ drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeTagsSel : SchemeTagsNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
if (occ & 1 << i)
drw_rect(drw, x + boxs, boxs, boxw, boxw,
@@ -725,17 +725,17 @@ drawbar(Monitor *m)
x += w;
}
w = blw = TEXTW(m->ltsymbol);
- drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_setscheme(drw, scheme[SchemeTagsNorm]);
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
if ((w = m->ww - sw - x) > bh) {
if (m->sel) {
- drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
+ drw_setscheme(drw, scheme[m == selmon ? SchemeInfoSel : SchemeInfoNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
if (m->sel->isfloating)
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
} else {
- drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_setscheme(drw, scheme[SchemeInfoNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1);
}
}

View file

@ -68,5 +68,5 @@ layout ()
echo  $(xkblayout-state print %s)
}
echo "---------{$(wifi)}--{$(battery)}--{$(volume)}--{$(layout)}--{$(diskspace)}---------"
echo " [$(wifi)] [$(battery)] [$(volume)] [$(layout)] [$(diskspace)] "