Added dwmblocks functionality

This commit is contained in:
Santiago Lo Coco 2021-08-07 12:09:49 -03:00
parent 116a7bb006
commit e6d1a05dac
8 changed files with 650 additions and 2701 deletions

View File

@ -12,17 +12,34 @@ static const unsigned int gappov = 30; /* vert outer gap between window
static int smartgaps = 0; /* 1 means no outer gap when there is only one window */ static int smartgaps = 0; /* 1 means no outer gap when there is only one window */
static const int showbar = 1; /* 0 means no bar */ static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */ static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = { "monospace:size=10" }; //static const char *fonts[] = { "monospace:size=10"};
static const char *fonts[] = { "monospace:size=10", "Noto Emoji:pixelsize=12:antialias=true:autohint=true" };
static const char dmenufont[] = "monospace:size=10"; static const char dmenufont[] = "monospace:size=10";
static const char col_gray1[] = "#222222"; static const char col_gray1[] = "#222222";
static const char col_gray2[] = "#444444"; static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb"; static const char col_gray3[] = "#bbbbbb";
static const char col_gray4[] = "#eeeeee"; static const char col_gray4[] = "#eeeeee";
static const char col_cyan[] = "#005577"; static const char col_cyan[] = "#005577";
static const char col1[] = "#ffffff";
static const char col2[] = "#ffffff";
static const char col3[] = "#ffffff";
static const char col4[] = "#ffffff";
static const char col5[] = "#ffffff";
static const char col6[] = "#ffffff";
enum { SchemeNorm, SchemeCol1, SchemeCol2, SchemeCol3, SchemeCol4,
SchemeCol5, SchemeCol6, SchemeSel }; /* color schemes */
static const char *colors[][3] = { static const char *colors[][3] = {
/* fg bg border */ /* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_cyan, col_cyan }, [SchemeCol1] = { col1, col_gray1, col_gray2 },
[SchemeCol2] = { col2, col_gray1, col_gray2 },
[SchemeCol3] = { col3, col_gray1, col_gray2 },
[SchemeCol4] = { col4, col_gray1, col_gray2 },
[SchemeCol5] = { col5, col_gray1, col_gray2 },
[SchemeCol6] = { col6, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
}; };
/* tagging */ /* tagging */
@ -36,7 +53,7 @@ static const Rule rules[] = {
/* class instance title tags mask isfloating isterminal noswallow monitor */ /* class instance title tags mask isfloating isterminal noswallow monitor */
{ "Gimp", NULL, NULL, 0, 1, 0, 0, -1 }, { "Gimp", NULL, NULL, 0, 1, 0, 0, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1 }, { "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1 },
{ "st", NULL, NULL, 0, 0, 1, 1, -1 }, { "st", NULL, NULL, 0, 0, 1, 0, -1 },
}; };
/* layout(s) */ /* layout(s) */
@ -84,9 +101,11 @@ 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 };
static const char *upvol[] = { "pulsemixer" , "--change-volume", "+5", NULL }; /*
static const char *downvol[] = { "pulsemixer" , "--change-volume", "-5", NULL }; static const char *upvol[] = { "pulsemixer" , "--change-volume", "+1", NULL };
static const char *downvol[] = { "pulsemixer" , "--change-volume", "-1", NULL };
static const char *mutevol[] = { "pulsemixer" , "--toggle-mute", NULL }; static const char *mutevol[] = { "pulsemixer" , "--toggle-mute", NULL };
*/
static Key keys[] = { static Key keys[] = {
/* modifier key function argument */ /* modifier key function argument */
@ -145,9 +164,18 @@ static Key keys[] = {
// https://gist.github.com/palopezv/efd34059af6126ad970940bcc6a90f2e // https://gist.github.com/palopezv/efd34059af6126ad970940bcc6a90f2e
// In my case, these XF86XK keys are FN+F2, FN+F4, FN+F3 respectively... // In my case, these XF86XK keys are FN+F2, FN+F4, FN+F3 respectively...
/*
{ 0, XF86XK_AudioLowerVolume, spawn, {.v = downvol } }, { 0, XF86XK_AudioLowerVolume, spawn, {.v = downvol } },
{ 0, XF86XK_AudioMute, spawn, {.v = mutevol } }, { 0, XF86XK_AudioMute, spawn, {.v = mutevol } },
{ 0, XF86XK_AudioRaiseVolume, spawn, {.v = upvol } }, { 0, XF86XK_AudioRaiseVolume, spawn, {.v = upvol } },
*/
// It says that SHCMD is deprecated?
{ 0, XF86XK_AudioLowerVolume, spawn, SHCMD("pulsemixer --change-volume -1; sigdwmblocks 2") },
{ 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("pulsemixer --change-volume +1; sigdwmblocks 2") },
{ 0, XF86XK_AudioMute, spawn, SHCMD("pulsemixer --toggle-mute; sigdwmblocks 2") },
{ MODKEY, XK_v, spawn, SHCMD("clipmenu") },
}; };
/* button definitions */ /* button definitions */
@ -157,7 +185,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, 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, Button1, movemouse, {0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} }, { ClkClientWin, MODKEY, Button2, togglefloating, {0} },
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} }, { ClkClientWin, MODKEY, Button3, resizemouse, {0} },

View File

@ -1,156 +0,0 @@
/* See LICENSE file for copyright and license details. */
/* appearance */
static const unsigned int borderpx = 1; /* border pixel of windows */
static const unsigned int snap = 32; /* snap pixel */
static const unsigned int gappih = 20; /* horiz inner gap between windows */
static const unsigned int gappiv = 10; /* vert inner gap between windows */
static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */
static const unsigned int gappov = 30; /* vert outer gap between windows and screen edge */
static int smartgaps = 0; /* 1 means no outer gap when there is only one window */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = { "monospace:size=10" };
static const char dmenufont[] = "monospace:size=10";
static const char col_gray1[] = "#222222";
static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb";
static const char col_gray4[] = "#eeeeee";
static const char col_cyan[] = "#005577";
static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
};
/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
static const Rule rules[] = {
/* xprop(1):
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
*/
/* class instance title tags mask isfloating isterminal noswallow monitor */
{ "Gimp", NULL, NULL, 0, 1, 0, 0, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1 },
{ "st", NULL, NULL, 0, 0, 1, 1, -1 },
};
/* layout(s) */
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
static const int attachdirection = 2; /* 0 default, 1 above, 2 aside, 3 below, 4 bottom, 5 top */
#define FORCE_VSPLIT 1 /* nrowgrid layout: force two clients to always split vertically */
#include "vanitygaps.c"
static const Layout layouts[] = {
/* symbol arrange function */
{ "[]=", tile }, /* first entry is default */
{ "[M]", monocle },
{ "[@]", spiral },
{ "[\\]", dwindle },
{ "H[]", deck },
{ "TTT", bstack },
{ "===", bstackhoriz },
{ "HHH", grid },
{ "###", nrowgrid },
{ "---", horizgrid },
{ ":::", gaplessgrid },
{ "|M|", centeredmaster },
{ ">M>", centeredfloatingmaster },
{ "><>", NULL }, /* no layout function means floating behavior */
{ NULL, NULL },
};
/* key definitions */
#define MODKEY Mod1Mask
#define TAGKEYS(KEY,TAG) \
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
{ MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
{ MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
/* commands */
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 };
static Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ 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_d, incnmaster, {.i = -1 } },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
{ MODKEY|ShiftMask, XK_h, setcfact, {.f = +0.25} },
{ MODKEY|ShiftMask, XK_l, setcfact, {.f = -0.25} },
{ MODKEY|ShiftMask, XK_o, setcfact, {.f = 0.00} },
{ MODKEY, XK_Return, zoom, {0} },
{ MODKEY|Mod4Mask, XK_u, incrgaps, {.i = +1 } },
{ MODKEY|Mod4Mask|ShiftMask, XK_u, incrgaps, {.i = -1 } },
{ MODKEY|Mod4Mask, XK_i, incrigaps, {.i = +1 } },
{ MODKEY|Mod4Mask|ShiftMask, XK_i, incrigaps, {.i = -1 } },
{ MODKEY|Mod4Mask, XK_o, incrogaps, {.i = +1 } },
{ MODKEY|Mod4Mask|ShiftMask, XK_o, incrogaps, {.i = -1 } },
{ MODKEY|Mod4Mask, XK_6, incrihgaps, {.i = +1 } },
{ MODKEY|Mod4Mask|ShiftMask, XK_6, incrihgaps, {.i = -1 } },
{ MODKEY|Mod4Mask, XK_7, incrivgaps, {.i = +1 } },
{ MODKEY|Mod4Mask|ShiftMask, XK_7, incrivgaps, {.i = -1 } },
{ MODKEY|Mod4Mask, XK_8, incrohgaps, {.i = +1 } },
{ MODKEY|Mod4Mask|ShiftMask, XK_8, incrohgaps, {.i = -1 } },
{ MODKEY|Mod4Mask, XK_9, incrovgaps, {.i = +1 } },
{ MODKEY|Mod4Mask|ShiftMask, XK_9, incrovgaps, {.i = -1 } },
{ MODKEY|Mod4Mask, XK_0, togglegaps, {0} },
{ MODKEY|Mod4Mask|ShiftMask, XK_0, defaultgaps, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~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 } },
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
TAGKEYS( XK_4, 3)
TAGKEYS( XK_5, 4)
TAGKEYS( XK_6, 5)
TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
{ MODKEY|ShiftMask, XK_q, quit, {0} },
};
/* button definitions */
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
static Button buttons[] = {
/* click event mask button function argument */
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
{ ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
{ ClkTagBar, 0, Button1, view, {0} },
{ ClkTagBar, 0, Button3, toggleview, {0} },
{ ClkTagBar, MODKEY, Button1, tag, {0} },
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
};

View File

@ -12,17 +12,34 @@ static const unsigned int gappov = 30; /* vert outer gap between window
static int smartgaps = 0; /* 1 means no outer gap when there is only one window */ static int smartgaps = 0; /* 1 means no outer gap when there is only one window */
static const int showbar = 1; /* 0 means no bar */ static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */ static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = { "monospace:size=10" }; //static const char *fonts[] = { "monospace:size=10"};
static const char *fonts[] = { "monospace:size=10", "Noto Emoji:pixelsize=12:antialias=true:autohint=true" };
static const char dmenufont[] = "monospace:size=10"; static const char dmenufont[] = "monospace:size=10";
static const char col_gray1[] = "#222222"; static const char col_gray1[] = "#222222";
static const char col_gray2[] = "#444444"; static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb"; static const char col_gray3[] = "#bbbbbb";
static const char col_gray4[] = "#eeeeee"; static const char col_gray4[] = "#eeeeee";
static const char col_cyan[] = "#005577"; static const char col_cyan[] = "#005577";
static const char col1[] = "#ffffff";
static const char col2[] = "#ffffff";
static const char col3[] = "#ffffff";
static const char col4[] = "#ffffff";
static const char col5[] = "#ffffff";
static const char col6[] = "#ffffff";
enum { SchemeNorm, SchemeCol1, SchemeCol2, SchemeCol3, SchemeCol4,
SchemeCol5, SchemeCol6, SchemeSel }; /* color schemes */
static const char *colors[][3] = { static const char *colors[][3] = {
/* fg bg border */ /* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_cyan, col_cyan }, [SchemeCol1] = { col1, col_gray1, col_gray2 },
[SchemeCol2] = { col2, col_gray1, col_gray2 },
[SchemeCol3] = { col3, col_gray1, col_gray2 },
[SchemeCol4] = { col4, col_gray1, col_gray2 },
[SchemeCol5] = { col5, col_gray1, col_gray2 },
[SchemeCol6] = { col6, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
}; };
/* tagging */ /* tagging */
@ -36,7 +53,7 @@ static const Rule rules[] = {
/* class instance title tags mask isfloating isterminal noswallow monitor */ /* class instance title tags mask isfloating isterminal noswallow monitor */
{ "Gimp", NULL, NULL, 0, 1, 0, 0, -1 }, { "Gimp", NULL, NULL, 0, 1, 0, 0, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1 }, { "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1 },
{ "st", NULL, NULL, 0, 0, 1, 1, -1 }, { "st", NULL, NULL, 0, 0, 1, 0, -1 },
}; };
/* layout(s) */ /* layout(s) */
@ -84,9 +101,11 @@ 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 };
static const char *upvol[] = { "pulsemixer" , "--change-volume", "+5", NULL }; /*
static const char *downvol[] = { "pulsemixer" , "--change-volume", "-5", NULL }; static const char *upvol[] = { "pulsemixer" , "--change-volume", "+1", NULL };
static const char *downvol[] = { "pulsemixer" , "--change-volume", "-1", NULL };
static const char *mutevol[] = { "pulsemixer" , "--toggle-mute", NULL }; static const char *mutevol[] = { "pulsemixer" , "--toggle-mute", NULL };
*/
static Key keys[] = { static Key keys[] = {
/* modifier key function argument */ /* modifier key function argument */
@ -144,14 +163,16 @@ static Key keys[] = {
{ MODKEY|ShiftMask, XK_q, quit, {0} }, { MODKEY|ShiftMask, XK_q, quit, {0} },
// https://gist.github.com/palopezv/efd34059af6126ad970940bcc6a90f2e // https://gist.github.com/palopezv/efd34059af6126ad970940bcc6a90f2e
// In my case, these XF86XK keys are FN+F2, FN+F4, FN+F3 respectively...
/* /*
{ MODKEY, XK_F2, spawn, {.v = downvol } },
{ MODKEY, XK_F4, spawn, {.v = mutevol } },
{ MODKEY, XK_F3, spawn, {.v = upvol } },
*/
{ 0, XF86XK_AudioLowerVolume, spawn, {.v = downvol } }, { 0, XF86XK_AudioLowerVolume, spawn, {.v = downvol } },
{ 0, XF86XK_AudioMute, spawn, {.v = mutevol } }, { 0, XF86XK_AudioMute, spawn, {.v = mutevol } },
{ 0, XF86XK_AudioRaiseVolume, spawn, {.v = upvol } }, { 0, XF86XK_AudioRaiseVolume, spawn, {.v = upvol } },
*/
{ 0, XF86XK_AudioLowerVolume, spawn, SHCMD("pulsemixer --change-volume -1; sigdwmblocks 2") },
{ 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("pulsemixer --change-volume +1; sigdwmblocks 2") },
{ 0, XF86XK_AudioMute, spawn, SHCMD("pulsemixer --toggle-mute; sigdwmblocks 2") },
{ MODKEY, XK_v, spawn, SHCMD("clipmenu") },
}; };
/* button definitions */ /* button definitions */
@ -161,7 +182,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, 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, Button1, movemouse, {0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} }, { ClkClientWin, MODKEY, Button2, togglefloating, {0} },
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} }, { ClkClientWin, MODKEY, Button3, resizemouse, {0} },

View File

@ -1,38 +0,0 @@
# dwm version
VERSION = 6.2
# Customize below to fit your system
# paths
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man
X11INC = /usr/X11R6/include
X11LIB = /usr/X11R6/lib
# Xinerama, comment if you don't want it
XINERAMALIBS = -lXinerama
XINERAMAFLAGS = -DXINERAMA
# freetype
FREETYPELIBS = -lfontconfig -lXft
FREETYPEINC = /usr/include/freetype2
# OpenBSD (uncomment)
#FREETYPEINC = ${X11INC}/freetype2
# includes and libs
INCS = -I${X11INC} -I${FREETYPEINC}
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res
# flags
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
LDFLAGS = ${LIBS}
# Solaris
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
#LDFLAGS = ${LIBS}
# compiler and linker
CC = cc

2
drw.c
View File

@ -140,11 +140,13 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
* https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916349 * https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916349
* and lots more all over the internet. * and lots more all over the internet.
*/ */
/*
FcBool iscol; FcBool iscol;
if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) { if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) {
XftFontClose(drw->dpy, xfont); XftFontClose(drw->dpy, xfont);
return NULL; return NULL;
} }
*/
font = ecalloc(1, sizeof(Fnt)); font = ecalloc(1, sizeof(Fnt));
font->xfont = xfont; font->xfont = xfont;

214
dwm.c
View File

@ -42,6 +42,7 @@
#include <X11/Xft/Xft.h> #include <X11/Xft/Xft.h>
#include <X11/Xlib-xcb.h> #include <X11/Xlib-xcb.h>
#include <xcb/res.h> #include <xcb/res.h>
#include <fcntl.h>
#include "drw.h" #include "drw.h"
#include "util.h" #include "util.h"
@ -59,10 +60,16 @@
#define HEIGHT(X) ((X)->h + 2 * (X)->bw) #define HEIGHT(X) ((X)->h + 2 * (X)->bw)
#define TAGMASK ((1 << LENGTH(tags)) - 1) #define TAGMASK ((1 << LENGTH(tags)) - 1)
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
#define TTEXTW(X) (drw_fontset_getwidth(drw, (X)))
#define STATUSLENGTH 256
#define DWMBLOCKSLOCKFILE "/var/local/dwmblocks/dwmblocks.pid"
#define DELIMITERENDCHAR 10
#define LSPAD (lrpad / 2) /* padding on left side of status text */
#define RSPAD (lrpad / 2) /* padding on right side of status text */
/* enums */ /* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { CurNormal, CurHand, CurResize, CurMove, CurLast }; /* cursor */
enum { SchemeNorm, SchemeSel }; /* color schemes */
enum { NetSupported, NetWMName, NetWMState, NetWMCheck, enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
@ -134,6 +141,7 @@ struct Monitor {
unsigned int tagset[2]; unsigned int tagset[2];
int showbar; int showbar;
int topbar; int topbar;
int statushandcursor;
Client *clients; Client *clients;
Client *sel; Client *sel;
Client *stack; Client *stack;
@ -226,6 +234,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 Client *swallowingclient(Window w); static Client *swallowingclient(Window w);
static void tag(const Arg *arg); static void tag(const Arg *arg);
@ -242,6 +251,7 @@ static void unmapnotify(XEvent *e);
static void updatebarpos(Monitor *m); static void updatebarpos(Monitor *m);
static void updatebars(void); static void updatebars(void);
static void updateclientlist(void); static void updateclientlist(void);
static void updatedwmblockssig(int x);
static int updategeom(void); static int updategeom(void);
static void updatenumlockmask(void); static void updatenumlockmask(void);
static void updatesizehints(Client *c); static void updatesizehints(Client *c);
@ -260,12 +270,15 @@ static void zoom(const Arg *arg);
/* variables */ /* variables */
static const char broken[] = "broken"; static const char broken[] = "broken";
static char stext[256]; static char stextc[STATUSLENGTH];
static char stexts[STATUSLENGTH];
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, ble; /* bar geometry */
static int wstext; /* width of status text */
static int lrpad; /* sum of left and right padding for text */ static int lrpad; /* sum of left and right padding for text */
static int (*xerrorxlib)(Display *, XErrorEvent *); static int (*xerrorxlib)(Display *, XErrorEvent *);
static unsigned int dwmblockssig;
static unsigned int numlockmask = 0; static unsigned int numlockmask = 0;
static void (*handler[LASTEvent]) (XEvent *) = { static void (*handler[LASTEvent]) (XEvent *) = {
[ButtonPress] = buttonpress, [ButtonPress] = buttonpress,
@ -553,13 +566,13 @@ unswallow(Client *c)
void void
buttonpress(XEvent *e) buttonpress(XEvent *e)
{ {
unsigned int i, x, click; int i, x;
unsigned int click;
Arg arg = {0}; Arg arg = {0};
Client *c; Client *c;
Monitor *m; Monitor *m;
XButtonPressedEvent *ev = &e->xbutton; XButtonPressedEvent *ev = &e->xbutton;
click = ClkRootWin;
/* focus monitor if necessary */ /* focus monitor if necessary */
if ((m = wintomon(ev->window)) && m != selmon) { if ((m = wintomon(ev->window)) && m != selmon) {
unfocus(selmon->sel, 1); unfocus(selmon->sel, 1);
@ -567,25 +580,29 @@ buttonpress(XEvent *e)
focus(NULL); focus(NULL);
} }
if (ev->window == selmon->barwin) { if (ev->window == selmon->barwin) {
i = x = 0; if (ev->x < ble - blw) {
do i = -1, x = -ev->x;
x += TEXTW(tags[i]); do
while (ev->x >= x && ++i < LENGTH(tags)); x += TEXTW(tags[++i]);
if (i < LENGTH(tags)) { while (x <= 0);
click = ClkTagBar; click = ClkTagBar;
arg.ui = 1 << i; arg.ui = 1 << i;
} else if (ev->x < x + blw) } else if (ev->x < ble)
click = ClkLtSymbol; click = ClkLtSymbol;
else if (ev->x > selmon->ww - (int)TEXTW(stext)) else if (ev->x < selmon->ww - wstext)
click = ClkStatusText; click = ClkWinTitle;
else else if ((x = selmon->ww - RSPAD - ev->x) > 0 && (x -= wstext - LSPAD - RSPAD) <= 0) {
click = ClkWinTitle; updatedwmblockssig(x);
click = ClkStatusText;
} else
return;
} else if ((c = wintoclient(ev->window))) { } else if ((c = wintoclient(ev->window))) {
focus(c); focus(c);
restack(selmon); restack(selmon);
XAllowEvents(dpy, ReplayPointer, CurrentTime); XAllowEvents(dpy, ReplayPointer, CurrentTime);
click = ClkClientWin; click = ClkClientWin;
} } else
click = ClkRootWin;
for (i = 0; i < LENGTH(buttons); i++) for (i = 0; i < LENGTH(buttons); i++)
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
&& CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
@ -838,7 +855,7 @@ dirtomon(int dir)
void void
drawbar(Monitor *m) drawbar(Monitor *m)
{ {
int x, w, tw = 0; int x, w;
int boxs = drw->fonts->h / 9; int boxs = drw->fonts->h / 9;
int boxw = drw->fonts->h / 6 + 2; int boxw = drw->fonts->h / 6 + 2;
unsigned int i, occ = 0, urg = 0; unsigned int i, occ = 0, urg = 0;
@ -846,9 +863,32 @@ drawbar(Monitor *m)
/* draw status first so it can be overdrawn by tags later */ /* draw status first so it can be overdrawn by tags later */
if (m == selmon) { /* status is only drawn on selected monitor */ if (m == selmon) { /* status is only drawn on selected monitor */
drw_setscheme(drw, scheme[SchemeNorm]); char *stc = stextc;
tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ char *stp = stextc;
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); char tmp;
drw_setscheme(drw, scheme[SchemeNorm]);
x = m->ww - wstext;
drw_rect(drw, x, 0, LSPAD, bh, 1, 1); x += LSPAD; /* to keep left padding clean */
for (;;) {
if ((unsigned char)*stc >= ' ') {
stc++;
continue;
}
tmp = *stc;
if (stp != stc) {
*stc = '\0';
x = drw_text(drw, x, 0, TTEXTW(stp), bh, 0, stp, 0);
}
if (tmp == '\0')
break;
if (tmp - DELIMITERENDCHAR - 1 < LENGTH(colors))
drw_setscheme(drw, scheme[tmp - DELIMITERENDCHAR - 1]);
*stc = tmp;
stp = ++stc;
}
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, x, 0, m->ww - x, bh, 1, 1); /* to keep right padding clean */
} }
for (c = m->clients; c; c = c->next) { for (c = m->clients; c; c = c->next) {
@ -867,11 +907,17 @@ drawbar(Monitor *m)
urg & 1 << i); urg & 1 << i);
x += w; x += w;
} }
w = blw = TEXTW(m->ltsymbol); w = TEXTW(m->ltsymbol);
drw_setscheme(drw, scheme[SchemeNorm]); drw_setscheme(drw, scheme[SchemeNorm]);
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
if ((w = m->ww - tw - x) > bh) { if (m == selmon) {
blw = w, ble = x;
w = m->ww - wstext - x;
} else
w = m->ww - x;
if (w > bh) {
if (m->sel) { if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
@ -1285,17 +1331,24 @@ void
motionnotify(XEvent *e) motionnotify(XEvent *e)
{ {
static Monitor *mon = NULL; static Monitor *mon = NULL;
int x;
Monitor *m; Monitor *m;
XMotionEvent *ev = &e->xmotion; XMotionEvent *ev = &e->xmotion;
if (ev->window != root) if (ev->window == root) {
return; if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) { unfocus(selmon->sel, 1);
unfocus(selmon->sel, 1); selmon = m;
selmon = m; focus(NULL);
focus(NULL); }
} mon = m;
mon = m; } else if (ev->window == selmon->barwin && (x = selmon->ww - RSPAD - ev->x) > 0
&& (x -= wstext - LSPAD - RSPAD) <= 0)
updatedwmblockssig(x);
else if (selmon->statushandcursor) {
selmon->statushandcursor = 0;
XDefineCursor(dpy, selmon->barwin, cursor[CurNormal]->cursor);
}
} }
void void
@ -1776,6 +1829,7 @@ setup(void)
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False); netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
/* init cursors */ /* init cursors */
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr); cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
cursor[CurHand] = drw_cur_create(drw, XC_hand2);
cursor[CurResize] = drw_cur_create(drw, XC_sizing); cursor[CurResize] = drw_cur_create(drw, XC_sizing);
cursor[CurMove] = drw_cur_create(drw, XC_fleur); cursor[CurMove] = drw_cur_create(drw, XC_fleur);
/* init appearance */ /* init appearance */
@ -1848,6 +1902,37 @@ sigchld(int unused)
while (0 < waitpid(-1, NULL, WNOHANG)); while (0 < waitpid(-1, NULL, WNOHANG));
} }
void
sigdwmblocks(const Arg *arg)
{
static int fd = -1;
struct flock fl;
union sigval sv;
if (!dwmblockssig)
return;
fl.l_type = F_WRLCK;
fl.l_whence = SEEK_SET;
fl.l_start = 0;
fl.l_len = 0;
if (fd != -1) {
if (fcntl(fd, F_GETLK, &fl) != -1 && fl.l_type == F_WRLCK)
goto signal;
close(fd);
fl.l_type = F_WRLCK;
}
if ((fd = open(DWMBLOCKSLOCKFILE, O_RDONLY | O_CLOEXEC)) == -1)
return;
if (fcntl(fd, F_GETLK, &fl) == -1 || fl.l_type != F_WRLCK) {
close(fd);
fd = -1;
return;
}
signal:
sv.sival_int = (dwmblockssig << 8) | arg->i;
sigqueue(fl.l_pid, SIGRTMIN, sv);
}
void void
spawn(const Arg *arg) spawn(const Arg *arg)
{ {
@ -2008,7 +2093,7 @@ updatebars(void)
XSetWindowAttributes wa = { XSetWindowAttributes wa = {
.override_redirect = True, .override_redirect = True,
.background_pixmap = ParentRelative, .background_pixmap = ParentRelative,
.event_mask = ButtonPressMask|ExposureMask .event_mask = ButtonPressMask|ExposureMask|PointerMotionMask
}; };
XClassHint ch = {"dwm", "dwm"}; XClassHint ch = {"dwm", "dwm"};
for (m = mons; m; m = m->next) { for (m = mons; m; m = m->next) {
@ -2050,6 +2135,41 @@ updateclientlist()
(unsigned char *) &(c->win), 1); (unsigned char *) &(c->win), 1);
} }
void
updatedwmblockssig(int x)
{
char *sts = stexts;
char *stp = stexts;
char tmp;
while (*sts != '\0') {
if ((unsigned char)*sts >= ' ') {
sts++;
continue;
}
tmp = *sts;
*sts = '\0';
x += TTEXTW(stp);
*sts = tmp;
if (x > 0) {
if (tmp == DELIMITERENDCHAR)
break;
if (!selmon->statushandcursor) {
selmon->statushandcursor = 1;
XDefineCursor(dpy, selmon->barwin, cursor[CurHand]->cursor);
}
dwmblockssig = tmp;
return;
}
stp = ++sts;
}
if (selmon->statushandcursor) {
selmon->statushandcursor = 0;
XDefineCursor(dpy, selmon->barwin, cursor[CurNormal]->cursor);
}
dwmblockssig = 0;
}
int int
updategeom(void) updategeom(void)
{ {
@ -2208,9 +2328,27 @@ updatesizehints(Client *c)
void void
updatestatus(void) updatestatus(void)
{ {
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) char rawstext[STATUSLENGTH];
strcpy(stext, "dwm-"VERSION);
drawbar(selmon); if (gettextprop(root, XA_WM_NAME, rawstext, sizeof rawstext)) {
char stextp[STATUSLENGTH];
char *stp = stextp, *stc = stextc, *sts = stexts;
for (char *rst = rawstext; *rst != '\0'; rst++)
if ((unsigned char)*rst >= ' ')
*(stp++) = *(stc++) = *(sts++) = *rst;
else if ((unsigned char)*rst > DELIMITERENDCHAR)
*(stc++) = *rst;
else
*(sts++) = *rst;
*stp = *stc = *sts = '\0';
wstext = TTEXTW(stextp) + LSPAD + RSPAD;
} else {
strcpy(stextc, "dwm-"VERSION);
strcpy(stexts, stextc);
wstext = TTEXTW(stextc) + LSPAD + RSPAD;
}
drawbar(selmon);
} }
void void

2451
dwm.c.orig

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,401 @@
diff -ruN dwm-6.2-ori/config.def.h dwm-6.2/config.def.h
--- dwm-6.2-ori/config.def.h 2019-02-02 18:25:28.000000000 +0530
+++ dwm-6.2/config.def.h 2020-12-27 19:45:35.127385861 +0530
@@ -12,10 +12,26 @@
static const char col_gray3[] = "#bbbbbb";
static const char col_gray4[] = "#eeeeee";
static const char col_cyan[] = "#005577";
+static const char col1[] = "#ffffff";
+static const char col2[] = "#ffffff";
+static const char col3[] = "#ffffff";
+static const char col4[] = "#ffffff";
+static const char col5[] = "#ffffff";
+static const char col6[] = "#ffffff";
+
+enum { SchemeNorm, SchemeCol1, SchemeCol2, SchemeCol3, SchemeCol4,
+ SchemeCol5, SchemeCol6, SchemeSel }; /* color schemes */
+
static const char *colors[][3] = {
/* fg bg border */
- [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
- [SchemeSel] = { col_gray4, col_cyan, col_cyan },
+ [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
+ [SchemeCol1] = { col1, col_gray1, col_gray2 },
+ [SchemeCol2] = { col2, col_gray1, col_gray2 },
+ [SchemeCol3] = { col3, col_gray1, col_gray2 },
+ [SchemeCol4] = { col4, col_gray1, col_gray2 },
+ [SchemeCol5] = { col5, col_gray1, col_gray2 },
+ [SchemeCol6] = { col6, col_gray1, col_gray2 },
+ [SchemeSel] = { col_gray4, col_cyan, col_cyan },
};
/* tagging */
@@ -103,7 +119,9 @@
{ 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 -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
--- dwm-6.2-ori/dwm.c 2019-02-02 18:25:28.000000000 +0530
+++ dwm-6.2/dwm.c 2021-08-03 19:15:58.734660076 +0530
@@ -40,6 +40,7 @@
#include <X11/extensions/Xinerama.h>
#endif /* XINERAMA */
#include <X11/Xft/Xft.h>
+#include <fcntl.h>
#include "drw.h"
#include "util.h"
@@ -56,10 +57,16 @@
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
#define TAGMASK ((1 << LENGTH(tags)) - 1)
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
+#define TTEXTW(X) (drw_fontset_getwidth(drw, (X)))
+
+#define STATUSLENGTH 256
+#define DWMBLOCKSLOCKFILE "/var/local/dwmblocks/dwmblocks.pid"
+#define DELIMITERENDCHAR 10
+#define LSPAD (lrpad / 2) /* padding on left side of status text */
+#define RSPAD (lrpad / 2) /* padding on right side of status text */
/* enums */
-enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
-enum { SchemeNorm, SchemeSel }; /* color schemes */
+enum { CurNormal, CurHand, CurResize, CurMove, CurLast }; /* cursor */
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
@@ -124,6 +131,7 @@
unsigned int tagset[2];
int showbar;
int topbar;
+ int statushandcursor;
Client *clients;
Client *sel;
Client *stack;
@@ -205,6 +213,7 @@
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);
@@ -219,6 +228,7 @@
static void updatebarpos(Monitor *m);
static void updatebars(void);
static void updateclientlist(void);
+static void updatedwmblockssig(int x);
static int updategeom(void);
static void updatenumlockmask(void);
static void updatesizehints(Client *c);
@@ -236,12 +246,15 @@
/* variables */
static const char broken[] = "broken";
-static char stext[256];
+static char stextc[STATUSLENGTH];
+static char stexts[STATUSLENGTH];
static int screen;
static int sw, sh; /* X display screen geometry width, height */
-static int bh, blw = 0; /* bar geometry */
+static int bh, blw, ble; /* bar geometry */
+static int wstext; /* width of status text */
static int lrpad; /* sum of left and right padding for text */
static int (*xerrorxlib)(Display *, XErrorEvent *);
+static unsigned int dwmblockssig;
static unsigned int numlockmask = 0;
static void (*handler[LASTEvent]) (XEvent *) = {
[ButtonPress] = buttonpress,
@@ -416,13 +429,13 @@
void
buttonpress(XEvent *e)
{
- unsigned int i, x, click;
+ int i, x;
+ unsigned int click;
Arg arg = {0};
Client *c;
Monitor *m;
XButtonPressedEvent *ev = &e->xbutton;
- click = ClkRootWin;
/* focus monitor if necessary */
if ((m = wintomon(ev->window)) && m != selmon) {
unfocus(selmon->sel, 1);
@@ -430,25 +443,29 @@
focus(NULL);
}
if (ev->window == selmon->barwin) {
- i = x = 0;
- do
- x += TEXTW(tags[i]);
- while (ev->x >= x && ++i < LENGTH(tags));
- if (i < LENGTH(tags)) {
- click = ClkTagBar;
- arg.ui = 1 << i;
- } else if (ev->x < x + blw)
- click = ClkLtSymbol;
- else if (ev->x > selmon->ww - TEXTW(stext))
- click = ClkStatusText;
- else
- click = ClkWinTitle;
+ if (ev->x < ble - blw) {
+ i = -1, x = -ev->x;
+ do
+ x += TEXTW(tags[++i]);
+ while (x <= 0);
+ click = ClkTagBar;
+ arg.ui = 1 << i;
+ } else if (ev->x < ble)
+ click = ClkLtSymbol;
+ else if (ev->x < selmon->ww - wstext)
+ click = ClkWinTitle;
+ else if ((x = selmon->ww - RSPAD - ev->x) > 0 && (x -= wstext - LSPAD - RSPAD) <= 0) {
+ updatedwmblockssig(x);
+ click = ClkStatusText;
+ } else
+ return;
} else if ((c = wintoclient(ev->window))) {
focus(c);
restack(selmon);
XAllowEvents(dpy, ReplayPointer, CurrentTime);
click = ClkClientWin;
- }
+ } else
+ click = ClkRootWin;
for (i = 0; i < LENGTH(buttons); i++)
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
&& CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
@@ -695,7 +712,7 @@
void
drawbar(Monitor *m)
{
- int x, w, sw = 0;
+ int x, w;
int boxs = drw->fonts->h / 9;
int boxw = drw->fonts->h / 6 + 2;
unsigned int i, occ = 0, urg = 0;
@@ -703,9 +720,32 @@
/* draw status first so it can be overdrawn by tags later */
if (m == selmon) { /* status is only drawn on selected monitor */
- drw_setscheme(drw, scheme[SchemeNorm]);
- sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
- drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0);
+ char *stc = stextc;
+ char *stp = stextc;
+ char tmp;
+
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ x = m->ww - wstext;
+ drw_rect(drw, x, 0, LSPAD, bh, 1, 1); x += LSPAD; /* to keep left padding clean */
+ for (;;) {
+ if ((unsigned char)*stc >= ' ') {
+ stc++;
+ continue;
+ }
+ tmp = *stc;
+ if (stp != stc) {
+ *stc = '\0';
+ x = drw_text(drw, x, 0, TTEXTW(stp), bh, 0, stp, 0);
+ }
+ if (tmp == '\0')
+ break;
+ if (tmp - DELIMITERENDCHAR - 1 < LENGTH(colors))
+ drw_setscheme(drw, scheme[tmp - DELIMITERENDCHAR - 1]);
+ *stc = tmp;
+ stp = ++stc;
+ }
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_rect(drw, x, 0, m->ww - x, bh, 1, 1); /* to keep right padding clean */
}
for (c = m->clients; c; c = c->next) {
@@ -724,11 +764,17 @@
urg & 1 << i);
x += w;
}
- w = blw = TEXTW(m->ltsymbol);
+ w = TEXTW(m->ltsymbol);
drw_setscheme(drw, scheme[SchemeNorm]);
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
- if ((w = m->ww - sw - x) > bh) {
+ if (m == selmon) {
+ blw = w, ble = x;
+ w = m->ww - wstext - x;
+ } else
+ w = m->ww - x;
+
+ if (w > bh) {
if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
@@ -1119,17 +1165,24 @@
motionnotify(XEvent *e)
{
static Monitor *mon = NULL;
+ int x;
Monitor *m;
XMotionEvent *ev = &e->xmotion;
- if (ev->window != root)
- return;
- if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
- unfocus(selmon->sel, 1);
- selmon = m;
- focus(NULL);
- }
- mon = m;
+ if (ev->window == root) {
+ if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
+ unfocus(selmon->sel, 1);
+ selmon = m;
+ focus(NULL);
+ }
+ mon = m;
+ } else if (ev->window == selmon->barwin && (x = selmon->ww - RSPAD - ev->x) > 0
+ && (x -= wstext - LSPAD - RSPAD) <= 0)
+ updatedwmblockssig(x);
+ else if (selmon->statushandcursor) {
+ selmon->statushandcursor = 0;
+ XDefineCursor(dpy, selmon->barwin, cursor[CurNormal]->cursor);
+ }
}
void
@@ -1564,6 +1617,7 @@
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
/* init cursors */
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
+ cursor[CurHand] = drw_cur_create(drw, XC_hand2);
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
/* init appearance */
@@ -1637,6 +1691,37 @@
}
void
+sigdwmblocks(const Arg *arg)
+{
+ static int fd = -1;
+ struct flock fl;
+ union sigval sv;
+
+ if (!dwmblockssig)
+ return;
+ fl.l_type = F_WRLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 0;
+ if (fd != -1) {
+ if (fcntl(fd, F_GETLK, &fl) != -1 && fl.l_type == F_WRLCK)
+ goto signal;
+ close(fd);
+ fl.l_type = F_WRLCK;
+ }
+ if ((fd = open(DWMBLOCKSLOCKFILE, O_RDONLY | O_CLOEXEC)) == -1)
+ return;
+ if (fcntl(fd, F_GETLK, &fl) == -1 || fl.l_type != F_WRLCK) {
+ close(fd);
+ fd = -1;
+ return;
+ }
+signal:
+ sv.sival_int = (dwmblockssig << 8) | arg->i;
+ sigqueue(fl.l_pid, SIGRTMIN, sv);
+}
+
+void
spawn(const Arg *arg)
{
if (arg->v == dmenucmd)
@@ -1805,7 +1890,7 @@
XSetWindowAttributes wa = {
.override_redirect = True,
.background_pixmap = ParentRelative,
- .event_mask = ButtonPressMask|ExposureMask
+ .event_mask = ButtonPressMask|ExposureMask|PointerMotionMask
};
XClassHint ch = {"dwm", "dwm"};
for (m = mons; m; m = m->next) {
@@ -1847,6 +1932,41 @@
(unsigned char *) &(c->win), 1);
}
+void
+updatedwmblockssig(int x)
+{
+ char *sts = stexts;
+ char *stp = stexts;
+ char tmp;
+
+ while (*sts != '\0') {
+ if ((unsigned char)*sts >= ' ') {
+ sts++;
+ continue;
+ }
+ tmp = *sts;
+ *sts = '\0';
+ x += TTEXTW(stp);
+ *sts = tmp;
+ if (x > 0) {
+ if (tmp == DELIMITERENDCHAR)
+ break;
+ if (!selmon->statushandcursor) {
+ selmon->statushandcursor = 1;
+ XDefineCursor(dpy, selmon->barwin, cursor[CurHand]->cursor);
+ }
+ dwmblockssig = tmp;
+ return;
+ }
+ stp = ++sts;
+ }
+ if (selmon->statushandcursor) {
+ selmon->statushandcursor = 0;
+ XDefineCursor(dpy, selmon->barwin, cursor[CurNormal]->cursor);
+ }
+ dwmblockssig = 0;
+}
+
int
updategeom(void)
{
@@ -1987,9 +2107,27 @@
void
updatestatus(void)
{
- if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
- strcpy(stext, "dwm-"VERSION);
- drawbar(selmon);
+ char rawstext[STATUSLENGTH];
+
+ if (gettextprop(root, XA_WM_NAME, rawstext, sizeof rawstext)) {
+ char stextp[STATUSLENGTH];
+ char *stp = stextp, *stc = stextc, *sts = stexts;
+
+ for (char *rst = rawstext; *rst != '\0'; rst++)
+ if ((unsigned char)*rst >= ' ')
+ *(stp++) = *(stc++) = *(sts++) = *rst;
+ else if ((unsigned char)*rst > DELIMITERENDCHAR)
+ *(stc++) = *rst;
+ else
+ *(sts++) = *rst;
+ *stp = *stc = *sts = '\0';
+ wstext = TTEXTW(stextp) + LSPAD + RSPAD;
+ } else {
+ strcpy(stextc, "dwm-"VERSION);
+ strcpy(stexts, stextc);
+ wstext = TTEXTW(stextc) + LSPAD + RSPAD;
+ }
+ drawbar(selmon);
}
void