From 8c65a77150db1013d5be1eff3711461de21e0da0 Mon Sep 17 00:00:00 2001 From: Shubham Saini Date: Mon, 18 May 2020 20:25:32 +0530 Subject: finally done --- dwm/config.h | 47 ++---- dwm/dwmbar | 8 +- dwm/patches/dwm-status2d-20200508-60bb3df.diff | 180 +++++++++++++++++++++ dwm/patches/dwm-statuscolors-20181008-b69c870.diff | 94 ----------- 4 files changed, 200 insertions(+), 129 deletions(-) create mode 100644 dwm/patches/dwm-status2d-20200508-60bb3df.diff delete mode 100644 dwm/patches/dwm-statuscolors-20181008-b69c870.diff (limited to 'dwm') diff --git a/dwm/config.h b/dwm/config.h index 0674870..11f6c81 100644 --- a/dwm/config.h +++ b/dwm/config.h @@ -3,30 +3,23 @@ /* appearance */ static const unsigned int borderpx = 0; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ -static const unsigned int gappih = 8; /* horiz inner gap between windows */ -static const unsigned int gappiv = 8; /* vert inner gap between windows */ -static const unsigned int gappoh = 8; /* horiz outer gap between windows and screen edge */ -static const unsigned int gappov = 8; /* vert outer gap between windows and screen edge */ +static const unsigned int gappih = 10; /* horiz inner gap between windows */ +static const unsigned int gappiv = 10; /* vert inner gap between windows */ +static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */ +static const unsigned int gappov = 10; /* vert outer gap between windows and screen edge */ static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ -static const char *fonts[] = { "Hermit:pixelsize=11:antialias=true:autohint=true" }; +static const char *fonts[] = { "Hermit:pixelsize=12.5:antialias=true:autohint=true" }; static const char col_gray1[] = "#696969"; static const char col_gray2[] = "#000000"; static const char col_gray3[] = "#c6c8d1"; static const char col_gray4[] = "#696969"; static const char col_cyan[] = "#e0e0e0"; -static const char col_black[] = "#000000"; -static const char col_red[] = "#ff0000"; -static const char col_yellow[] = "#ffff00"; -static const char col_white[] = "#ffffff"; -#define NUMCOLORS 4 static const char *colors[][3] = { /* fg bg border */ [SchemeNorm] = { col_gray4, col_gray2, col_gray2 }, - [SchemeSel] = { col_gray3, col_gray2, col_gray2 }, - [SchemeWarn] = { col_black, col_yellow, col_red }, - [SchemeUrgent]= { col_white, col_red, col_red }, + [SchemeSel] = { col_gray3, col_gray2, col_gray2}, }; /* tagging */ @@ -45,7 +38,7 @@ static const Rule rules[] = { /* layout(s) */ static const float mfact = 0.50; /* factor of master area size [0.05..0.95] */ static const int nmaster = 1; /* number of clients in master area */ -static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */ +static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ static const Layout layouts[] = { /* symbol arrange function */ @@ -70,7 +63,7 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() static const char *dmenucmd[] = { "menu", NULL }; static const char *termcmd[] = { "st", NULL }; static const char scratchpadname[] = "scratchpad"; -static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "80x24", NULL }; +static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL }; /* volume */ static const char *upvol[] = { "pulsemixer", "--change-volume", "+5", NULL }; @@ -82,11 +75,6 @@ static const char *shut[] = { "shut", NULL }; static const char *brightup[] = { "doas", "bup", NULL }; static const char *brightdown[] = { "doas", "bdown", NULL }; -/* cmus */ -static const char *plyrnext[] = { "cmus-remote", "-n", NULL }; -static const char *plyrprev[] = { "cmus-remote", "-r", NULL }; -static const char *plyrplay[] = { "cmus-remote", "-u", NULL }; - /* lock */ static const char *lock[] = { "xset", "s", "activate", NULL }; @@ -101,9 +89,6 @@ static Key keys[] = { { 0, XF86XK_AudioRaiseVolume, spawn, {.v = upvol } }, { 0, XF86XK_MonBrightnessUp, spawn, {.v = brightup } }, { 0, XF86XK_MonBrightnessDown, spawn, {.v = brightdown } }, - { 0, XF86XK_AudioNext, spawn, {.v = plyrnext } }, - { 0, XF86XK_AudioPrev, spawn, {.v = plyrprev } }, - { 0, XF86XK_AudioPlay, spawn, {.v = plyrplay } }, { MODKEY|ShiftMask, XK_Delete, spawn, {.v = lock } }, { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, @@ -112,14 +97,14 @@ static Key keys[] = { { MODKEY, XK_d, incnmaster, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, - { MODKEY|Mod1Mask, XK_h, incrgaps, {.i = +1 } }, - { MODKEY|Mod1Mask, XK_l, incrgaps, {.i = -1 } }, - { MODKEY|Mod1Mask|ShiftMask, XK_h, incrogaps, {.i = +1 } }, - { MODKEY|Mod1Mask|ShiftMask, XK_l, incrogaps, {.i = -1 } }, - { MODKEY|Mod1Mask|ControlMask, XK_h, incrigaps, {.i = +1 } }, - { MODKEY|Mod1Mask|ControlMask, XK_l, incrigaps, {.i = -1 } }, - { MODKEY|Mod1Mask, XK_0, togglegaps, {0} }, - { MODKEY|Mod1Mask|ShiftMask, XK_0, defaultgaps, {0} }, + { MODKEY|Mod4Mask, XK_h, incrgaps, {.i = +1 } }, + { MODKEY|Mod4Mask, XK_l, incrgaps, {.i = -1 } }, + { MODKEY|Mod4Mask|ShiftMask, XK_h, incrogaps, {.i = +1 } }, + { MODKEY|Mod4Mask|ShiftMask, XK_l, incrogaps, {.i = -1 } }, + { MODKEY|Mod4Mask|ControlMask, XK_h, incrigaps, {.i = +1 } }, + { MODKEY|Mod4Mask|ControlMask, XK_l, incrigaps, {.i = -1 } }, + { MODKEY|Mod4Mask, XK_0, togglegaps, {0} }, + { MODKEY|Mod4Mask|ShiftMask, XK_0, defaultgaps, {0} }, { MODKEY, XK_y, incrihgaps, {.i = +1 } }, { MODKEY, XK_o, incrihgaps, {.i = -1 } }, { MODKEY|ControlMask, XK_y, incrivgaps, {.i = +1 } }, diff --git a/dwm/dwmbar b/dwm/dwmbar index d9e92ca..0960930 100755 --- a/dwm/dwmbar +++ b/dwm/dwmbar @@ -1,22 +1,22 @@ #!/bin/bash vol(){ vol=$(pulsemixer --get-volume | awk '{print $1}') - echo -e "\x01vol \x02$vol%" + printf "%s" "vol ^c#c6c8d1^$vol%^d^" } bat() { power=$(cat /sys/class/power_supply/BAT0/capacity) - echo -e "\x01bat \x02$power%" + printf "%s" "bat ^c#c6c8d1^$power%^d^" } dte() { dte=$(date +"%A, %B %d") - echo -e "\x01date \x02$dte" + printf "%s" "date ^c#c6c8d1^$dte^d^" } tie() { tme=$(date +"%I:%M %p") - echo -e "\x01time \x02$tme" + printf "%s" "time ^c#c6c8d1^$tme^d^" } while true; do xsetroot -name "$(vol) $(bat) $(tie) $(dte)" diff --git a/dwm/patches/dwm-status2d-20200508-60bb3df.diff b/dwm/patches/dwm-status2d-20200508-60bb3df.diff new file mode 100644 index 0000000..6f353fd --- /dev/null +++ b/dwm/patches/dwm-status2d-20200508-60bb3df.diff @@ -0,0 +1,180 @@ +From 60bb3dfaf91227eb02e828d74e6f4758b2c56542 Mon Sep 17 00:00:00 2001 +From: cultab +Date: Fri, 8 May 2020 13:56:08 +0300 +Subject: [PATCH] fix status2d to work after ed3ab6 + +ed3ab6 changed the name of the variable sw to tw, now the patch won't apply nor work. +This patch updates the variable name to the new one. +--- + dwm.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- + 1 file changed, 114 insertions(+), 6 deletions(-) + +diff --git a/dwm.c b/dwm.c +index 9fd0286..71e18be 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -163,6 +163,7 @@ static void detachstack(Client *c); + static Monitor *dirtomon(int dir); + static void drawbar(Monitor *m); + static void drawbars(void); ++static int drawstatusbar(Monitor *m, int bh, char* text); + static void enternotify(XEvent *e); + static void expose(XEvent *e); + static void focus(Client *c); +@@ -237,7 +238,7 @@ static void zoom(const Arg *arg); + + /* variables */ + static const char broken[] = "broken"; +-static char stext[256]; ++static char stext[1024]; + static int screen; + static int sw, sh; /* X display screen geometry width, height */ + static int bh, blw = 0; /* bar geometry */ +@@ -485,7 +486,7 @@ cleanup(void) + cleanupmon(mons); + for (i = 0; i < CurLast; i++) + drw_cur_free(drw, cursor[i]); +- for (i = 0; i < LENGTH(colors); i++) ++ for (i = 0; i < LENGTH(colors) + 1; i++) + free(scheme[i]); + XDestroyWindow(dpy, wmcheckwin); + drw_free(drw); +@@ -693,6 +694,114 @@ dirtomon(int dir) + return m; + } + ++int ++drawstatusbar(Monitor *m, int bh, char* stext) { ++ int ret, i, w, x, len; ++ short isCode = 0; ++ char *text; ++ char *p; ++ ++ len = strlen(stext) + 1 ; ++ if (!(text = (char*) malloc(sizeof(char)*len))) ++ die("malloc"); ++ p = text; ++ memcpy(text, stext, len); ++ ++ /* compute width of the status text */ ++ w = 0; ++ i = -1; ++ while (text[++i]) { ++ if (text[i] == '^') { ++ if (!isCode) { ++ isCode = 1; ++ text[i] = '\0'; ++ w += TEXTW(text) - lrpad; ++ text[i] = '^'; ++ if (text[++i] == 'f') ++ w += atoi(text + ++i); ++ } else { ++ isCode = 0; ++ text = text + i + 1; ++ i = -1; ++ } ++ } ++ } ++ if (!isCode) ++ w += TEXTW(text) - lrpad; ++ else ++ isCode = 0; ++ text = p; ++ ++ w += 2; /* 1px padding on both sides */ ++ ret = x = m->ww - w; ++ ++ drw_setscheme(drw, scheme[LENGTH(colors)]); ++ drw->scheme[ColFg] = scheme[SchemeNorm][ColFg]; ++ drw->scheme[ColBg] = scheme[SchemeNorm][ColBg]; ++ drw_rect(drw, x, 0, w, bh, 1, 1); ++ x++; ++ ++ /* process status text */ ++ i = -1; ++ while (text[++i]) { ++ if (text[i] == '^' && !isCode) { ++ isCode = 1; ++ ++ text[i] = '\0'; ++ w = TEXTW(text) - lrpad; ++ drw_text(drw, x, 0, w, bh, 0, text, 0); ++ ++ x += w; ++ ++ /* process code */ ++ while (text[++i] != '^') { ++ if (text[i] == 'c') { ++ char buf[8]; ++ memcpy(buf, (char*)text+i+1, 7); ++ buf[7] = '\0'; ++ drw_clr_create(drw, &drw->scheme[ColFg], buf); ++ i += 7; ++ } else if (text[i] == 'b') { ++ char buf[8]; ++ memcpy(buf, (char*)text+i+1, 7); ++ buf[7] = '\0'; ++ drw_clr_create(drw, &drw->scheme[ColBg], buf); ++ i += 7; ++ } else if (text[i] == 'd') { ++ drw->scheme[ColFg] = scheme[SchemeNorm][ColFg]; ++ drw->scheme[ColBg] = scheme[SchemeNorm][ColBg]; ++ } else if (text[i] == 'r') { ++ int rx = atoi(text + ++i); ++ while (text[++i] != ','); ++ int ry = atoi(text + ++i); ++ while (text[++i] != ','); ++ int rw = atoi(text + ++i); ++ while (text[++i] != ','); ++ int rh = atoi(text + ++i); ++ ++ drw_rect(drw, rx + x, ry, rw, rh, 1, 0); ++ } else if (text[i] == 'f') { ++ x += atoi(text + ++i); ++ } ++ } ++ ++ text = text + i + 1; ++ i=-1; ++ isCode = 0; ++ } ++ } ++ ++ if (!isCode) { ++ w = TEXTW(text) - lrpad; ++ drw_text(drw, x, 0, w, bh, 0, text, 0); ++ } ++ ++ drw_setscheme(drw, scheme[SchemeNorm]); ++ free(p); ++ ++ return ret; ++} ++ + void + drawbar(Monitor *m) + { +@@ -704,9 +813,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]); +- tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ +- drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); ++ tw = m->ww - drawstatusbar(m, bh, stext); + } + + for (c = m->clients; c; c = c->next) { +@@ -1568,7 +1675,8 @@ setup(void) + cursor[CurResize] = drw_cur_create(drw, XC_sizing); + cursor[CurMove] = drw_cur_create(drw, XC_fleur); + /* init appearance */ +- scheme = ecalloc(LENGTH(colors), sizeof(Clr *)); ++ scheme = ecalloc(LENGTH(colors) + 1, sizeof(Clr *)); ++ scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], 3); + for (i = 0; i < LENGTH(colors); i++) + scheme[i] = drw_scm_create(drw, colors[i], 3); + /* init bars */ +-- +2.26.2 + diff --git a/dwm/patches/dwm-statuscolors-20181008-b69c870.diff b/dwm/patches/dwm-statuscolors-20181008-b69c870.diff deleted file mode 100644 index 8c7869a..0000000 --- a/dwm/patches/dwm-statuscolors-20181008-b69c870.diff +++ /dev/null @@ -1,94 +0,0 @@ -From 35418d156fccb922710f6ca80a1f3972ba88b42f Mon Sep 17 00:00:00 2001 -From: Danny O'Brien -Date: Mon, 8 Oct 2018 19:21:29 -0700 -Subject: [PATCH] Add colors to status message in bar. - -This patch matches the format used by -https://dwm.suckless.org/patches/statuscolors/ -- An \x01 character -switches to the normal foreground/color combo, \x02 switches to the -color combo used for selected tags, \03 is set by default to black on -yellow, \04 is white on red. - -These color settings are defined in the colors array in config.def.h. -More can be added, but don't have more than 32, or you'll start hitting -real ASCII. - -This applies cleanly on mainline dwm from commit 022d076 (Sat Jan 7 -17:21:29 2017 +0100) until at least b69c870 (Sat Jun 2 17:15:42 2018 -+020). - ---- - config.def.h | 13 ++++++++++--- - dwm.c | 18 ++++++++++++++++-- - 2 files changed, 26 insertions(+), 5 deletions(-) - -diff --git a/config.def.h b/config.def.h -index 1c0b587..df92695 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -12,10 +12,17 @@ static const char col_gray2[] = "#444444"; - static const char col_gray3[] = "#bbbbbb"; - static const char col_gray4[] = "#eeeeee"; - static const char col_cyan[] = "#005577"; -+static const char col_black[] = "#000000"; -+static const char col_red[] = "#ff0000"; -+static const char col_yellow[] = "#ffff00"; -+static const char col_white[] = "#ffffff"; -+ - static const char *colors[][3] = { -- /* fg bg border */ -- [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, -- [SchemeSel] = { col_gray4, col_cyan, col_cyan }, -+ /* fg bg border */ -+ [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, -+ [SchemeSel] = { col_gray4, col_cyan, col_cyan }, -+ [SchemeWarn] = { col_black, col_yellow, col_red }, -+ [SchemeUrgent]= { col_white, col_red, col_red }, - }; - - /* tagging */ -diff --git a/dwm.c b/dwm.c -index 4465af1..9d9d46f 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, SchemeWarn, SchemeUrgent }; /* color schemes */ - enum { NetSupported, NetWMName, NetWMState, NetWMCheck, - NetWMFullscreen, NetActiveWindow, NetWMWindowType, - NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ -@@ -699,13 +699,27 @@ drawbar(Monitor *m) - int boxs = drw->fonts->h / 9; - int boxw = drw->fonts->h / 6 + 2; - unsigned int i, occ = 0, urg = 0; -+ char *ts = stext; -+ char *tp = stext; -+ int tx = 0; -+ char ctmp; - Client *c; - - /* 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]); - sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ -- drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0); -+ while (1) { -+ if ((unsigned int)*ts > LENGTH(colors)) { ts++; continue ; } -+ ctmp = *ts; -+ *ts = '\0'; -+ drw_text(drw, m->ww - sw + tx, 0, sw - tx, bh, 0, tp, 0); -+ tx += TEXTW(tp) -lrpad; -+ if (ctmp == '\0') { break; } -+ drw_setscheme(drw, scheme[(unsigned int)(ctmp-1)]); -+ *ts = ctmp; -+ tp = ++ts; -+ } - } - - for (c = m->clients; c; c = c->next) { --- -2.19.1 - -- cgit v1.2.3