commit 38341da3257fbf5d602897b655cef472ad918a95
parent 93851ff28c3fae70cb48490880730bf8bb543acf
Author: kocotian <kocotian@kocotian.pl>
Date: Sat, 12 Dec 2020 13:51:31 +0100
more keybindings
Diffstat:
M | config.def.h | | | 58 | +++++++++++++++++++++++++++++++++++++++++++++++++++------- |
M | drw.c | | | 11 | ++++++----- |
M | dwm.c | | | 72 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- |
A | patches/dwm-statuscmd-signal-6.2.diff | | | 157 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
4 files changed, 283 insertions(+), 15 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -8,7 +8,7 @@ static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const int barheight = 25; /* height of a bar; 0 equals autocalculation */
static const int attachdirection = 0; /* 0 default, 1 above, 2 aside, 3 below, 4 bottom, 5 top */
-static const char *fonts[] = { "monospace:size=8" };
+static const char *fonts[] = { "monospace:size=8", "JoyPixels:pixelsize=10:antialias=true:autohint=true" };
static const char dmenufont[] = "monospace:size=8";
static const char col_gray1[] = "#222222";
static const char col_gray2[] = "#444444";
@@ -89,8 +89,20 @@ static const char *termcmd[] = { "st", NULL };
#include "movestack.c"
static Key keys[] = {
/* modifier key function argument */
+ { MODKEY, XK_grave, spawn, SHCMD("dmenuunicode") },
+ { MODKEY, XK_minus, spawn, SHCMD("pamixer --allow-boost -d 5; kill -44 $(pidof dwmblocks)") },
+ { MODKEY|ShiftMask, XK_minus, spawn, SHCMD("pamixer --allow-boost -d 15; kill -44 $(pidof dwmblocks)") },
+ { MODKEY, XK_equal, spawn, SHCMD("pamixer --allow-boost -i 5; kill -44 $(pidof dwmblocks)") },
+ { MODKEY|ShiftMask, XK_equal, spawn, SHCMD("pamixer --allow-boost -i 15; kill -44 $(pidof dwmblocks)") },
+ { MODKEY, XK_BackSpace, spawn, SHCMD("sysact") },
+ { MODKEY|ShiftMask, XK_BackSpace, spawn, SHCMD("sysact") },
+
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY, XK_q, killclient, {0} },
+ { MODKEY, XK_w, spawn, SHCMD("$BROWSER") },
+ { MODKEY|ShiftMask, XK_w, spawn, SHCMD("st -e sudo nmtui") },
+ { MODKEY, XK_e, spawn, SHCMD("st -e neomutt ; pkill -RTMIN+12 dwmblocks; rmdir ~/.abook") },
+ { MODKEY|ShiftMask, XK_e, spawn, SHCMD("st -e abook -C ~/.config/abook/abookrc --datafile ~/.config/abook/addressbook") },
{ MODKEY, XK_r, reorganizetags, {0} },
{ MODKEY|ShiftMask, XK_r, setcfact, {.f = 0.00} },
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
@@ -101,13 +113,26 @@ static Key keys[] = {
{ MODKEY|ShiftMask, XK_u, setlayout, {.v = &layouts[5]} },
{ MODKEY, XK_o, incnmaster, {.i = +1 } },
{ MODKEY|ShiftMask, XK_o, incnmaster, {.i = -1 } },
-
+ { MODKEY, XK_p, spawn, SHCMD("mpc toggle") },
+ { MODKEY|ShiftMask, XK_p, spawn, SHCMD("mpc pause ; pauseallmpv") },
+ { MODKEY, XK_bracketleft, spawn, SHCMD("mpc seek -10") },
+ { MODKEY|ShiftMask, XK_bracketleft, spawn, SHCMD("mpc seek -60") },
+ { MODKEY, XK_bracketright, spawn, SHCMD("mpc seek +10") },
+ { MODKEY|ShiftMask, XK_bracketright, spawn, SHCMD("mpc seek +60") },
+
+ { MODKEY, XK_a, spawn, SHCMD("st -e lf") },
+ { MODKEY|ShiftMask, XK_a, spawn, SHCMD("st -e htop") },
{ MODKEY, XK_d, spawn, {.v = dmenucmd } },
+ { MODKEY|ShiftMask, XK_d, spawn, SHCMD("dmenize") },
{ MODKEY, XK_f, togglefullscr, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } },
{ MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } },
+ { MODKEY|Mod1Mask, XK_j, focusmon, {.i = -1 } },
+ { MODKEY|Mod1Mask, XK_k, focusmon, {.i = +1 } },
+ { MODKEY|Mod1Mask|ShiftMask, XK_j, tagmon, {.i = -1 } },
+ { MODKEY|Mod1Mask|ShiftMask, XK_k, tagmon, {.i = +1 } },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
{ MODKEY|ShiftMask, XK_h, setcfact, {.f = -0.25} },
@@ -118,14 +143,31 @@ static Key keys[] = {
{ MODKEY|ShiftMask, XK_z, resetlayout, {0} },
{ MODKEY, XK_x, setattach, {0} },
{ MODKEY, XK_b, togglebar, {0} },
- { MODKEY, XK_comma, focusmon, {.i = -1 } },
- { MODKEY, XK_period, focusmon, {.i = +1 } },
- { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
- { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_b, spawn, SHCMD("setbg") },
+ { MODKEY, XK_n, spawn, SHCMD("st -e newsboat; pkill -RTMIN+6 dwmblocks") },
+ { MODKEY|ShiftMask, XK_n, spawn, SHCMD("st -e nvim -c VimwikiIndex") },
+ { MODKEY, XK_m, spawn, SHCMD("st -e ncmpcpp") },
+ { MODKEY|ShiftMask, XK_m, spawn, SHCMD("pamixer -t; kill -44 $(pidof dwmblocks)") },
+ { MODKEY, XK_comma, spawn, SHCMD("mpc prev") },
+ { MODKEY|ShiftMask, XK_comma, spawn, SHCMD("mpc seek 0%") },
+ { MODKEY, XK_period, spawn, SHCMD("mpc next") },
+ { MODKEY|ShiftMask, XK_period, spawn, SHCMD("mpc repeat") },
{ MODKEY, XK_space, zoom, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
+ { MODKEY, XK_F4, spawn, SHCMD("st -e pulsemixer; kill -44 $(pidof dwmblocks)") },
+ { MODKEY, XK_F9, spawn, SHCMD("dmenumount") },
+ { MODKEY, XK_F10, spawn, SHCMD("dmenuumount") },
+ { MODKEY, XK_F11, spawn, SHCMD("mpv --no-cache --no-osc --no-input-default-bindings --input-conf=/dev/null --title=webcam $(ls /dev/video[0,2,4,6,8] | tail -n 1)") },
+
+ { 0, XK_Print, spawn, SHCMD("maim /home/kocotian/pix/screen/pic-full-$(date '+%y%m%d-%H%M-%S').png") },
+ { ShiftMask, XK_Print, spawn, SHCMD("maimpick") },
+ { MODKEY, XK_Print, spawn, SHCMD("dmenurecord") },
+ { MODKEY|ShiftMask, XK_Print, spawn, SHCMD("dmenurecord kill") },
+ { MODKEY, XK_Delete, spawn, SHCMD("dmenurecord kill") },
+ { MODKEY, XK_Scroll_Lock, spawn, SHCMD("killall screenkey || screenkey &") },
+
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
TAGKEYS( XK_1, 0)
@@ -149,7 +191,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/drw.c b/drw.c
@@ -140,11 +140,12 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
* https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916349
* and lots more all over the internet.
*/
- FcBool iscol;
- if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) {
- XftFontClose(drw->dpy, xfont);
- return NULL;
- }
+
+ /* FcBool iscol; */
+ /* if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) { */
+ /* XftFontClose(drw->dpy, xfont); */
+ /* return NULL; */
+ /* } */
font = ecalloc(1, sizeof(Fnt));
font->xfont = xfont;
diff --git a/dwm.c b/dwm.c
@@ -186,6 +186,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);
@@ -199,6 +200,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 Atom getatomprop(Client *c, Atom prop);
static int getrootptr(int *x, int *y);
static long getstate(Window w);
@@ -241,6 +243,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 sighup(int unused);
static void sigterm(int unused);
static void spawn(const Arg *arg);
@@ -283,6 +286,9 @@ static pid_t winpid(Window w);
/* 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 */
@@ -614,9 +620,25 @@ buttonpress(XEvent *e)
arg.ui = 1 << i;
} else if (ev->x < x + blw)
click = ClkLtSymbol;
- else if (ev->x > selmon->ww - (int)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);
@@ -802,6 +824,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)
{
@@ -1081,6 +1116,18 @@ getatomprop(Client *c, Atom prop)
}
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)
{
int di;
@@ -1999,6 +2046,23 @@ sigterm(int unused)
}
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)
@@ -2447,8 +2511,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);
}
diff --git a/patches/dwm-statuscmd-signal-6.2.diff b/patches/dwm-statuscmd-signal-6.2.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);
+ }
+