From 923c8302fa656adcac3b012537fafc1b2c4a32a1 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 5 Feb 2022 23:54:13 +0100 Subject: [PATCH] Finishing basic status bar handling --- config.h | 11 +++++++++-- patch/bar_dwmblocks.c | 17 ++++++++--------- patch/bar_status2d.c | 14 +------------- patch/bar_status2d.h | 4 +--- patch/bar_statuscmd.c | 6 ------ patch/bar_statuscmd.h | 3 +-- 6 files changed, 20 insertions(+), 35 deletions(-) diff --git a/config.h b/config.h index a845c70..61d8bbd 100644 --- a/config.h +++ b/config.h @@ -5,6 +5,7 @@ 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 char statussep = ';'; /* separator between status bars */ static const char *fonts[] = { "monospace:size=10" }; static const char dmenufont[] = "monospace:size=10"; static const char col_gray1[] = "#222222"; @@ -37,6 +38,8 @@ static const int nmaster = 1; /* number of clients in master area */ static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ +#define STATUSBAR "dwmblocks" + /* Bar rules allow you to configure what is shown where on the bar, as well as * introducing your own bar modules. * @@ -53,7 +56,7 @@ static const BarRule barrules[] = { /* monitor bar alignment widthfunc drawfunc clickfunc name */ { -1, 0, BAR_ALIGN_LEFT, width_tags, draw_tags, click_tags, "tags" }, { -1, 0, BAR_ALIGN_LEFT, width_ltsymbol, draw_ltsymbol, click_ltsymbol, "layout" }, - { 'A', 0, BAR_ALIGN_RIGHT, width_status, draw_status, click_status, "status" }, + { -1, 0, BAR_ALIGN_RIGHT, width_status2d, draw_status2d, click_statuscmd, "status2d" }, { -1, 0, BAR_ALIGN_NONE, width_wintitle, draw_wintitle, click_wintitle, "wintitle" }, }; @@ -124,7 +127,11 @@ static Button buttons[] = { { ClkLtSymbol, 0, Button1, setlayout, {0} }, { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, { ClkWinTitle, 0, Button2, zoom, {0} }, - { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, + { ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1 } }, + { ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2 } }, + { ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3 } }, + { ClkStatusText, 0, Button4, sigdwmblocks, {.i = 4 } }, + { ClkStatusText, 0, Button5, sigdwmblocks, {.i = 5 } }, { ClkClientWin, MODKEY, Button1, movemouse, {0} }, { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, diff --git a/patch/bar_dwmblocks.c b/patch/bar_dwmblocks.c index 442b0bc..8028f8c 100644 --- a/patch/bar_dwmblocks.c +++ b/patch/bar_dwmblocks.c @@ -1,11 +1,12 @@ static int dwmblockssig; pid_t dwmblockspid = 0; + int getdwmblockspid() { char buf[16]; - FILE *fp = popen("pidof -s dwmblocks", "r"); + FILE *fp = popen("pidof -s " STATUSBAR, "r"); if (fgets(buf, sizeof(buf), fp)); pid_t pid = strtoul(buf, NULL, 10); pclose(fp); @@ -17,15 +18,13 @@ void sigdwmblocks(const Arg *arg) { union sigval sv; - sv.sival_int = (dwmblockssig << 8) | arg->i; + + if (!dwmblockssig) + return; + sv.sival_int = arg->i; if (!dwmblockspid) if (getdwmblockspid() == -1) return; - if (sigqueue(dwmblockspid, SIGUSR1, sv) == -1) { - if (errno == ESRCH) { - if (!getdwmblockspid()) - sigqueue(dwmblockspid, SIGUSR1, sv); - } - } -} \ No newline at end of file + sigqueue(dwmblockspid, SIGRTMIN+dwmblockssig, sv); +} diff --git a/patch/bar_status2d.c b/patch/bar_status2d.c index 6111a51..4735d29 100644 --- a/patch/bar_status2d.c +++ b/patch/bar_status2d.c @@ -4,24 +4,12 @@ width_status2d(Bar *bar, BarWidthArg *a) return status2dtextlength(rawstext) + lrpad; } -int -width_status2d_es(Bar *bar, BarWidthArg *a) -{ - return status2dtextlength(rawestext); -} - int draw_status2d(Bar *bar, BarDrawArg *a) { return drawstatusbar(a->x, rawstext); } -int -draw_status2d_es(Bar *bar, BarDrawArg *a) -{ - return drawstatusbar(a->x, rawestext); -} - int drawstatusbar(int x, char* stext) { @@ -168,4 +156,4 @@ status2dtextlength(char* stext) w += TEXTW(text) - lrpad; free(p); return w; -} \ No newline at end of file +} diff --git a/patch/bar_status2d.h b/patch/bar_status2d.h index 0830025..a029f42 100644 --- a/patch/bar_status2d.h +++ b/patch/bar_status2d.h @@ -1,6 +1,4 @@ static int width_status2d(Bar *bar, BarWidthArg *a); -static int width_status2d_es(Bar *bar, BarWidthArg *a); static int draw_status2d(Bar *bar, BarDrawArg *a); -static int draw_status2d_es(Bar *bar, BarDrawArg *a); static int drawstatusbar(int x, char *text); -static int status2dtextlength(char *stext); \ No newline at end of file +static int status2dtextlength(char *stext); diff --git a/patch/bar_statuscmd.c b/patch/bar_statuscmd.c index 28ce120..11db56e 100644 --- a/patch/bar_statuscmd.c +++ b/patch/bar_statuscmd.c @@ -4,12 +4,6 @@ click_statuscmd(Bar *bar, Arg *arg, BarClickArg *a) return click_statuscmd_text(arg, a->rel_x, rawstext); } -int -click_statuscmd_es(Bar *bar, Arg *arg, BarClickArg *a) -{ - return click_statuscmd_text(arg, a->rel_x, rawestext); -} - int click_statuscmd_text(Arg *arg, int rel_x, char *text) { diff --git a/patch/bar_statuscmd.h b/patch/bar_statuscmd.h index d6d428e..25964e6 100644 --- a/patch/bar_statuscmd.h +++ b/patch/bar_statuscmd.h @@ -1,4 +1,3 @@ static int click_statuscmd(Bar *bar, Arg *arg, BarClickArg *a); -static int click_statuscmd_es(Bar *bar, Arg *arg, BarClickArg *a); static int click_statuscmd_text(Arg *arg, int rel_x, char *text); -static void copyvalidchars(char *text, char *rawtext); \ No newline at end of file +static void copyvalidchars(char *text, char *rawtext);