Revert "try to add status2d with barpadding again"

This reverts commit 491aa7db88.
This commit is contained in:
Sakooooo 2023-08-05 02:31:52 +03:00
parent c5456ecfe3
commit 1a596bacda
Signed by: sako
GPG key ID: 3FD715D87D7725E0
5 changed files with 21 additions and 201 deletions

View file

@ -23,17 +23,16 @@ static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#cccccc"; static const char col_gray3[] = "#cccccc";
static const char col_gray4[] = "#eeeeee"; static const char col_gray4[] = "#eeeeee";
static const char col_cyan[] = "#770000"; static const char col_cyan[] = "#770000";
static const char col_red[] = "#5E3737";
static const char col_red_dark[] = "#4D1111";
static const char *colors[][3] = { static const char *colors[][3] = {
/* fg bg border */ /* fg bg border */
[SchemeNorm] = { col_gray3, col_red, col_gray2 }, [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_red_dark, col_cyan }, [SchemeSel] = { col_gray4, col_cyan, col_cyan },
}; };
static const char *const autostart[] = { static const char *const autostart[] = {
"/home/sako/.dwmscripts/bar.sh", NULL, "xsetroot", "-cursor_name", "Catppuccin-Mocha-Dark", NULL,
"feh", "--bg-scale", "/home/sako/.config/bspwm/background.png", NULL, "feh", "--bg-scale", "/home/sako/.config/bspwm/background.png", NULL,
"dwmblocks", NULL,
"nm-applet", NULL, "nm-applet", NULL,
"blueman-applet", NULL, "blueman-applet", NULL,
"keepassxc", NULL, "keepassxc", NULL,
@ -112,22 +111,6 @@ static const Key keys[] = {
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_p, setlayout, {0} }, { MODKEY, XK_p, setlayout, {0} },
{ MODKEY|ShiftMask, XK_p, togglefloating, {0} }, { MODKEY|ShiftMask, XK_p, togglefloating, {0} },
{ MODKEY, XK_Down, moveresize, {.v = "0x 25y 0w 0h" } },
{ MODKEY, XK_Up, moveresize, {.v = "0x -25y 0w 0h" } },
{ MODKEY, XK_Right, moveresize, {.v = "25x 0y 0w 0h" } },
{ MODKEY, XK_Left, moveresize, {.v = "-25x 0y 0w 0h" } },
{ MODKEY|ShiftMask, XK_Down, moveresize, {.v = "0x 0y 0w 25h" } },
{ MODKEY|ShiftMask, XK_Up, moveresize, {.v = "0x 0y 0w -25h" } },
{ MODKEY|ShiftMask, XK_Right, moveresize, {.v = "0x 0y 25w 0h" } },
{ MODKEY|ShiftMask, XK_Left, moveresize, {.v = "0x 0y -25w 0h" } },
{ MODKEY|ControlMask, XK_Up, moveresizeedge, {.v = "t"} },
{ MODKEY|ControlMask, XK_Down, moveresizeedge, {.v = "b"} },
{ MODKEY|ControlMask, XK_Left, moveresizeedge, {.v = "l"} },
{ MODKEY|ControlMask, XK_Right, moveresizeedge, {.v = "r"} },
{ MODKEY|ControlMask|ShiftMask, XK_Up, moveresizeedge, {.v = "T"} },
{ MODKEY|ControlMask|ShiftMask, XK_Down, moveresizeedge, {.v = "B"} },
{ MODKEY|ControlMask|ShiftMask, XK_Left, moveresizeedge, {.v = "L"} },
{ MODKEY|ControlMask|ShiftMask, XK_Right, moveresizeedge, {.v = "R"} },
{ MODKEY|ShiftMask, XK_f, togglefullscr, {0} }, { MODKEY|ShiftMask, XK_f, togglefullscr, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } }, { MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } }, { MODKEY, XK_comma, focusmon, {.i = -1 } },

View file

@ -1,11 +0,0 @@
--- config.def.h
+++ config.def.h
@@ -5,6 +5,8 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
static const unsigned int snap = 32; /* snap pixel */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
+static const int vertpad = 10; /* vertical padding of bar */
+static const int sidepad = 10; /* horizontal padding of bar */
static const char *fonts[] = { "monospace:size=10" };
static const char dmenufont[] = "monospace:size=10";
static const char col_gray1[] = "#222222";

View file

@ -279,8 +279,6 @@ static int screen;
static int sw, sh; /* X display screen geometry width, height */ static int sw, sh; /* X display screen geometry width, height */
static int bh; /* bar height */ static int bh; /* bar height */
static int lrpad; /* sum of left and right padding for text */ static int lrpad; /* sum of left and right padding for text */
static int vp; /* vertical padding for bar */
static int sp; /* side padding for bar */
static int (*xerrorxlib)(Display *, XErrorEvent *); static int (*xerrorxlib)(Display *, XErrorEvent *);
static unsigned int numlockmask = 0; static unsigned int numlockmask = 0;
static void (*handler[LASTEvent]) (XEvent *) = { static void (*handler[LASTEvent]) (XEvent *) = {
@ -871,7 +869,7 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
drw_setscheme(drw, scheme[LENGTH(colors)]); drw_setscheme(drw, scheme[LENGTH(colors)]);
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg]; drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
drw->scheme[ColBg] = scheme[SchemeNorm][ColBg]; drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
drw_rect(drw, x - 2 * sp, 0, w, bh, 1, 1); drw_rect(drw, x, 0, w, bh, 1, 1);
x++; x++;
/* process status text */ /* process status text */
@ -882,7 +880,7 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
text[i] = '\0'; text[i] = '\0';
w = TEXTW(text) - lrpad; w = TEXTW(text) - lrpad;
drw_text(drw, x - 2 * sp, 0, w, bh, 0, text, 0); drw_text(drw, x, 0, w, bh, 0, text, 0);
x += w; x += w;
@ -912,7 +910,7 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
while (text[++i] != ','); while (text[++i] != ',');
int rh = atoi(text + ++i); int rh = atoi(text + ++i);
drw_rect(drw, rx + x - 2 * sp, ry, rw, rh, 1, 0); drw_rect(drw, rx + x, ry, rw, rh, 1, 0);
} else if (text[i] == 'f') { } else if (text[i] == 'f') {
x += atoi(text + ++i); x += atoi(text + ++i);
} }
@ -979,12 +977,12 @@ drawbar(Monitor *m)
if ((w = m->ww - tw - stw - x) > bh) { if ((w = m->ww - tw - stw - x) > bh) {
if (m->sel) { if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w - 2 * sp, bh, lrpad / 2, m->sel->name, 0); drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
if (m->sel->isfloating) if (m->sel->isfloating)
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
} else { } else {
drw_setscheme(drw, scheme[SchemeNorm]); drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, x, 0, w - 2 * sp, bh, 1, 1); drw_rect(drw, x, 0, w, bh, 1, 1);
} }
} }
drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh); drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh);
@ -1746,7 +1744,7 @@ resizebarwin(Monitor *m) {
unsigned int w = m->ww; unsigned int w = m->ww;
if (showsystray && m == systraytomon(m) && !systrayonleft) if (showsystray && m == systraytomon(m) && !systrayonleft)
w -= getsystraywidth(); w -= getsystraywidth();
XMoveResizeWindow(dpy, m->barwin, m->wx + sp, m->by + vp, w - 2 * sp, bh); XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, w, bh);
} }
void void
@ -2064,10 +2062,7 @@ setup(void)
die("no fonts could be loaded."); die("no fonts could be loaded.");
lrpad = drw->fonts->h; lrpad = drw->fonts->h;
bh = drw->fonts->h + 2; bh = drw->fonts->h + 2;
sp = sidepad;
vp = (topbar == 1) ? vertpad : - vertpad;
updategeom(); updategeom();
/* init atoms */ /* init atoms */
utf8string = XInternAtom(dpy, "UTF8_STRING", False); utf8string = XInternAtom(dpy, "UTF8_STRING", False);
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
@ -2393,7 +2388,7 @@ updatebars(void)
w = m->ww; w = m->ww;
if (showsystray && m == systraytomon(m)) if (showsystray && m == systraytomon(m))
w -= getsystraywidth(); w -= getsystraywidth();
m->barwin = XCreateWindow(dpy, root, m->wx + sp, m->by + vp, w - 2 * sp, bh, 0, DefaultDepth(dpy, screen), m->barwin = XCreateWindow(dpy, root, m->wx, m->by, w, bh, 0, DefaultDepth(dpy, screen),
CopyFromParent, DefaultVisual(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
@ -2410,11 +2405,11 @@ updatebarpos(Monitor *m)
m->wy = m->my; m->wy = m->my;
m->wh = m->mh; m->wh = m->mh;
if (m->showbar) { if (m->showbar) {
m->wh = m->wh - vertpad - bh; m->wh -= bh;
m->by = m->topbar ? m->wy : m->wy + m->wh + vertpad; m->by = m->topbar ? m->wy : m->wy + m->wh;
m->wy = m->topbar ? m->wy + bh + vp : m->wy; m->wy = m->topbar ? m->wy + bh : m->wy;
} else } else
m->by = -bh - vp; m->by = -bh;
} }
void void

View file

@ -185,7 +185,6 @@ static void detachstack(Client *c);
static Monitor *dirtomon(int dir); static Monitor *dirtomon(int dir);
static void drawbar(Monitor *m); static void drawbar(Monitor *m);
static void drawbars(void); static void drawbars(void);
static int drawstatusbar(Monitor *m, int bh, char* text);
static void enternotify(XEvent *e); static void enternotify(XEvent *e);
static void expose(XEvent *e); static void expose(XEvent *e);
static void focus(Client *c); static void focus(Client *c);
@ -274,7 +273,7 @@ static void autostart_exec(void);
/* variables */ /* variables */
static Systray *systray = NULL; static Systray *systray = NULL;
static const char broken[] = "broken"; static const char broken[] = "broken";
static char stext[1024]; static char stext[256];
static int screen; static int screen;
static int sw, sh; /* X display screen geometry width, height */ static int sw, sh; /* X display screen geometry width, height */
static int bh; /* bar height */ static int bh; /* bar height */
@ -560,7 +559,7 @@ cleanup(void)
for (i = 0; i < CurLast; i++) for (i = 0; i < CurLast; i++)
drw_cur_free(drw, cursor[i]); drw_cur_free(drw, cursor[i]);
for (i = 0; i < LENGTH(colors) + 1; i++) for (i = 0; i < LENGTH(colors); i++)
free(scheme[i]); free(scheme[i]);
free(scheme); free(scheme);
XDestroyWindow(dpy, wmcheckwin); XDestroyWindow(dpy, wmcheckwin);
@ -824,115 +823,6 @@ dirtomon(int dir)
return m; 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 = m->ww - w;
x = ret - getsystraywidth();
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 void
drawbar(Monitor *m) drawbar(Monitor *m)
{ {
@ -950,7 +840,9 @@ drawbar(Monitor *m)
/* draw status first so it can be overdrawn by tags later */ /* draw status first so it can be overdrawn by tags later */
if (m == selmon) { /* status is only drawn on selected monitor */ if (m == selmon) { /* status is only drawn on selected monitor */
tw = m->ww - drawstatusbar(m, bh, stext); drw_setscheme(drw, scheme[SchemeNorm]);
tw = TEXTW(stext) - lrpad / 2 + 2; /* 2px extra right padding */
drw_text(drw, m->ww - tw - stw, 0, tw, bh, lrpad / 2 - 2, stext, 0);
} }
resizebarwin(m); resizebarwin(m);
@ -2090,8 +1982,7 @@ setup(void)
cursor[CurResize] = drw_cur_create(drw, XC_sizing); cursor[CurResize] = drw_cur_create(drw, XC_sizing);
cursor[CurMove] = drw_cur_create(drw, XC_fleur); cursor[CurMove] = drw_cur_create(drw, XC_fleur);
/* init appearance */ /* init appearance */
scheme = ecalloc(LENGTH(colors) + 1, sizeof(Clr *)); scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], 3);
for (i = 0; i < LENGTH(colors); i++) for (i = 0; i < LENGTH(colors); i++)
scheme[i] = drw_scm_create(drw, colors[i], 3); scheme[i] = drw_scm_create(drw, colors[i], 3);
/* init system tray */ /* init system tray */

View file

@ -1,38 +0,0 @@
--- dwm.c
+++ dwm.c
@@ -570,7 +572,7 @@ configurenotify(XEvent *e)
for (c = m->clients; c; c = c->next)
if (c->isfullscreen)
resizeclient(c, m->mx, m->my, m->mw, m->mh);
- XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
+ XMoveResizeWindow(dpy, m->barwin, m->wx + sp, m->by + vp, m->ww - 2 * sp, bh);
}
focus(NULL);
arrange(NULL);
@@ -708,7 +710,7 @@ drawbar(Monitor *m)
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);
+ drw_text(drw, m->ww - tw - 2 * sp, 0, tw, bh, 0, stext, 0);
}
for (c = m->clients; c; c = c->next) {
@@ -1709,7 +1714,7 @@ togglebar(const Arg *arg)
{
selmon->showbar = !selmon->showbar;
updatebarpos(selmon);
- XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
+ XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + sp, selmon->by + vp, selmon->ww - 2 * sp, bh);
arrange(selmon);
}
@@ -1819,7 +1824,7 @@ updatebars(void)
for (m = mons; m; m = m->next) {
if (m->barwin)
continue;
- m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen),
+ m->barwin = XCreateWindow(dpy, root, m->wx + sp, m->by + vp, m->ww - 2 * sp, bh, 0, DefaultDepth(dpy, screen),
CopyFromParent, DefaultVisual(dpy, screen),
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);