Finishing basic status bar handling

This commit is contained in:
Zoe Roux
2022-02-05 23:54:13 +01:00
parent e2119fbe3a
commit 923c8302fa
6 changed files with 20 additions and 35 deletions
+9 -2
View File
@@ -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} },
+8 -9
View File
@@ -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);
}
}
}
sigqueue(dwmblockspid, SIGRTMIN+dwmblockssig, sv);
}
+1 -13
View File
@@ -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;
}
}
+1 -3
View File
@@ -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);
static int status2dtextlength(char *stext);
-6
View File
@@ -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)
{
+1 -2
View File
@@ -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);
static void copyvalidchars(char *text, char *rawtext);