Compare commits
10 Commits
d356591b13
...
b012bbb46b
Author | SHA1 | Date |
---|---|---|
meftimes | b012bbb46b | |
meftimes | e16d0b929b | |
meftimes | 21fb162c30 | |
meftimes | cd2b39b2cf | |
meftimes | 07caa91f0e | |
meftimes | e9209fa34f | |
meftimes | 2e4ef8e69a | |
meftimes | 66ce8e7a21 | |
meftimes | eecb0b8f46 | |
meftimes | 93bf920483 |
279
config.def.h
279
config.def.h
|
@ -1,47 +1,68 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
/* Constants */
|
||||
#define TERMINAL "st"
|
||||
#define TERMCLASS "St"
|
||||
#define BROWSER "librewolf"
|
||||
|
||||
/* appearance */
|
||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
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 },
|
||||
static unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static unsigned int snap = 32; /* snap pixel */
|
||||
static int showbar = 1; /* 0 means no bar */
|
||||
static int topbar = 1; /* 0 means bottom bar */
|
||||
static char font[] = "monospace:size=10";
|
||||
static char dmenufont[] = "monospace:size=10";
|
||||
static const char *fonts[] = { font };
|
||||
static char normbgcolor[] = "#000000";
|
||||
static char normbordercolor[] = "#000000";
|
||||
static char normfgcolor[] = "#BD93F9";
|
||||
static char selfgcolor[] = "#000000";
|
||||
static char selbordercolor[] = "#FF97C6";
|
||||
static char selbgcolor[] = "#BD93F9";
|
||||
static char *colors[][3] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
|
||||
[SchemeSel] = { selfgcolor, selbgcolor, selbordercolor },
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const void *cmd;
|
||||
} Sp;
|
||||
const char *spcmd1[] = {TERMINAL, "-n", "spterm", "-g", "120x34", NULL };
|
||||
const char *spcmd2[] = {TERMINAL, "-n", "spcalc", "-f", "monospace:size=16", "-g", "50x20", "-e", "bc", "-lq", NULL };
|
||||
static Sp scratchpads[] = {
|
||||
/* name cmd */
|
||||
{"spterm", spcmd1},
|
||||
{"spcalc", spcmd2},
|
||||
};
|
||||
|
||||
/* 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 monitor */
|
||||
{ "Gimp", NULL, NULL, 0, 1, -1 },
|
||||
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
||||
{ "FreeTube", NULL, NULL, 1 << 1, 0, -1 },
|
||||
{ "LibreWolf", NULL, NULL, 1 << 2, 0, -1 },
|
||||
{ "Beeper", NULL, NULL, 1 << 3, 0, -1 },
|
||||
{ NULL, "spterm", NULL, SPTAG(0), 1, -1 },
|
||||
{ NULL, "spcalc", NULL, SPTAG(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 float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
||||
static int nmaster = 1; /* number of clients in master area */
|
||||
static int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
||||
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||
|
||||
static const Layout layouts[] = {
|
||||
/* symbol arrange function */
|
||||
{ "[]=", tile }, /* first entry is default */
|
||||
{ "TTT", bstack },
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
};
|
||||
|
||||
/* key definitions */
|
||||
|
@ -55,47 +76,181 @@ static const Layout layouts[] = {
|
|||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
|
||||
#define STATUSBAR "dwmblocks"
|
||||
|
||||
/* 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 const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbordercolor, "-sf", selfgcolor, NULL };
|
||||
static const char *termcmd[] = { TERMINAL, NULL };
|
||||
|
||||
/*
|
||||
* Xresources preferences to load at startup
|
||||
*/
|
||||
ResourcePref resources[] = {
|
||||
{ "font", STRING, &font },
|
||||
{ "dmenufont", STRING, &dmenufont },
|
||||
{ "normbgcolor", STRING, &normbgcolor },
|
||||
{ "normbordercolor", STRING, &normbordercolor },
|
||||
{ "normfgcolor", STRING, &normfgcolor },
|
||||
{ "selbgcolor", STRING, &selbgcolor },
|
||||
{ "selbordercolor", STRING, &selbordercolor },
|
||||
{ "selfgcolor", STRING, &selfgcolor },
|
||||
{ "borderpx", INTEGER, &borderpx },
|
||||
{ "snap", INTEGER, &snap },
|
||||
{ "showbar", INTEGER, &showbar },
|
||||
{ "topbar", INTEGER, &topbar },
|
||||
{ "nmaster", INTEGER, &nmaster },
|
||||
{ "resizehints", INTEGER, &resizehints },
|
||||
{ "mfact", FLOAT, &mfact },
|
||||
};
|
||||
|
||||
static const 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, XK_Return, zoom, {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|ShiftMask, XK_f, togglefullscr, {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} },
|
||||
/* modifier key function argument */
|
||||
{ MODKEY, XK_grave, spawn, {.v = (const char*[]){ "dmenuunicode", NULL } } },
|
||||
// { MODKEY|ShiftMask, XK_grave, togglescratch, SHCMD("") },
|
||||
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, XK_0, view, {.ui = ~0 } },
|
||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||
// { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
||||
{ MODKEY, XK_minus, spawn, SHCMD("wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-; kill -44 $(pidof dwmblocks)") },
|
||||
{ MODKEY|ShiftMask, XK_minus, spawn, SHCMD("brightness -; pkill -RTMIN+27 dwmblocks") },
|
||||
// { MODKEY|ShiftMask, XK_minus, spawn, SHCMD("wpctl set-volume @DEFAULT_AUDIO_SINK@ 15%-; kill -44 $(pidof dwmblocks)") },
|
||||
{ MODKEY, XK_equal, spawn, SHCMD("wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+; kill -44 $(pidof dwmblocks)") },
|
||||
{ MODKEY|ShiftMask, XK_equal, spawn, SHCMD("brightness +; pkill -RTMIN+27 dwmblocks") },
|
||||
// { MODKEY|ShiftMask, XK_equal, spawn, SHCMD("wpctl set-volume @DEFAULT_AUDIO_SINK@ 15%+; kill -44 $(pidof dwmblocks)") },
|
||||
{ MODKEY, XK_BackSpace, spawn, {.v = (const char*[]){ "sysact", NULL } } },
|
||||
{ MODKEY|ShiftMask, XK_BackSpace, spawn, {.v = (const char*[]){ "sysact", NULL } } },
|
||||
|
||||
{ MODKEY, XK_Tab, view, {0} },
|
||||
// { MODKEY|ShiftMask, XK_Tab, spawn, SHCMD("") },
|
||||
{ MODKEY, XK_q, killclient, {0} },
|
||||
{ MODKEY|ShiftMask, XK_q, spawn, {.v = (const char*[]){ "sysact", NULL } } },
|
||||
{ MODKEY, XK_w, spawn, {.v = (const char*[]){ BROWSER, NULL } } },
|
||||
// { MODKEY|ShiftMask, XK_w, spawn, {.v = (const char*[]){ TERMINAL, "-e", "sudo", "nmtui", NULL } } },
|
||||
{ MODKEY, XK_e, spawn, SHCMD(TERMINAL " -e neomutt ; pkill -RTMIN+12 dwmblocks; rmdir ~/.abook") },
|
||||
// { MODKEY|ShiftMask, XK_e, spawn, SHCMD(TERMINAL " -e abook -C ~/.config/abook/abookrc --datafile ~/.config/abook/addressbook") },
|
||||
{ MODKEY, XK_r, spawn, {.v = (const char*[]){ TERMINAL, "-e", "lfub", NULL } } },
|
||||
// { MODKEY|ShiftMask, XK_r, spawn, {.v = (const char*[]){ TERMINAL, "-e", "htop", NULL } } },
|
||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, /* tile */
|
||||
{ MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[1]} }, /* bstack */
|
||||
// { MODKEY, XK_y, setlayout, {.v = &layouts[2]} }, /* spiral */
|
||||
// { MODKEY|ShiftMask, XK_y, setlayout, {.v = &layouts[3]} }, /* dwindle */
|
||||
// { MODKEY, XK_u, setlayout, {.v = &layouts[4]} }, /* deck */
|
||||
// { MODKEY|ShiftMask, XK_u, setlayout, {.v = &layouts[5]} }, /* monocle */
|
||||
// { MODKEY, XK_i, setlayout, {.v = &layouts[6]} }, /* centeredmaster */
|
||||
// { MODKEY|ShiftMask, XK_i, setlayout, {.v = &layouts[7]} }, /* centeredfloatingmaster */
|
||||
// { MODKEY, XK_o, incnmaster, {.i = +1 } },
|
||||
// { MODKEY|ShiftMask, XK_o, incnmaster, {.i = -1 } },
|
||||
{ MODKEY, XK_p, spawn, {.v = (const char*[]){ "mpc", "toggle", NULL } } },
|
||||
{ MODKEY|ShiftMask, XK_p, spawn, SHCMD("mpc stop; pauseallmpv") },
|
||||
{ MODKEY, XK_bracketleft, spawn, {.v = (const char*[]){ "mpc", "seek", "-10", NULL } } },
|
||||
{ MODKEY|ShiftMask, XK_bracketleft, spawn, {.v = (const char*[]){ "mpc", "seek", "-60", NULL } } },
|
||||
{ MODKEY, XK_bracketright, spawn, {.v = (const char*[]){ "mpc", "seek", "+10", NULL } } },
|
||||
{ MODKEY|ShiftMask, XK_bracketright, spawn, {.v = (const char*[]){ "mpc", "seek", "+60", NULL } } },
|
||||
{ MODKEY, XK_backslash, view, {0} },
|
||||
// { MODKEY|ShiftMask, XK_backslash, spawn, SHCMD("") },
|
||||
|
||||
// { MODKEY, XK_a, togglegaps, {0} },
|
||||
// { MODKEY|ShiftMask, XK_a, defaultgaps, {0} },
|
||||
// { MODKEY, XK_s, togglesticky, {0} },
|
||||
{ MODKEY|ShiftMask, XK_s, spawn, {.v = (const char*[]){ "passmenu-otp", NULL } } },
|
||||
{ MODKEY, XK_d, spawn, {.v = (const char*[]){ "dmenu_run", NULL } } },
|
||||
{ MODKEY|ShiftMask, XK_d, spawn, {.v = (const char*[]){ "passmenu", NULL } } },
|
||||
{ MODKEY, XK_f, togglefullscr, {0} },
|
||||
{ MODKEY|ShiftMask, XK_f, setlayout, {.v = &layouts[8]} },
|
||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
/* J and K are automatically bound above in STACKEYS */
|
||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||
{ MODKEY, XK_apostrophe, togglescratch, {.ui = 1} },
|
||||
// { MODKEY|ShiftMask, XK_apostrophe, spawn, SHCMD("") },
|
||||
// { MODKEY|ShiftMask, XK_apostrophe, togglesmartgaps, {0} },
|
||||
{ MODKEY, XK_Return, spawn, {.v = termcmd } },
|
||||
{ MODKEY|ShiftMask, XK_Return, togglescratch, {.ui = 0} },
|
||||
|
||||
// { MODKEY, XK_z, incrgaps, {.i = +3 } },
|
||||
// { MODKEY|ShiftMask, XK_z, spawn, SHCMD("") },
|
||||
// { MODKEY, XK_x, incrgaps, {.i = -3 } },
|
||||
// { MODKEY|ShiftMask, XK_x, spawn, SHCMD("") },
|
||||
// { MODKEY, XK_c, spawn, {.v = (const char*[]){ TERMINAL, "-e", "profanity", NULL } } },
|
||||
// { MODKEY|ShiftMask, XK_c, spawn, SHCMD("") },
|
||||
/* V is automatically bound above in STACKKEYS */
|
||||
// { MODKEY, XK_b, togglebar, {0} },
|
||||
// { MODKEY|ShiftMask, XK_b, spawn, SHCMD("") },
|
||||
{ MODKEY, XK_n, spawn, {.v = (const char*[]){ TERMINAL, "-e", "nvim", "-c", "VimwikiIndex", NULL } } },
|
||||
{ MODKEY|ShiftMask, XK_n, spawn, SHCMD(TERMINAL " -e newsboat ; pkill -RTMIN+6 dwmblocks") },
|
||||
{ MODKEY, XK_m, spawn, {.v = (const char*[]){ TERMINAL, "-e", "ncmpcpp", NULL } } },
|
||||
{ MODKEY|ShiftMask, XK_m, spawn, SHCMD("wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle; kill -44 $(pidof dwmblocks)") },
|
||||
{ MODKEY, XK_comma, spawn, {.v = (const char*[]){ "mpc", "prev", NULL } } },
|
||||
{ MODKEY|ShiftMask, XK_comma, spawn, {.v = (const char*[]){ "mpc", "seek", "0%", NULL } } },
|
||||
{ MODKEY, XK_period, spawn, {.v = (const char*[]){ "mpc", "next", NULL } } },
|
||||
{ MODKEY|ShiftMask, XK_period, spawn, {.v = (const char*[]){ "mpc", "repeat", NULL } } },
|
||||
|
||||
// { MODKEY, XK_Left, focusmon, {.i = -1 } },
|
||||
// { MODKEY|ShiftMask, XK_Left, tagmon, {.i = -1 } },
|
||||
// { MODKEY, XK_Right, focusmon, {.i = +1 } },
|
||||
// { MODKEY|ShiftMask, XK_Right, tagmon, {.i = +1 } },
|
||||
|
||||
{ MODKEY, XK_Insert, spawn, SHCMD("xdotool type $(grep -v '^#' ~/.local/share/larbs/snippets | dmenu -i -l 50 | cut -d' ' -f1)") },
|
||||
|
||||
// { MODKEY, XK_F1, spawn, SHCMD("groff -mom /usr/local/share/dwm/larbs.mom -Tpdf | zathura -") },
|
||||
// { MODKEY, XK_F2, spawn, {.v = (const char*[]){ "tutorialvids", NULL } } },
|
||||
{ MODKEY, XK_F3, spawn, {.v = (const char*[]){ "displayselect", NULL } } },
|
||||
{ MODKEY, XK_F4, spawn, SHCMD(TERMINAL " -e pulsemixer; kill -44 $(pidof dwmblocks)") },
|
||||
// { MODKEY, XK_F6, spawn, {.v = (const char*[]){ "torwrap", NULL } } },
|
||||
// { MODKEY, XK_F7, spawn, {.v = (const char*[]){ "td-toggle", NULL } } },
|
||||
// { MODKEY, XK_F8, spawn, {.v = (const char*[]){ "mw", "-Y", NULL } } },
|
||||
{ MODKEY, XK_F9, spawn, {.v = (const char*[]){ "mounter", NULL } } },
|
||||
{ MODKEY, XK_F10, spawn, {.v = (const char*[]){ "unmounter", NULL } } },
|
||||
{ MODKEY, XK_F11, spawn, SHCMD("mpv --untimed --no-cache --no-osc --no-input-default-bindings --profile=low-latency --input-conf=/dev/null --title=webcam $(ls /dev/video[0,2,4,6,8] | tail -n 1)") },
|
||||
{ MODKEY, XK_F12, spawn, SHCMD("remaps") },
|
||||
{ MODKEY, XK_space, zoom, {0} },
|
||||
// { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||
|
||||
{ 0, XK_Print, spawn, SHCMD("maim pic-full-$(date '+%y%m%d-%H%M-%S').png") },
|
||||
{ ShiftMask, XK_Print, spawn, {.v = (const char*[]){ "maimpick", NULL } } },
|
||||
{ MODKEY, XK_Print, spawn, {.v = (const char*[]){ "dmenurecord", NULL } } },
|
||||
{ MODKEY|ShiftMask, XK_Print, spawn, {.v = (const char*[]){ "dmenurecord", "kill", NULL } } },
|
||||
{ MODKEY, XK_Delete, spawn, {.v = (const char*[]){ "dmenurecord", "kill", NULL } } },
|
||||
{ MODKEY, XK_Scroll_Lock, spawn, SHCMD("killall screenkey || screenkey &") },
|
||||
|
||||
// { 0, XF86XK_AudioMute, spawn, SHCMD("wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle; kill -44 $(pidof dwmblocks)") },
|
||||
// { 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("wpctl set-volume @DEFAULT_AUDIO_SINK@ 3%+; kill -44 $(pidof dwmblocks)") },
|
||||
// { 0, XF86XK_AudioLowerVolume, spawn, SHCMD("wpctl set-volume @DEFAULT_AUDIO_SINK@ 3%-; kill -44 $(pidof dwmblocks)") },
|
||||
// { 0, XF86XK_AudioPrev, spawn, {.v = (const char*[]){ "mpc", "prev", NULL } } },
|
||||
// { 0, XF86XK_AudioNext, spawn, {.v = (const char*[]){ "mpc", "next", NULL } } },
|
||||
// { 0, XF86XK_AudioPause, spawn, {.v = (const char*[]){ "mpc", "pause", NULL } } },
|
||||
// { 0, XF86XK_AudioPlay, spawn, {.v = (const char*[]){ "mpc", "play", NULL } } },
|
||||
// { 0, XF86XK_AudioStop, spawn, {.v = (const char*[]){ "mpc", "stop", NULL } } },
|
||||
// { 0, XF86XK_AudioRewind, spawn, {.v = (const char*[]){ "mpc", "seek", "-10", NULL } } },
|
||||
// { 0, XF86XK_AudioForward, spawn, {.v = (const char*[]){ "mpc", "seek", "+10", NULL } } },
|
||||
// { 0, XF86XK_AudioMedia, spawn, {.v = (const char*[]){ TERMINAL, "-e", "ncmpcpp", NULL } } },
|
||||
// { 0, XF86XK_AudioMicMute, spawn, SHCMD("pactl set-source-mute @DEFAULT_SOURCE@ toggle") },
|
||||
// /* { 0, XF86XK_PowerOff, spawn, {.v = (const char*[]){ "sysact", NULL } } }, */
|
||||
// { 0, XF86XK_Calculator, spawn, {.v = (const char*[]){ TERMINAL, "-e", "bc", "-l", NULL } } },
|
||||
// { 0, XF86XK_Sleep, spawn, {.v = (const char*[]){ "sudo", "-A", "zzz", NULL } } },
|
||||
// { 0, XF86XK_WWW, spawn, {.v = (const char*[]){ BROWSER, NULL } } },
|
||||
// { 0, XF86XK_DOS, spawn, {.v = termcmd } },
|
||||
// { 0, XF86XK_ScreenSaver, spawn, SHCMD("slock & xset dpms force off; mpc pause; pauseallmpv") },
|
||||
// { 0, XF86XK_TaskPane, spawn, {.v = (const char*[]){ TERMINAL, "-e", "htop", NULL } } },
|
||||
// { 0, XF86XK_Mail, spawn, SHCMD(TERMINAL " -e neomutt ; pkill -RTMIN+12 dwmblocks") },
|
||||
// { 0, XF86XK_MyComputer, spawn, {.v = (const char*[]){ TERMINAL, "-e", "lfub", "/", NULL } } },
|
||||
// /* { 0, XF86XK_Battery, spawn, SHCMD("") }, */
|
||||
// { 0, XF86XK_Launch1, spawn, {.v = (const char*[]){ "xset", "dpms", "force", "off", NULL } } },
|
||||
// { 0, XF86XK_TouchpadToggle, spawn, SHCMD("(synclient | grep 'TouchpadOff.*1' && synclient TouchpadOff=0) || synclient TouchpadOff=1") },
|
||||
// { 0, XF86XK_TouchpadOff, spawn, {.v = (const char*[]){ "synclient", "TouchpadOff=1", NULL } } },
|
||||
// { 0, XF86XK_TouchpadOn, spawn, {.v = (const char*[]){ "synclient", "TouchpadOff=0", NULL } } },
|
||||
// { 0, XF86XK_MonBrightnessUp, spawn, {.v = (const char*[]){ "xbacklight", "-inc", "15", NULL } } },
|
||||
// { 0, XF86XK_MonBrightnessDown, spawn, {.v = (const char*[]){ "xbacklight", "-dec", "15", NULL } } },
|
||||
|
||||
};
|
||||
|
||||
/* button definitions */
|
||||
|
@ -105,10 +260,12 @@ static const 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, sigstatusbar, {.i = 1} },
|
||||
{ ClkStatusText, 0, Button2, sigstatusbar, {.i = 2} },
|
||||
{ ClkStatusText, 0, Button3, sigstatusbar, {.i = 3} },
|
||||
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
||||
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||||
{ ClkClientWin, MODKEY, Button1, resizemouse, {0} },
|
||||
{ ClkTagBar, 0, Button1, view, {0} },
|
||||
{ ClkTagBar, 0, Button3, toggleview, {0} },
|
||||
{ ClkTagBar, MODKEY, Button1, tag, {0} },
|
||||
|
|
2
drw.c
2
drw.c
|
@ -195,7 +195,7 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
|||
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
||||
* returned color scheme when done using it. */
|
||||
Clr *
|
||||
drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||
drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount)
|
||||
{
|
||||
size_t i;
|
||||
Clr *ret;
|
||||
|
|
2
drw.h
2
drw.h
|
@ -40,7 +40,7 @@ void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned in
|
|||
|
||||
/* Colorscheme abstraction */
|
||||
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
||||
Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
||||
Clr *drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount);
|
||||
|
||||
/* Cursor abstraction */
|
||||
Cur *drw_cur_create(Drw *drw, int shape);
|
||||
|
|
265
dwm.c
265
dwm.c
|
@ -36,6 +36,7 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xresource.h>
|
||||
#ifdef XINERAMA
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#endif /* XINERAMA */
|
||||
|
@ -54,7 +55,10 @@
|
|||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
||||
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
||||
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||
#define NUMTAGS (LENGTH(tags) + LENGTH(scratchpads))
|
||||
#define TAGMASK ((1 << NUMTAGS) - 1)
|
||||
#define SPTAG(i) ((1 << LENGTH(tags)) << (i))
|
||||
#define SPTAGMASK (((1 << LENGTH(scratchpads))-1) << LENGTH(tags))
|
||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||
|
||||
/* enums */
|
||||
|
@ -141,6 +145,19 @@ typedef struct {
|
|||
int monitor;
|
||||
} Rule;
|
||||
|
||||
/* Xresources preferences */
|
||||
enum resource_type {
|
||||
STRING = 0,
|
||||
INTEGER = 1,
|
||||
FLOAT = 2
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
enum resource_type type;
|
||||
void *dst;
|
||||
} ResourcePref;
|
||||
|
||||
/* function declarations */
|
||||
static void applyrules(Client *c);
|
||||
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
|
||||
|
@ -172,6 +189,7 @@ static void focusstack(const Arg *arg);
|
|||
static Atom getatomprop(Client *c, Atom prop);
|
||||
static int getrootptr(int *x, int *y);
|
||||
static long getstate(Window w);
|
||||
static pid_t getstatusbarpid();
|
||||
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
||||
static void grabbuttons(Client *c, int focused);
|
||||
static void grabkeys(void);
|
||||
|
@ -181,7 +199,6 @@ static void killclient(const Arg *arg);
|
|||
static void manage(Window w, XWindowAttributes *wa);
|
||||
static void mappingnotify(XEvent *e);
|
||||
static void maprequest(XEvent *e);
|
||||
static void monocle(Monitor *m);
|
||||
static void motionnotify(XEvent *e);
|
||||
static void movemouse(const Arg *arg);
|
||||
static Client *nexttiled(Client *c);
|
||||
|
@ -205,12 +222,14 @@ static void setmfact(const Arg *arg);
|
|||
static void setup(void);
|
||||
static void seturgent(Client *c, int urg);
|
||||
static void showhide(Client *c);
|
||||
static void sigstatusbar(const Arg *arg);
|
||||
static void spawn(const Arg *arg);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
static void tile(Monitor *m);
|
||||
static void togglebar(const Arg *arg);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void togglescratch(const Arg *arg);
|
||||
static void togglefullscr(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
static void toggleview(const Arg *arg);
|
||||
|
@ -234,10 +253,16 @@ static int xerror(Display *dpy, XErrorEvent *ee);
|
|||
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||
static void zoom(const Arg *arg);
|
||||
static void bstack(Monitor *m);
|
||||
static void load_xresources(void);
|
||||
static void resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst);
|
||||
|
||||
/* variables */
|
||||
static const char broken[] = "broken";
|
||||
static char stext[256];
|
||||
static int statusw;
|
||||
static int statussig;
|
||||
static pid_t statuspid = -1;
|
||||
static int screen;
|
||||
static int sw, sh; /* X display screen geometry width, height */
|
||||
static int bh; /* bar height */
|
||||
|
@ -300,6 +325,11 @@ applyrules(Client *c)
|
|||
{
|
||||
c->isfloating = r->isfloating;
|
||||
c->tags |= r->tags;
|
||||
if ((r->tags & SPTAGMASK) && r->isfloating) {
|
||||
c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
|
||||
c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
|
||||
}
|
||||
|
||||
for (m = mons; m && m->num != r->monitor; m = m->next);
|
||||
if (m)
|
||||
c->mon = m;
|
||||
|
@ -309,7 +339,7 @@ applyrules(Client *c)
|
|||
XFree(ch.res_class);
|
||||
if (ch.res_name)
|
||||
XFree(ch.res_name);
|
||||
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
|
||||
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : (c->mon->tagset[c->mon->seltags] & ~SPTAGMASK);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -424,6 +454,7 @@ buttonpress(XEvent *e)
|
|||
Client *c;
|
||||
Monitor *m;
|
||||
XButtonPressedEvent *ev = &e->xbutton;
|
||||
char *text, *s, ch;
|
||||
|
||||
click = ClkRootWin;
|
||||
/* focus monitor if necessary */
|
||||
|
@ -448,9 +479,23 @@ buttonpress(XEvent *e)
|
|||
arg.ui = 1 << i;
|
||||
} else if (ev->x < x + TEXTW(selmon->ltsymbol))
|
||||
click = ClkLtSymbol;
|
||||
else if (ev->x > selmon->ww - (int)TEXTW(stext))
|
||||
else if (ev->x > selmon->ww - statusw) {
|
||||
x = selmon->ww - statusw;
|
||||
click = ClkStatusText;
|
||||
else
|
||||
statussig = 0;
|
||||
for (text = s = stext; *s && x <= ev->x; s++) {
|
||||
if ((unsigned char)(*s) < ' ') {
|
||||
ch = *s;
|
||||
*s = '\0';
|
||||
x += TEXTW(text) - lrpad;
|
||||
*s = ch;
|
||||
text = s + 1;
|
||||
if (x >= ev->x)
|
||||
break;
|
||||
statussig = ch;
|
||||
}
|
||||
}
|
||||
} else
|
||||
click = ClkWinTitle;
|
||||
} else if ((c = wintoclient(ev->window))) {
|
||||
focus(c);
|
||||
|
@ -716,9 +761,24 @@ drawbar(Monitor *m)
|
|||
|
||||
/* draw status first so it can be overdrawn by tags later */
|
||||
if (m == selmon) { /* status is only drawn on selected monitor */
|
||||
char *text, *s, ch;
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
|
||||
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
|
||||
|
||||
x = 0;
|
||||
for (text = s = stext; *s; s++) {
|
||||
if ((unsigned char)(*s) < ' ') {
|
||||
ch = *s;
|
||||
*s = '\0';
|
||||
tw = TEXTW(text) - lrpad;
|
||||
drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0);
|
||||
x += tw;
|
||||
*s = ch;
|
||||
text = s + 1;
|
||||
}
|
||||
}
|
||||
tw = TEXTW(text) - lrpad + 2;
|
||||
drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0);
|
||||
tw = statusw;
|
||||
}
|
||||
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
|
@ -883,6 +943,30 @@ getatomprop(Client *c, Atom prop)
|
|||
return atom;
|
||||
}
|
||||
|
||||
pid_t
|
||||
getstatusbarpid()
|
||||
{
|
||||
char buf[32], *str = buf, *c;
|
||||
FILE *fp;
|
||||
|
||||
if (statuspid > 0) {
|
||||
snprintf(buf, sizeof(buf), "/proc/%u/cmdline", statuspid);
|
||||
if ((fp = fopen(buf, "r"))) {
|
||||
fgets(buf, sizeof(buf), fp);
|
||||
while ((c = strchr(str, '/')))
|
||||
str = c + 1;
|
||||
fclose(fp);
|
||||
if (!strcmp(str, STATUSBAR))
|
||||
return statuspid;
|
||||
}
|
||||
}
|
||||
if (!(fp = popen("pidof -s "STATUSBAR, "r")))
|
||||
return -1;
|
||||
fgets(buf, sizeof(buf), fp);
|
||||
pclose(fp);
|
||||
return strtol(buf, NULL, 10);
|
||||
}
|
||||
|
||||
int
|
||||
getrootptr(int *x, int *y)
|
||||
{
|
||||
|
@ -1116,21 +1200,6 @@ maprequest(XEvent *e)
|
|||
manage(ev->window, &wa);
|
||||
}
|
||||
|
||||
void
|
||||
monocle(Monitor *m)
|
||||
{
|
||||
unsigned int n = 0;
|
||||
Client *c;
|
||||
|
||||
for (c = m->clients; c; c = c->next)
|
||||
if (ISVISIBLE(c))
|
||||
n++;
|
||||
if (n > 0) /* override layout symbol */
|
||||
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
|
||||
for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
|
||||
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
|
||||
}
|
||||
|
||||
void
|
||||
motionnotify(XEvent *e)
|
||||
{
|
||||
|
@ -1638,6 +1707,10 @@ showhide(Client *c)
|
|||
if (!c)
|
||||
return;
|
||||
if (ISVISIBLE(c)) {
|
||||
if ((c->tags & SPTAGMASK) && c->isfloating) {
|
||||
c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
|
||||
c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
|
||||
}
|
||||
/* show clients top down */
|
||||
XMoveWindow(dpy, c->win, c->x, c->y);
|
||||
if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
|
||||
|
@ -1650,6 +1723,20 @@ showhide(Client *c)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
sigstatusbar(const Arg *arg)
|
||||
{
|
||||
union sigval sv;
|
||||
|
||||
if (!statussig)
|
||||
return;
|
||||
sv.sival_int = arg->i;
|
||||
if ((statuspid = getstatusbarpid()) <= 0)
|
||||
return;
|
||||
|
||||
sigqueue(statuspid, SIGRTMIN+statussig, sv);
|
||||
}
|
||||
|
||||
void
|
||||
spawn(const Arg *arg)
|
||||
{
|
||||
|
@ -1748,6 +1835,32 @@ togglefullscr(const Arg *arg)
|
|||
setfullscreen(selmon->sel, !selmon->sel->isfullscreen);
|
||||
}
|
||||
|
||||
void
|
||||
togglescratch(const Arg *arg)
|
||||
{
|
||||
Client *c;
|
||||
unsigned int found = 0;
|
||||
unsigned int scratchtag = SPTAG(arg->ui);
|
||||
Arg sparg = {.v = scratchpads[arg->ui].cmd};
|
||||
|
||||
for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next);
|
||||
if (found) {
|
||||
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
|
||||
if (newtagset) {
|
||||
selmon->tagset[selmon->seltags] = newtagset;
|
||||
focus(NULL);
|
||||
arrange(selmon);
|
||||
}
|
||||
if (ISVISIBLE(c)) {
|
||||
focus(c);
|
||||
restack(selmon);
|
||||
}
|
||||
} else {
|
||||
selmon->tagset[selmon->seltags] |= scratchtag;
|
||||
spawn(&sparg);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
toggletag(const Arg *arg)
|
||||
{
|
||||
|
@ -2018,8 +2131,25 @@ updatesizehints(Client *c)
|
|||
void
|
||||
updatestatus(void)
|
||||
{
|
||||
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
|
||||
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) {
|
||||
strcpy(stext, "dwm-"VERSION);
|
||||
statusw = TEXTW(stext) - lrpad + 2;
|
||||
} else {
|
||||
char *text, *s, ch;
|
||||
|
||||
statusw = 0;
|
||||
for (text = s = stext; *s; s++) {
|
||||
if ((unsigned char)(*s) < ' ') {
|
||||
ch = *s;
|
||||
*s = '\0';
|
||||
statusw += TEXTW(text) - lrpad;
|
||||
*s = ch;
|
||||
text = s + 1;
|
||||
}
|
||||
}
|
||||
statusw += TEXTW(text) - lrpad + 2;
|
||||
|
||||
}
|
||||
drawbar(selmon);
|
||||
}
|
||||
|
||||
|
@ -2153,6 +2283,60 @@ zoom(const Arg *arg)
|
|||
pop(c);
|
||||
}
|
||||
|
||||
void
|
||||
resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst)
|
||||
{
|
||||
char *sdst = NULL;
|
||||
int *idst = NULL;
|
||||
float *fdst = NULL;
|
||||
|
||||
sdst = dst;
|
||||
idst = dst;
|
||||
fdst = dst;
|
||||
|
||||
char fullname[256];
|
||||
char *type;
|
||||
XrmValue ret;
|
||||
|
||||
snprintf(fullname, sizeof(fullname), "%s.%s", "dwm", name);
|
||||
fullname[sizeof(fullname) - 1] = '\0';
|
||||
|
||||
XrmGetResource(db, fullname, "*", &type, &ret);
|
||||
if (!(ret.addr == NULL || strncmp("String", type, 64)))
|
||||
{
|
||||
switch (rtype) {
|
||||
case STRING:
|
||||
strcpy(sdst, ret.addr);
|
||||
break;
|
||||
case INTEGER:
|
||||
*idst = strtoul(ret.addr, NULL, 10);
|
||||
break;
|
||||
case FLOAT:
|
||||
*fdst = strtof(ret.addr, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
load_xresources(void)
|
||||
{
|
||||
Display *display;
|
||||
char *resm;
|
||||
XrmDatabase db;
|
||||
ResourcePref *p;
|
||||
|
||||
display = XOpenDisplay(NULL);
|
||||
resm = XResourceManagerString(display);
|
||||
if (!resm)
|
||||
return;
|
||||
|
||||
db = XrmGetStringDatabase(resm);
|
||||
for (p = resources; p < resources + LENGTH(resources); p++)
|
||||
resource_load(db, p->name, p->type, p->dst);
|
||||
XCloseDisplay(display);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -2165,6 +2349,8 @@ main(int argc, char *argv[])
|
|||
if (!(dpy = XOpenDisplay(NULL)))
|
||||
die("dwm: cannot open display");
|
||||
checkotherwm();
|
||||
XrmInitialize();
|
||||
load_xresources();
|
||||
setup();
|
||||
#ifdef __OpenBSD__
|
||||
if (pledge("stdio rpath proc exec", NULL) == -1)
|
||||
|
@ -2176,3 +2362,36 @@ main(int argc, char *argv[])
|
|||
XCloseDisplay(dpy);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
bstack(Monitor *m) {
|
||||
int w, h, mh, mx, tx, ty, tw;
|
||||
unsigned int i, n;
|
||||
Client *c;
|
||||
|
||||
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||
if (n == 0)
|
||||
return;
|
||||
if (n > m->nmaster) {
|
||||
mh = m->nmaster ? m->mfact * m->wh : 0;
|
||||
tw = m->ww / (n - m->nmaster);
|
||||
ty = m->wy + mh;
|
||||
} else {
|
||||
mh = m->wh;
|
||||
tw = m->ww;
|
||||
ty = m->wy;
|
||||
}
|
||||
for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
||||
if (i < m->nmaster) {
|
||||
w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
|
||||
resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
|
||||
mx += WIDTH(c);
|
||||
} else {
|
||||
h = m->wh - mh;
|
||||
resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), 0);
|
||||
if (tw != m->ww)
|
||||
tx += WIDTH(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
diff --git a/config.def.h b/config.def.h
|
||||
index 7054c06..554f1db 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -39,6 +39,8 @@ static const Layout layouts[] = {
|
||||
{ "[]=", tile }, /* first entry is default */
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
+ { "TTT", bstack },
|
||||
+ { "===", bstackhoriz },
|
||||
};
|
||||
|
||||
/* key definitions */
|
||||
@@ -74,6 +76,8 @@ static Key keys[] = {
|
||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||
+ { MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
|
||||
+ { MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
|
||||
{ MODKEY, XK_space, setlayout, {0} },
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 0362114..c313b5e 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -233,6 +233,8 @@ static int xerror(Display *dpy, XErrorEvent *ee);
|
||||
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||
static void zoom(const Arg *arg);
|
||||
+static void bstack(Monitor *m);
|
||||
+static void bstackhoriz(Monitor *m);
|
||||
|
||||
/* variables */
|
||||
static const char broken[] = "broken";
|
||||
@@ -2139,3 +2141,65 @@ main(int argc, char *argv[])
|
||||
XCloseDisplay(dpy);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+
|
||||
+static void
|
||||
+bstack(Monitor *m) {
|
||||
+ int w, h, mh, mx, tx, ty, tw;
|
||||
+ unsigned int i, n;
|
||||
+ Client *c;
|
||||
+
|
||||
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||
+ if (n == 0)
|
||||
+ return;
|
||||
+ if (n > m->nmaster) {
|
||||
+ mh = m->nmaster ? m->mfact * m->wh : 0;
|
||||
+ tw = m->ww / (n - m->nmaster);
|
||||
+ ty = m->wy + mh;
|
||||
+ } else {
|
||||
+ mh = m->wh;
|
||||
+ tw = m->ww;
|
||||
+ ty = m->wy;
|
||||
+ }
|
||||
+ for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
||||
+ if (i < m->nmaster) {
|
||||
+ w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
|
||||
+ resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
|
||||
+ mx += WIDTH(c);
|
||||
+ } else {
|
||||
+ h = m->wh - mh;
|
||||
+ resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), 0);
|
||||
+ if (tw != m->ww)
|
||||
+ tx += WIDTH(c);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+bstackhoriz(Monitor *m) {
|
||||
+ int w, mh, mx, tx, ty, th;
|
||||
+ unsigned int i, n;
|
||||
+ Client *c;
|
||||
+
|
||||
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||
+ if (n == 0)
|
||||
+ return;
|
||||
+ if (n > m->nmaster) {
|
||||
+ mh = m->nmaster ? m->mfact * m->wh : 0;
|
||||
+ th = (m->wh - mh) / (n - m->nmaster);
|
||||
+ ty = m->wy + mh;
|
||||
+ } else {
|
||||
+ th = mh = m->wh;
|
||||
+ ty = m->wy;
|
||||
+ }
|
||||
+ for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
||||
+ if (i < m->nmaster) {
|
||||
+ w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
|
||||
+ resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
|
||||
+ mx += WIDTH(c);
|
||||
+ } else {
|
||||
+ resize(c, tx, ty, m->ww - (2 * c->bw), th - (2 * c->bw), 0);
|
||||
+ if (th != m->wh)
|
||||
+ ty += HEIGHT(c);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
|
@ -0,0 +1,199 @@
|
|||
From 728d397b21982af88737277fd9d6939a7b558786 Mon Sep 17 00:00:00 2001
|
||||
From: Christian Tenllado <ctenllado@gmail.com>
|
||||
Date: Tue, 14 Apr 2020 23:31:15 +0200
|
||||
Subject: [PATCH] Multiple scratchpads
|
||||
|
||||
This patch enables multiple scratchpads, each with one asigned window.
|
||||
This enables the same scratchpad workflow that you have in i3.
|
||||
|
||||
Scratchpads are implemented as special tags, whose mask does not
|
||||
apply to new spawned windows. To assign a window to a scratchpad you
|
||||
have to set up a rule, as you do with regular tags.
|
||||
|
||||
Windows tagged with scratchpad tags can be set floating or not in the
|
||||
rules array. Most users would probably want them floating (i3 style),
|
||||
but having them tiled does also perfectly work and might fit better the
|
||||
DWM approach. In case they are set floating, the patch moves them to the
|
||||
center of the screen whenever they are shown. The patch can easily be
|
||||
modified to make this last feature configurable in the rules array (see
|
||||
the center patch).
|
||||
|
||||
The togglescratch function, borrowed from the previous scratchpad patch
|
||||
and slightly modified, can be used to spawn a registered scratchpad
|
||||
process or toggle its view. This function looks for a window tagged with
|
||||
the selected scratchpad tag. If it is found its view is toggled. If it is
|
||||
not found the corresponding registered command is spawned. The
|
||||
config.def.h shows three examples of its use to spawn a terminal in the
|
||||
first scratchpad tag, a second terminal running ranger on the second
|
||||
scratchpad tag and the keepassxc application to manage passwords on a
|
||||
third scratchpad tag.
|
||||
|
||||
If you prefer to spawn your scratchpad applications from the startup
|
||||
script, you might opt for binding keys to toggleview instead, as
|
||||
scratchpads are just special tags (you may even extend the TAGKEYS macro
|
||||
to generalize the key bindings).
|
||||
---
|
||||
config.def.h | 28 ++++++++++++++++++++++++----
|
||||
dwm.c | 43 +++++++++++++++++++++++++++++++++++++++++--
|
||||
2 files changed, 65 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1c0b587..06265e1 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -18,17 +18,33 @@ static const char *colors[][3] = {
|
||||
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||
};
|
||||
|
||||
+typedef struct {
|
||||
+ const char *name;
|
||||
+ const void *cmd;
|
||||
+} Sp;
|
||||
+const char *spcmd1[] = {"st", "-n", "spterm", "-g", "120x34", NULL };
|
||||
+const char *spcmd2[] = {"st", "-n", "spfm", "-g", "144x41", "-e", "ranger", NULL };
|
||||
+const char *spcmd3[] = {"keepassxc", NULL };
|
||||
+static Sp scratchpads[] = {
|
||||
+ /* name cmd */
|
||||
+ {"spterm", spcmd1},
|
||||
+ {"spranger", spcmd2},
|
||||
+ {"keepassxc", spcmd3},
|
||||
+};
|
||||
+
|
||||
/* 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 monitor */
|
||||
- { "Gimp", NULL, NULL, 0, 1, -1 },
|
||||
- { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
||||
+ { "Gimp", NULL, NULL, 0, 1, -1 },
|
||||
+ { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
||||
+ { NULL, "spterm", NULL, SPTAG(0), 1, -1 },
|
||||
+ { NULL, "spfm", NULL, SPTAG(1), 1, -1 },
|
||||
+ { NULL, "keepassxc", NULL, SPTAG(2), 0, -1 },
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
@@ -59,6 +75,7 @@ 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 } },
|
||||
@@ -84,6 +101,9 @@ static Key keys[] = {
|
||||
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
||||
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||
+ { MODKEY, XK_y, togglescratch, {.ui = 0 } },
|
||||
+ { MODKEY, XK_u, togglescratch, {.ui = 1 } },
|
||||
+ { MODKEY, XK_x, togglescratch, {.ui = 2 } },
|
||||
TAGKEYS( XK_1, 0)
|
||||
TAGKEYS( XK_2, 1)
|
||||
TAGKEYS( XK_3, 2)
|
||||
@@ -106,7 +126,7 @@ static Button buttons[] = {
|
||||
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
||||
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
||||
- { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||||
+ { ClkClientWin, MODKEY, Button1, resizemouse, {0} },
|
||||
{ ClkTagBar, 0, Button1, view, {0} },
|
||||
{ ClkTagBar, 0, Button3, toggleview, {0} },
|
||||
{ ClkTagBar, MODKEY, Button1, tag, {0} },
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 4465af1..646aa1a 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -54,7 +54,10 @@
|
||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
||||
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
||||
-#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||
+#define NUMTAGS (LENGTH(tags) + LENGTH(scratchpads))
|
||||
+#define TAGMASK ((1 << NUMTAGS) - 1)
|
||||
+#define SPTAG(i) ((1 << LENGTH(tags)) << (i))
|
||||
+#define SPTAGMASK (((1 << LENGTH(scratchpads))-1) << LENGTH(tags))
|
||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||
|
||||
/* enums */
|
||||
@@ -211,6 +214,7 @@ static void tagmon(const Arg *arg);
|
||||
static void tile(Monitor *);
|
||||
static void togglebar(const Arg *arg);
|
||||
static void togglefloating(const Arg *arg);
|
||||
+static void togglescratch(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
static void toggleview(const Arg *arg);
|
||||
static void unfocus(Client *c, int setfocus);
|
||||
@@ -299,6 +303,11 @@ applyrules(Client *c)
|
||||
{
|
||||
c->isfloating = r->isfloating;
|
||||
c->tags |= r->tags;
|
||||
+ if ((r->tags & SPTAGMASK) && r->isfloating) {
|
||||
+ c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
|
||||
+ c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
|
||||
+ }
|
||||
+
|
||||
for (m = mons; m && m->num != r->monitor; m = m->next);
|
||||
if (m)
|
||||
c->mon = m;
|
||||
@@ -308,7 +317,7 @@ applyrules(Client *c)
|
||||
XFree(ch.res_class);
|
||||
if (ch.res_name)
|
||||
XFree(ch.res_name);
|
||||
- c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
|
||||
+ c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : (c->mon->tagset[c->mon->seltags] & ~SPTAGMASK);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -1616,6 +1625,10 @@ showhide(Client *c)
|
||||
if (!c)
|
||||
return;
|
||||
if (ISVISIBLE(c)) {
|
||||
+ if ((c->tags & SPTAGMASK) && c->isfloating) {
|
||||
+ c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
|
||||
+ c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
|
||||
+ }
|
||||
/* show clients top down */
|
||||
XMoveWindow(dpy, c->win, c->x, c->y);
|
||||
if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
|
||||
@@ -1719,6 +1732,32 @@ togglefloating(const Arg *arg)
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
+void
|
||||
+togglescratch(const Arg *arg)
|
||||
+{
|
||||
+ Client *c;
|
||||
+ unsigned int found = 0;
|
||||
+ unsigned int scratchtag = SPTAG(arg->ui);
|
||||
+ Arg sparg = {.v = scratchpads[arg->ui].cmd};
|
||||
+
|
||||
+ for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next);
|
||||
+ if (found) {
|
||||
+ unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
|
||||
+ if (newtagset) {
|
||||
+ selmon->tagset[selmon->seltags] = newtagset;
|
||||
+ focus(NULL);
|
||||
+ arrange(selmon);
|
||||
+ }
|
||||
+ if (ISVISIBLE(c)) {
|
||||
+ focus(c);
|
||||
+ restack(selmon);
|
||||
+ }
|
||||
+ } else {
|
||||
+ selmon->tagset[selmon->seltags] |= scratchtag;
|
||||
+ spawn(&sparg);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
toggletag(const Arg *arg)
|
||||
{
|
||||
--
|
||||
2.20.1
|
||||
|
|
@ -0,0 +1,208 @@
|
|||
From f58c7e4fd05ec13383518ccd51663167d45e92d0 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Bylinka <daniel.bylinka@gmail.com>
|
||||
Date: Fri, 2 Apr 2021 19:02:58 +0200
|
||||
Subject: [PATCH] [statuscmd] Signal mouse button and click location to status
|
||||
monitor
|
||||
|
||||
---
|
||||
config.def.h | 6 +++-
|
||||
dwm.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++---
|
||||
2 files changed, 100 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1c0b587..154a59b 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -54,6 +54,8 @@ static const Layout layouts[] = {
|
||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
|
||||
+#define STATUSBAR "dwmblocks"
|
||||
+
|
||||
/* 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 };
|
||||
@@ -103,7 +105,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, sigstatusbar, {.i = 1} },
|
||||
+ { ClkStatusText, 0, Button2, sigstatusbar, {.i = 2} },
|
||||
+ { ClkStatusText, 0, Button3, sigstatusbar, {.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 b0b3466..d871457 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -172,6 +172,7 @@ static void focusstack(const Arg *arg);
|
||||
static Atom getatomprop(Client *c, Atom prop);
|
||||
static int getrootptr(int *x, int *y);
|
||||
static long getstate(Window w);
|
||||
+static pid_t getstatusbarpid();
|
||||
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
||||
static void grabbuttons(Client *c, int focused);
|
||||
static void grabkeys(void);
|
||||
@@ -206,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 sigstatusbar(const Arg *arg);
|
||||
static void spawn(const Arg *arg);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
@@ -238,6 +240,9 @@ static void zoom(const Arg *arg);
|
||||
/* variables */
|
||||
static const char broken[] = "broken";
|
||||
static char stext[256];
|
||||
+static int statusw;
|
||||
+static int statussig;
|
||||
+static pid_t statuspid = -1;
|
||||
static int screen;
|
||||
static int sw, sh; /* X display screen geometry width, height */
|
||||
static int bh, blw = 0; /* bar geometry */
|
||||
@@ -422,6 +427,7 @@ buttonpress(XEvent *e)
|
||||
Client *c;
|
||||
Monitor *m;
|
||||
XButtonPressedEvent *ev = &e->xbutton;
|
||||
+ char *text, *s, ch;
|
||||
|
||||
click = ClkRootWin;
|
||||
/* focus monitor if necessary */
|
||||
@@ -440,9 +446,23 @@ 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 > selmon->ww - statusw) {
|
||||
+ x = selmon->ww - statusw;
|
||||
click = ClkStatusText;
|
||||
- else
|
||||
+ statussig = 0;
|
||||
+ for (text = s = stext; *s && x <= ev->x; s++) {
|
||||
+ if ((unsigned char)(*s) < ' ') {
|
||||
+ ch = *s;
|
||||
+ *s = '\0';
|
||||
+ x += TEXTW(text) - lrpad;
|
||||
+ *s = ch;
|
||||
+ text = s + 1;
|
||||
+ if (x >= ev->x)
|
||||
+ break;
|
||||
+ statussig = ch;
|
||||
+ }
|
||||
+ }
|
||||
+ } else
|
||||
click = ClkWinTitle;
|
||||
} else if ((c = wintoclient(ev->window))) {
|
||||
focus(c);
|
||||
@@ -704,9 +724,24 @@ drawbar(Monitor *m)
|
||||
|
||||
/* draw status first so it can be overdrawn by tags later */
|
||||
if (m == selmon) { /* status is only drawn on selected monitor */
|
||||
+ char *text, *s, ch;
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
- tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
|
||||
- drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
|
||||
+
|
||||
+ x = 0;
|
||||
+ for (text = s = stext; *s; s++) {
|
||||
+ if ((unsigned char)(*s) < ' ') {
|
||||
+ ch = *s;
|
||||
+ *s = '\0';
|
||||
+ tw = TEXTW(text) - lrpad;
|
||||
+ drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0);
|
||||
+ x += tw;
|
||||
+ *s = ch;
|
||||
+ text = s + 1;
|
||||
+ }
|
||||
+ }
|
||||
+ tw = TEXTW(text) - lrpad + 2;
|
||||
+ drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0);
|
||||
+ tw = statusw;
|
||||
}
|
||||
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
@@ -872,6 +907,30 @@ getatomprop(Client *c, Atom prop)
|
||||
return atom;
|
||||
}
|
||||
|
||||
+pid_t
|
||||
+getstatusbarpid()
|
||||
+{
|
||||
+ char buf[32], *str = buf, *c;
|
||||
+ FILE *fp;
|
||||
+
|
||||
+ if (statuspid > 0) {
|
||||
+ snprintf(buf, sizeof(buf), "/proc/%u/cmdline", statuspid);
|
||||
+ if ((fp = fopen(buf, "r"))) {
|
||||
+ fgets(buf, sizeof(buf), fp);
|
||||
+ while ((c = strchr(str, '/')))
|
||||
+ str = c + 1;
|
||||
+ fclose(fp);
|
||||
+ if (!strcmp(str, STATUSBAR))
|
||||
+ return statuspid;
|
||||
+ }
|
||||
+ }
|
||||
+ if (!(fp = popen("pidof -s "STATUSBAR, "r")))
|
||||
+ return -1;
|
||||
+ fgets(buf, sizeof(buf), fp);
|
||||
+ pclose(fp);
|
||||
+ return strtol(buf, NULL, 10);
|
||||
+}
|
||||
+
|
||||
int
|
||||
getrootptr(int *x, int *y)
|
||||
{
|
||||
@@ -1637,6 +1696,20 @@ sigchld(int unused)
|
||||
while (0 < waitpid(-1, NULL, WNOHANG));
|
||||
}
|
||||
|
||||
+void
|
||||
+sigstatusbar(const Arg *arg)
|
||||
+{
|
||||
+ union sigval sv;
|
||||
+
|
||||
+ if (!statussig)
|
||||
+ return;
|
||||
+ sv.sival_int = arg->i;
|
||||
+ if ((statuspid = getstatusbarpid()) <= 0)
|
||||
+ return;
|
||||
+
|
||||
+ sigqueue(statuspid, SIGRTMIN+statussig, sv);
|
||||
+}
|
||||
+
|
||||
void
|
||||
spawn(const Arg *arg)
|
||||
{
|
||||
@@ -1990,8 +2063,25 @@ updatesizehints(Client *c)
|
||||
void
|
||||
updatestatus(void)
|
||||
{
|
||||
- if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
|
||||
+ if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) {
|
||||
strcpy(stext, "dwm-"VERSION);
|
||||
+ statusw = TEXTW(stext) - lrpad + 2;
|
||||
+ } else {
|
||||
+ char *text, *s, ch;
|
||||
+
|
||||
+ statusw = 0;
|
||||
+ for (text = s = stext; *s; s++) {
|
||||
+ if ((unsigned char)(*s) < ' ') {
|
||||
+ ch = *s;
|
||||
+ *s = '\0';
|
||||
+ statusw += TEXTW(text) - lrpad;
|
||||
+ *s = ch;
|
||||
+ text = s + 1;
|
||||
+ }
|
||||
+ }
|
||||
+ statusw += TEXTW(text) - lrpad + 2;
|
||||
+
|
||||
+ }
|
||||
drawbar(selmon);
|
||||
}
|
||||
|
||||
--
|
||||
2.31.0
|
||||
|
|
@ -0,0 +1,240 @@
|
|||
From f30583c6e2ab5e7de6ef4ebf156076ac0f6e69fc Mon Sep 17 00:00:00 2001
|
||||
From: Jack Bird <jack.bird@durham.ac.uk>
|
||||
Date: Fri, 27 Aug 2021 00:53:14 +0100
|
||||
Subject: [PATCH] xresources updated for 138b405
|
||||
|
||||
---
|
||||
config.def.h | 61 ++++++++++++++++++++++++++++++--------------
|
||||
drw.c | 2 +-
|
||||
drw.h | 2 +-
|
||||
dwm.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
4 files changed, 116 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a2ac963..87ac198 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -1,21 +1,23 @@
|
||||
/* 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 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 },
|
||||
+static unsigned int borderpx = 1; /* border pixel of windows */
|
||||
+static unsigned int snap = 32; /* snap pixel */
|
||||
+static int showbar = 1; /* 0 means no bar */
|
||||
+static int topbar = 1; /* 0 means bottom bar */
|
||||
+static char font[] = "monospace:size=10";
|
||||
+static char dmenufont[] = "monospace:size=10";
|
||||
+static const char *fonts[] = { font };
|
||||
+static char normbgcolor[] = "#222222";
|
||||
+static char normbordercolor[] = "#444444";
|
||||
+static char normfgcolor[] = "#bbbbbb";
|
||||
+static char selfgcolor[] = "#eeeeee";
|
||||
+static char selbordercolor[] = "#005577";
|
||||
+static char selbgcolor[] = "#005577";
|
||||
+static char *colors[][3] = {
|
||||
+ /* fg bg border */
|
||||
+ [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
|
||||
+ [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor },
|
||||
};
|
||||
|
||||
/* tagging */
|
||||
@@ -32,9 +34,9 @@ static const Rule rules[] = {
|
||||
};
|
||||
|
||||
/* 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 float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
||||
+static int nmaster = 1; /* number of clients in master area */
|
||||
+static int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
||||
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||
|
||||
static const Layout layouts[] = {
|
||||
@@ -57,9 +59,30 @@ static const Layout layouts[] = {
|
||||
|
||||
/* 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 *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbordercolor, "-sf", selfgcolor, NULL };
|
||||
static const char *termcmd[] = { "st", NULL };
|
||||
|
||||
+/*
|
||||
+ * Xresources preferences to load at startup
|
||||
+ */
|
||||
+ResourcePref resources[] = {
|
||||
+ { "font", STRING, &font },
|
||||
+ { "dmenufont", STRING, &dmenufont },
|
||||
+ { "normbgcolor", STRING, &normbgcolor },
|
||||
+ { "normbordercolor", STRING, &normbordercolor },
|
||||
+ { "normfgcolor", STRING, &normfgcolor },
|
||||
+ { "selbgcolor", STRING, &selbgcolor },
|
||||
+ { "selbordercolor", STRING, &selbordercolor },
|
||||
+ { "selfgcolor", STRING, &selfgcolor },
|
||||
+ { "borderpx", INTEGER, &borderpx },
|
||||
+ { "snap", INTEGER, &snap },
|
||||
+ { "showbar", INTEGER, &showbar },
|
||||
+ { "topbar", INTEGER, &topbar },
|
||||
+ { "nmaster", INTEGER, &nmaster },
|
||||
+ { "resizehints", INTEGER, &resizehints },
|
||||
+ { "mfact", FLOAT, &mfact },
|
||||
+};
|
||||
+
|
||||
static Key keys[] = {
|
||||
/* modifier key function argument */
|
||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||
diff --git a/drw.c b/drw.c
|
||||
index 4cdbcbe..8f1059e 100644
|
||||
--- a/drw.c
|
||||
+++ b/drw.c
|
||||
@@ -208,7 +208,7 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
||||
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
||||
* returned color scheme when done using it. */
|
||||
Clr *
|
||||
-drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||
+drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount)
|
||||
{
|
||||
size_t i;
|
||||
Clr *ret;
|
||||
diff --git a/drw.h b/drw.h
|
||||
index 4bcd5ad..42b04ce 100644
|
||||
--- a/drw.h
|
||||
+++ b/drw.h
|
||||
@@ -39,7 +39,7 @@ void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned in
|
||||
|
||||
/* Colorscheme abstraction */
|
||||
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
||||
-Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
||||
+Clr *drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount);
|
||||
|
||||
/* Cursor abstraction */
|
||||
Cur *drw_cur_create(Drw *drw, int shape);
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 5e4d494..2214b19 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include <X11/Xutil.h>
|
||||
+#include <X11/Xresource.h>
|
||||
#ifdef XINERAMA
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#endif /* XINERAMA */
|
||||
@@ -141,6 +142,19 @@ typedef struct {
|
||||
int monitor;
|
||||
} Rule;
|
||||
|
||||
+/* Xresources preferences */
|
||||
+enum resource_type {
|
||||
+ STRING = 0,
|
||||
+ INTEGER = 1,
|
||||
+ FLOAT = 2
|
||||
+};
|
||||
+
|
||||
+typedef struct {
|
||||
+ char *name;
|
||||
+ enum resource_type type;
|
||||
+ void *dst;
|
||||
+} ResourcePref;
|
||||
+
|
||||
/* function declarations */
|
||||
static void applyrules(Client *c);
|
||||
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
|
||||
@@ -234,6 +248,8 @@ static int xerror(Display *dpy, XErrorEvent *ee);
|
||||
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||
static void zoom(const Arg *arg);
|
||||
+static void load_xresources(void);
|
||||
+static void resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst);
|
||||
|
||||
/* variables */
|
||||
static const char broken[] = "broken";
|
||||
@@ -2127,6 +2143,60 @@ zoom(const Arg *arg)
|
||||
pop(c);
|
||||
}
|
||||
|
||||
+void
|
||||
+resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst)
|
||||
+{
|
||||
+ char *sdst = NULL;
|
||||
+ int *idst = NULL;
|
||||
+ float *fdst = NULL;
|
||||
+
|
||||
+ sdst = dst;
|
||||
+ idst = dst;
|
||||
+ fdst = dst;
|
||||
+
|
||||
+ char fullname[256];
|
||||
+ char *type;
|
||||
+ XrmValue ret;
|
||||
+
|
||||
+ snprintf(fullname, sizeof(fullname), "%s.%s", "dwm", name);
|
||||
+ fullname[sizeof(fullname) - 1] = '\0';
|
||||
+
|
||||
+ XrmGetResource(db, fullname, "*", &type, &ret);
|
||||
+ if (!(ret.addr == NULL || strncmp("String", type, 64)))
|
||||
+ {
|
||||
+ switch (rtype) {
|
||||
+ case STRING:
|
||||
+ strcpy(sdst, ret.addr);
|
||||
+ break;
|
||||
+ case INTEGER:
|
||||
+ *idst = strtoul(ret.addr, NULL, 10);
|
||||
+ break;
|
||||
+ case FLOAT:
|
||||
+ *fdst = strtof(ret.addr, NULL);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+load_xresources(void)
|
||||
+{
|
||||
+ Display *display;
|
||||
+ char *resm;
|
||||
+ XrmDatabase db;
|
||||
+ ResourcePref *p;
|
||||
+
|
||||
+ display = XOpenDisplay(NULL);
|
||||
+ resm = XResourceManagerString(display);
|
||||
+ if (!resm)
|
||||
+ return;
|
||||
+
|
||||
+ db = XrmGetStringDatabase(resm);
|
||||
+ for (p = resources; p < resources + LENGTH(resources); p++)
|
||||
+ resource_load(db, p->name, p->type, p->dst);
|
||||
+ XCloseDisplay(display);
|
||||
+}
|
||||
+
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
@@ -2139,6 +2209,8 @@ main(int argc, char *argv[])
|
||||
if (!(dpy = XOpenDisplay(NULL)))
|
||||
die("dwm: cannot open display");
|
||||
checkotherwm();
|
||||
+ XrmInitialize();
|
||||
+ load_xresources();
|
||||
setup();
|
||||
#ifdef __OpenBSD__
|
||||
if (pledge("stdio rpath proc exec", NULL) == -1)
|
||||
--
|
||||
2.33.0
|
||||
|
Loading…
Reference in New Issue