mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Upgrading statuscmd patch.
The original statuscmd patch has been renamed to statuscmd-nosignal to separate the logic from the dwmblocks integration that involves signals. I assume as the latter has become more popular it has replaced the statuscmd in name.
This commit is contained in:
parent
7efb64d685
commit
6e80cb5f36
@ -780,8 +780,13 @@ static const char *termcmd[] = { "st", NULL };
|
|||||||
#define STATUSBAR "dwmblocks"
|
#define STATUSBAR "dwmblocks"
|
||||||
#else
|
#else
|
||||||
/* commands spawned when clicking statusbar, the mouse button pressed is exported as BUTTON */
|
/* commands spawned when clicking statusbar, the mouse button pressed is exported as BUTTON */
|
||||||
static const char *statuscmds[] = { "notify-send Mouse$BUTTON", "notify-send Cat$BUTTON", "notify-send Dog$BUTTON" };
|
static const StatusCmd statuscmds[] = {
|
||||||
static char *statuscmd[] = { "/bin/sh", "-c", NULL, NULL };
|
{ "notify-send Volume$BUTTON", 1 },
|
||||||
|
{ "notify-send CPU$BUTTON", 2 },
|
||||||
|
{ "notify-send Battery$BUTTON", 3 },
|
||||||
|
};
|
||||||
|
/* test the above with: xsetroot -name "$(printf '\x01Volume |\x02 CPU |\x03 Battery')" */
|
||||||
|
static const char *statuscmd[] = { "/bin/sh", "-c", NULL, NULL };
|
||||||
#endif // BAR_DWMBLOCKS_PATCH
|
#endif // BAR_DWMBLOCKS_PATCH
|
||||||
#endif // BAR_STATUSCMD_PATCH
|
#endif // BAR_STATUSCMD_PATCH
|
||||||
|
|
||||||
|
41
dwm.c
41
dwm.c
@ -1066,6 +1066,11 @@ buttonpress(XEvent *e)
|
|||||||
const BarRule *br;
|
const BarRule *br;
|
||||||
BarArg carg = { 0, 0, 0, 0 };
|
BarArg carg = { 0, 0, 0, 0 };
|
||||||
click = ClkRootWin;
|
click = ClkRootWin;
|
||||||
|
|
||||||
|
#if BAR_STATUSCMD_PATCH && !BAR_DWMBLOCKS_PATCH
|
||||||
|
*lastbutton = '0' + ev->button;
|
||||||
|
#endif // BAR_STATUSCMD_PATCH | BAR_DWMBLOCKS_PATCH
|
||||||
|
|
||||||
/* focus monitor if necessary */
|
/* focus monitor if necessary */
|
||||||
if ((m = wintomon(ev->window)) && m != selmon
|
if ((m = wintomon(ev->window)) && m != selmon
|
||||||
#if FOCUSONCLICK_PATCH
|
#if FOCUSONCLICK_PATCH
|
||||||
@ -3751,29 +3756,10 @@ spawn(const Arg *arg)
|
|||||||
#if RIODRAW_PATCH
|
#if RIODRAW_PATCH
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
#endif // RIODRAW_PATCH
|
#endif // RIODRAW_PATCH
|
||||||
#if BAR_STATUSCMD_PATCH && !BAR_DWMBLOCKS_PATCH
|
|
||||||
char *cmd = NULL;
|
|
||||||
#endif // BAR_STATUSCMD_PATCH | BAR_DWMBLOCKS_PATCH
|
|
||||||
#if !NODMENU_PATCH
|
#if !NODMENU_PATCH
|
||||||
if (arg->v == dmenucmd)
|
if (arg->v == dmenucmd)
|
||||||
dmenumon[0] = '0' + selmon->num;
|
dmenumon[0] = '0' + selmon->num;
|
||||||
#endif // NODMENU_PATCH
|
#endif // NODMENU_PATCH
|
||||||
#if BAR_STATUSCMD_PATCH && !BAR_DWMBLOCKS_PATCH
|
|
||||||
#if !NODMENU_PATCH
|
|
||||||
else if (arg->v == statuscmd)
|
|
||||||
#else
|
|
||||||
if (arg->v == statuscmd)
|
|
||||||
#endif // NODMENU_PATCH
|
|
||||||
{
|
|
||||||
int len = strlen(statuscmds[statuscmdn]) + 1;
|
|
||||||
if (!(cmd = malloc(sizeof(char)*len + sizeof(statusexport))))
|
|
||||||
die("malloc:");
|
|
||||||
strcpy(cmd, statusexport);
|
|
||||||
strcat(cmd, statuscmds[statuscmdn]);
|
|
||||||
cmd[LENGTH(statusexport)-3] = '0' + lastbutton;
|
|
||||||
statuscmd[2] = cmd;
|
|
||||||
}
|
|
||||||
#endif // BAR_STATUSCMD_PATCH | BAR_DWMBLOCKS_PATCH
|
|
||||||
|
|
||||||
#if RIODRAW_PATCH
|
#if RIODRAW_PATCH
|
||||||
if ((pid = fork()) == 0)
|
if ((pid = fork()) == 0)
|
||||||
@ -3783,6 +3769,20 @@ spawn(const Arg *arg)
|
|||||||
{
|
{
|
||||||
if (dpy)
|
if (dpy)
|
||||||
close(ConnectionNumber(dpy));
|
close(ConnectionNumber(dpy));
|
||||||
|
|
||||||
|
#if BAR_STATUSCMD_PATCH && !BAR_DWMBLOCKS_PATCH
|
||||||
|
if (arg->v == statuscmd) {
|
||||||
|
for (int i = 0; i < LENGTH(statuscmds); i++) {
|
||||||
|
if (statuscmdn == statuscmds[i].id) {
|
||||||
|
statuscmd[2] = statuscmds[i].cmd;
|
||||||
|
setenv("BUTTON", lastbutton, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!statuscmd[2])
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
#endif // BAR_STATUSCMD_PATCH | BAR_DWMBLOCKS_PATCH
|
||||||
#if SPAWNCMD_PATCH
|
#if SPAWNCMD_PATCH
|
||||||
if (selmon->sel) {
|
if (selmon->sel) {
|
||||||
const char* const home = getenv("HOME");
|
const char* const home = getenv("HOME");
|
||||||
@ -3823,9 +3823,6 @@ spawn(const Arg *arg)
|
|||||||
perror(" failed");
|
perror(" failed");
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
#if BAR_STATUSCMD_PATCH && !BAR_DWMBLOCKS_PATCH
|
|
||||||
free(cmd);
|
|
||||||
#endif // BAR_STATUSCMD_PATCH | BAR_DWMBLOCKS_PATCH
|
|
||||||
#if RIODRAW_PATCH
|
#if RIODRAW_PATCH
|
||||||
return pid;
|
return pid;
|
||||||
#endif // RIODRAW_PATCH
|
#endif // RIODRAW_PATCH
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#if !BAR_DWMBLOCKS_PATCH
|
#if !BAR_DWMBLOCKS_PATCH
|
||||||
static const char statusexport[] = "export BUTTON=-;";
|
static const char statusexport[] = "export BUTTON=-;";
|
||||||
static int statuscmdn;
|
static int statuscmdn;
|
||||||
static int lastbutton;
|
static char lastbutton[] = "-";
|
||||||
#endif // BAR_DWMBLOCKS_PATCH
|
#endif // BAR_DWMBLOCKS_PATCH
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -49,7 +49,7 @@ click_statuscmd_text(Arg *arg, int rel_x, char *text)
|
|||||||
if (x >= rel_x)
|
if (x >= rel_x)
|
||||||
break;
|
break;
|
||||||
if (ch <= LENGTH(statuscmds))
|
if (ch <= LENGTH(statuscmds))
|
||||||
statuscmdn = ch - 1;
|
statuscmdn = ch;
|
||||||
#endif // BAR_DWMBLOCKS_PATCH
|
#endif // BAR_DWMBLOCKS_PATCH
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,4 +3,9 @@ static int click_statuscmd(Bar *bar, Arg *arg, BarArg *a);
|
|||||||
static int click_statuscmd_es(Bar *bar, Arg *arg, BarArg *a);
|
static int click_statuscmd_es(Bar *bar, Arg *arg, BarArg *a);
|
||||||
#endif // BAR_EXTRASTATUS_PATCH
|
#endif // BAR_EXTRASTATUS_PATCH
|
||||||
static int click_statuscmd_text(Arg *arg, int rel_x, char *text);
|
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);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *cmd;
|
||||||
|
int id;
|
||||||
|
} StatusCmd;
|
Loading…
Reference in New Issue
Block a user