summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2021-02-07 18:32:14 -0500
committerJon Santmyer <jon@jonsantmyer.com>2021-02-07 18:32:14 -0500
commit684f6de00bb19a3c4e2a7a114d685b3196c7c403 (patch)
treee1eded321ed59d005c03db635106e4d9a697f960
parentb3307e4769ddd19aa7a2793f0b0c4631c0c0c05e (diff)
downloaddwm-684f6de00bb19a3c4e2a7a114d685b3196c7c403.tar.gz
dwm-684f6de00bb19a3c4e2a7a114d685b3196c7c403.tar.bz2
dwm-684f6de00bb19a3c4e2a7a114d685b3196c7c403.zip
add statuscmd signal
-rw-r--r--config.def.h64
-rw-r--r--patches/statuscmd-signal.diff157
2 files changed, 200 insertions, 21 deletions
diff --git a/config.def.h b/config.def.h
index 8a8fad9..575ded9 100644
--- a/config.def.h
+++ b/config.def.h
@@ -23,8 +23,8 @@ enum showtab_modes { showtab_never, showtab_auto, showtab_nmodes, showtab_always
static const int showtab = showtab_auto; /* Default tab bar show mode */
static const int toptab = False; /* False means bottom tab bar */
-static const char *fonts[] = { "JetBrains Mono Medium:size=10" };
-static const char dmenufont[] = "JetBrains Mono Medium:size=10";
+static const char *fonts[] = { "Liberation Mono:size=10" };
+static const char dmenufont[] = "Liberation Mono:size=10";
static const char col_gray1[] = "#222222";
static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb";
@@ -54,10 +54,9 @@ static const Rule rules[] = {
*/
/* class instance title tags mask isfloating isterminal noswallow monitor */
{ "Gimp", NULL, NULL, 0, 1, 0, 0, -1 },
- { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1, -1 },
- { "Librewolf", NULL, NULL, 1 << 8, 0, 0, -1, -1 },
- { "St", NULL, NULL, 0, 0, 1, 0, -1 },
- { "Alacritty",NULL, NULL, 0, 0, 1, 0, -1 },
+ { "Chromium", NULL, NULL, 0, 0, 0, -1, -1 },
+ { "LibreWolf", NULL, NULL, 0, 0, 0, -1, -1 },
+ { "st", NULL, NULL, 0, 0, 1, 0, -1 },
{ NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */
};
@@ -102,23 +101,40 @@ static const Layout layouts[] = {
/* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "rofi", "-show", "drun", "-icon-theme" ,"'Papirus'", "-show-icons", NULL };
-static const char *termcmd[] = { "alacritty", NULL };
+static const char *termcmd[] = { "st", NULL };
static const char *browsercmd[] = { "librewolf", NULL };
+static const char *volume_lower[] = { "/bin/sh", "-c", "${HOME}/.dwm/scripts/volume-change.sh -5%", NULL };
+static const char *volume_raise[] = { "/bin/sh", "-c", "${HOME}/.dwm/scripts/volume-change.sh +5%", NULL };
+static const char *volume_mute[] = { "/bin/sh", "-c", "${HOME}/.dwm/scripts/volume-change.sh mute", NULL };
+
+static const char *passmenu[] = { "/bin/sh", "-c", "${HOME}/.local/bin/passmenu-unified.sh", NULL };
+static const char *neomutt[] = { "/usr/bin/st", "neomutt", NULL };
+static const char *newsboat[] = { "/usr/bin/st", "newsboat", NULL };
+
static Key keys[] = {
/* modifier key function argument */
- { MODKEY, XK_d, spawn, {.v = dmenucmd } },
- { MODKEY, XK_Return, spawn, {.v = termcmd } },
- { MODKEY, XK_w, spawn, {.v = browsercmd } },
- { MODKEY, XK_b, togglebar, {0} },
- { MODKEY, XK_j, focusstack, {.i = +1 } },
- { MODKEY, XK_k, focusstack, {.i = -1 } },
- { MODKEY, XK_i, incnmaster, {.i = +1 } },
- { MODKEY, XK_p, incnmaster, {.i = -1 } },
- { MODKEY, XK_h, setmfact, {.f = -0.05} },
- { MODKEY, XK_l, setmfact, {.f = +0.05} },
- { MODKEY|ShiftMask, XK_Return, zoom, {0} },
+ //Basic command spawns
+ { MODKEY, XK_d, spawn, { .v = dmenucmd } },
+ { MODKEY, XK_Return, spawn, { .v = termcmd } },
+ { MODKEY, XK_w, spawn, { .v = browsercmd } },
+ { MODKEY, XK_p, spawn, { .v = passmenu } },
+ { MODKEY, XK_n, spawn, { .v = newsboat } },
+ { MODKEY, XK_m, spawn, { .v = neomutt } },
+
+ //Multimedia
+ #include <X11/XF86keysym.h>
+ { 0, XF86XK_AudioLowerVolume, spawn, { .v = volume_lower } },
+ { 0, XF86XK_AudioRaiseVolume, spawn, { .v = volume_raise } },
+ { 0, XF86XK_AudioMute, spawn, { .v = volume_mute } },
+
+ //Layout
+ { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
+ { MODKEY, XK_s, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XK_m, setlayout, {.v = &layouts[1]} },
+
+ //Gaps
{ MODKEY|Mod1Mask, XK_u, incrgaps, {.i = +1 } },
{ MODKEY|Mod1Mask|ShiftMask, XK_u, incrgaps, {.i = -1 } },
{ MODKEY|Mod1Mask, XK_i, incrigaps, {.i = +1 } },
@@ -135,11 +151,17 @@ static Key keys[] = {
{ MODKEY|Mod1Mask|ShiftMask, XK_9, incrovgaps, {.i = -1 } },
{ MODKEY|Mod1Mask, XK_0, togglegaps, {0} },
{ MODKEY|Mod1Mask|ShiftMask, XK_0, defaultgaps, {0} },
+
+ { MODKEY, XK_b, togglebar, {0} },
+ { MODKEY, XK_j, focusstack, {.i = +1 } },
+ { MODKEY, XK_k, focusstack, {.i = -1 } },
+ { MODKEY, XK_i, incnmaster, {.i = +1 } },
+ { MODKEY, XK_p, incnmaster, {.i = -1 } },
+ { MODKEY, XK_h, setmfact, {.f = -0.05} },
+ { MODKEY, XK_l, setmfact, {.f = +0.05} },
+ { MODKEY|ShiftMask, XK_Return, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY, XK_q, killclient, {0} },
- { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
- { MODKEY, XK_s, setlayout, {.v = &layouts[2]} },
- { MODKEY, XK_m, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_f, togglefullscr, {0} },
diff --git a/patches/statuscmd-signal.diff b/patches/statuscmd-signal.diff
new file mode 100644
index 0000000..97fda1b
--- /dev/null
+++ b/patches/statuscmd-signal.diff
@@ -0,0 +1,157 @@
+diff --git a/config.def.h b/config.def.h
+index 1c0b587..b67825e 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -103,7 +103,9 @@ 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} },
+ { ClkClientWin, MODKEY, Button1, movemouse, {0} },
+ { ClkClientWin, MODKEY, Button2, togglefloating, {0} },
+ { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
+diff --git a/dwm.c b/dwm.c
+index 4465af1..c600131 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -156,6 +156,7 @@ static void clientmessage(XEvent *e);
+ static void configure(Client *c);
+ static void configurenotify(XEvent *e);
+ static void configurerequest(XEvent *e);
++static void copyvalidchars(char *text, char *rawtext);
+ static Monitor *createmon(void);
+ static void destroynotify(XEvent *e);
+ static void detach(Client *c);
+@@ -169,6 +170,7 @@ 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 int getrootptr(int *x, int *y);
+ static long getstate(Window w);
+ static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
+@@ -205,6 +207,7 @@ 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);
+@@ -237,6 +240,9 @@ static void zoom(const Arg *arg);
+ /* variables */
+ static const char broken[] = "broken";
+ static char stext[256];
++static char rawstext[256];
++static int dwmblockssig;
++pid_t dwmblockspid = 0;
+ static int screen;
+ static int sw, sh; /* X display screen geometry width, height */
+ static int bh, blw = 0; /* bar geometry */
+@@ -439,9 +445,26 @@ buttonpress(XEvent *e)
+ arg.ui = 1 << i;
+ } else if (ev->x < x + blw)
+ click = ClkLtSymbol;
+- else if (ev->x > selmon->ww - TEXTW(stext))
++ else if (ev->x > (x = selmon->ww - TEXTW(stext) + lrpad)) {
+ click = ClkStatusText;
+- else
++
++ char *text = rawstext;
++ int i = -1;
++ char ch;
++ dwmblockssig = 0;
++ while (text[++i]) {
++ if ((unsigned char)text[i] < ' ') {
++ ch = text[i];
++ text[i] = '\0';
++ x += TEXTW(text) - lrpad;
++ text[i] = ch;
++ text += i+1;
++ i = -1;
++ if (x >= ev->x) break;
++ dwmblockssig = ch;
++ }
++ }
++ } else
+ click = ClkWinTitle;
+ } else if ((c = wintoclient(ev->window))) {
+ focus(c);
+@@ -627,6 +650,19 @@ configurerequest(XEvent *e)
+ XSync(dpy, False);
+ }
+
++void
++copyvalidchars(char *text, char *rawtext)
++{
++ int i = -1, j = 0;
++
++ while(rawtext[++i]) {
++ if ((unsigned char)rawtext[i] >= ' ') {
++ text[j++] = rawtext[i];
++ }
++ }
++ text[j] = '\0';
++}
++
+ Monitor *
+ createmon(void)
+ {
+@@ -871,6 +907,18 @@ 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)
+ {
+@@ -1636,6 +1684,23 @@ 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)
+ {
+@@ -1987,8 +2052,10 @@ updatesizehints(Client *c)
+ void
+ updatestatus(void)
+ {
+- if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
++ if (!gettextprop(root, XA_WM_NAME, rawstext, sizeof(rawstext)))
+ strcpy(stext, "dwm-"VERSION);
++ else
++ copyvalidchars(stext, rawstext);
+ drawbar(selmon);
+ }
+