Compare commits
1 Commits
statuscmd-
...
statuscmd
Author | SHA1 | Date | |
---|---|---|---|
|
d6df194b8c |
10
config.def.h
10
config.def.h
@@ -59,6 +59,10 @@ 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 *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[] = {
|
||||
/* modifier key function argument */
|
||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||
@@ -103,9 +107,9 @@ static Button buttons[] = {
|
||||
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
||||
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
||||
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||||
{ ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1} },
|
||||
{ ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2} },
|
||||
{ ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3} },
|
||||
{ ClkStatusText, 0, Button1, spawn, {.v = statuscmd } },
|
||||
{ ClkStatusText, 0, Button2, spawn, {.v = statuscmd } },
|
||||
{ ClkStatusText, 0, Button3, spawn, {.v = statuscmd } },
|
||||
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
||||
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||||
|
45
dwm.c
45
dwm.c
@@ -170,7 +170,6 @@ static void focus(Client *c);
|
||||
static void focusin(XEvent *e);
|
||||
static void focusmon(const Arg *arg);
|
||||
static void focusstack(const Arg *arg);
|
||||
static int getdwmblockspid();
|
||||
static Atom getatomprop(Client *c, Atom prop);
|
||||
static int getrootptr(int *x, int *y);
|
||||
static long getstate(Window w);
|
||||
@@ -208,7 +207,6 @@ static void setup(void);
|
||||
static void seturgent(Client *c, int urg);
|
||||
static void showhide(Client *c);
|
||||
static void sigchld(int unused);
|
||||
static void sigdwmblocks(const Arg *arg);
|
||||
static void spawn(const Arg *arg);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
@@ -242,8 +240,8 @@ static void zoom(const Arg *arg);
|
||||
static const char broken[] = "broken";
|
||||
static char stext[256];
|
||||
static char rawstext[256];
|
||||
static int dwmblockssig;
|
||||
pid_t dwmblockspid = 0;
|
||||
static int statuscmdn;
|
||||
static char lastbutton[] = "-";
|
||||
static int screen;
|
||||
static int sw, sh; /* X display screen geometry width, height */
|
||||
static int bh, blw = 0; /* bar geometry */
|
||||
@@ -428,6 +426,7 @@ buttonpress(XEvent *e)
|
||||
Client *c;
|
||||
Monitor *m;
|
||||
XButtonPressedEvent *ev = &e->xbutton;
|
||||
*lastbutton = '0' + ev->button;
|
||||
|
||||
click = ClkRootWin;
|
||||
/* focus monitor if necessary */
|
||||
@@ -448,10 +447,11 @@ buttonpress(XEvent *e)
|
||||
click = ClkLtSymbol;
|
||||
else if (ev->x > (x = selmon->ww - TEXTW(stext) + lrpad)) {
|
||||
click = ClkStatusText;
|
||||
|
||||
char *text = rawstext;
|
||||
int i = -1;
|
||||
char ch;
|
||||
dwmblockssig = 0;
|
||||
statuscmdn = 0;
|
||||
while (text[++i]) {
|
||||
if ((unsigned char)text[i] < ' ') {
|
||||
ch = text[i];
|
||||
@@ -461,7 +461,7 @@ buttonpress(XEvent *e)
|
||||
text += i+1;
|
||||
i = -1;
|
||||
if (x >= ev->x) break;
|
||||
dwmblockssig = ch;
|
||||
if (ch <= LENGTH(statuscmds)) statuscmdn = ch - 1;
|
||||
}
|
||||
}
|
||||
} else
|
||||
@@ -907,18 +907,6 @@ getatomprop(Client *c, Atom prop)
|
||||
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
|
||||
getrootptr(int *x, int *y)
|
||||
{
|
||||
@@ -1684,28 +1672,15 @@ sigchld(int unused)
|
||||
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
|
||||
spawn(const Arg *arg)
|
||||
{
|
||||
if (arg->v == dmenucmd)
|
||||
dmenumon[0] = '0' + selmon->num;
|
||||
else if (arg->v == statuscmd) {
|
||||
statuscmd[2] = statuscmds[statuscmdn];
|
||||
setenv("BUTTON", lastbutton, 1);
|
||||
}
|
||||
if (fork() == 0) {
|
||||
if (dpy)
|
||||
close(ConnectionNumber(dpy));
|
||||
|
Reference in New Issue
Block a user