Compare commits
1 Commits
statuscmd
...
statuscmd-
Author | SHA1 | Date | |
---|---|---|---|
|
6770fb61fd |
10
config.def.h
10
config.def.h
@@ -59,10 +59,6 @@ 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, NULL };
|
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||||
static const char *termcmd[] = { "st", NULL };
|
static const char *termcmd[] = { "st", NULL };
|
||||||
|
|
||||||
/* commands spawned when clicking statusbar, the mouse button pressed is exported as BUTTON */
|
|
||||||
static char *statuscmds[] = { "notify-send Mouse$BUTTON" };
|
|
||||||
static char *statuscmd[] = { "/bin/sh", "-c", NULL, NULL };
|
|
||||||
|
|
||||||
static Key keys[] = {
|
static Key keys[] = {
|
||||||
/* modifier key function argument */
|
/* modifier key function argument */
|
||||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||||
@@ -107,9 +103,9 @@ static Button buttons[] = {
|
|||||||
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
||||||
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
||||||
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||||||
{ ClkStatusText, 0, Button1, spawn, {.v = statuscmd } },
|
{ ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1} },
|
||||||
{ ClkStatusText, 0, Button2, spawn, {.v = statuscmd } },
|
{ ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2} },
|
||||||
{ ClkStatusText, 0, Button3, spawn, {.v = statuscmd } },
|
{ ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3} },
|
||||||
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||||
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
||||||
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||||||
|
45
dwm.c
45
dwm.c
@@ -170,6 +170,7 @@ static void focus(Client *c);
|
|||||||
static void focusin(XEvent *e);
|
static void focusin(XEvent *e);
|
||||||
static void focusmon(const Arg *arg);
|
static void focusmon(const Arg *arg);
|
||||||
static void focusstack(const Arg *arg);
|
static void focusstack(const Arg *arg);
|
||||||
|
static int getdwmblockspid();
|
||||||
static Atom getatomprop(Client *c, Atom prop);
|
static Atom getatomprop(Client *c, Atom prop);
|
||||||
static int getrootptr(int *x, int *y);
|
static int getrootptr(int *x, int *y);
|
||||||
static long getstate(Window w);
|
static long getstate(Window w);
|
||||||
@@ -207,6 +208,7 @@ static void setup(void);
|
|||||||
static void seturgent(Client *c, int urg);
|
static void seturgent(Client *c, int urg);
|
||||||
static void showhide(Client *c);
|
static void showhide(Client *c);
|
||||||
static void sigchld(int unused);
|
static void sigchld(int unused);
|
||||||
|
static void sigdwmblocks(const Arg *arg);
|
||||||
static void spawn(const Arg *arg);
|
static void spawn(const Arg *arg);
|
||||||
static void tag(const Arg *arg);
|
static void tag(const Arg *arg);
|
||||||
static void tagmon(const Arg *arg);
|
static void tagmon(const Arg *arg);
|
||||||
@@ -240,8 +242,8 @@ static void zoom(const Arg *arg);
|
|||||||
static const char broken[] = "broken";
|
static const char broken[] = "broken";
|
||||||
static char stext[256];
|
static char stext[256];
|
||||||
static char rawstext[256];
|
static char rawstext[256];
|
||||||
static int statuscmdn;
|
static int dwmblockssig;
|
||||||
static char lastbutton[] = "-";
|
pid_t dwmblockspid = 0;
|
||||||
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, blw = 0; /* bar geometry */
|
static int bh, blw = 0; /* bar geometry */
|
||||||
@@ -426,7 +428,6 @@ buttonpress(XEvent *e)
|
|||||||
Client *c;
|
Client *c;
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
XButtonPressedEvent *ev = &e->xbutton;
|
XButtonPressedEvent *ev = &e->xbutton;
|
||||||
*lastbutton = '0' + ev->button;
|
|
||||||
|
|
||||||
click = ClkRootWin;
|
click = ClkRootWin;
|
||||||
/* focus monitor if necessary */
|
/* focus monitor if necessary */
|
||||||
@@ -447,11 +448,10 @@ buttonpress(XEvent *e)
|
|||||||
click = ClkLtSymbol;
|
click = ClkLtSymbol;
|
||||||
else if (ev->x > (x = selmon->ww - TEXTW(stext) + lrpad)) {
|
else if (ev->x > (x = selmon->ww - TEXTW(stext) + lrpad)) {
|
||||||
click = ClkStatusText;
|
click = ClkStatusText;
|
||||||
|
|
||||||
char *text = rawstext;
|
char *text = rawstext;
|
||||||
int i = -1;
|
int i = -1;
|
||||||
char ch;
|
char ch;
|
||||||
statuscmdn = 0;
|
dwmblockssig = 0;
|
||||||
while (text[++i]) {
|
while (text[++i]) {
|
||||||
if ((unsigned char)text[i] < ' ') {
|
if ((unsigned char)text[i] < ' ') {
|
||||||
ch = text[i];
|
ch = text[i];
|
||||||
@@ -461,7 +461,7 @@ buttonpress(XEvent *e)
|
|||||||
text += i+1;
|
text += i+1;
|
||||||
i = -1;
|
i = -1;
|
||||||
if (x >= ev->x) break;
|
if (x >= ev->x) break;
|
||||||
if (ch <= LENGTH(statuscmds)) statuscmdn = ch - 1;
|
dwmblockssig = ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@@ -907,6 +907,18 @@ getatomprop(Client *c, Atom prop)
|
|||||||
return atom;
|
return atom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
getdwmblockspid()
|
||||||
|
{
|
||||||
|
char buf[16];
|
||||||
|
FILE *fp = popen("pidof -s dwmblocks", "r");
|
||||||
|
fgets(buf, sizeof(buf), fp);
|
||||||
|
pid_t pid = strtoul(buf, NULL, 10);
|
||||||
|
pclose(fp);
|
||||||
|
dwmblockspid = pid;
|
||||||
|
return pid != 0 ? 0 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
getrootptr(int *x, int *y)
|
getrootptr(int *x, int *y)
|
||||||
{
|
{
|
||||||
@@ -1672,15 +1684,28 @@ sigchld(int unused)
|
|||||||
while (0 < waitpid(-1, NULL, WNOHANG));
|
while (0 < waitpid(-1, NULL, WNOHANG));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sigdwmblocks(const Arg *arg)
|
||||||
|
{
|
||||||
|
union sigval sv;
|
||||||
|
sv.sival_int = (dwmblockssig << 8) | arg->i;
|
||||||
|
if (!dwmblockspid)
|
||||||
|
if (getdwmblockspid() == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (sigqueue(dwmblockspid, SIGUSR1, sv) == -1) {
|
||||||
|
if (errno == ESRCH) {
|
||||||
|
if (!getdwmblockspid())
|
||||||
|
sigqueue(dwmblockspid, SIGUSR1, sv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spawn(const Arg *arg)
|
spawn(const Arg *arg)
|
||||||
{
|
{
|
||||||
if (arg->v == dmenucmd)
|
if (arg->v == dmenucmd)
|
||||||
dmenumon[0] = '0' + selmon->num;
|
dmenumon[0] = '0' + selmon->num;
|
||||||
else if (arg->v == statuscmd) {
|
|
||||||
statuscmd[2] = statuscmds[statuscmdn];
|
|
||||||
setenv("BUTTON", lastbutton, 1);
|
|
||||||
}
|
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
if (dpy)
|
if (dpy)
|
||||||
close(ConnectionNumber(dpy));
|
close(ConnectionNumber(dpy));
|
||||||
|
Reference in New Issue
Block a user