retab
This commit is contained in:
parent
fbb6a9ac3c
commit
c0c0adc645
7 changed files with 1283 additions and 1279 deletions
680
config.h
680
config.h
|
@ -1,351 +1,355 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#define BROWSER "librewolf"
|
||||
|
||||
#define BROWSER "librewolf"
|
||||
#define TERMINAL "kitty"
|
||||
|
||||
/* appearance */
|
||||
|
||||
/* appearance */
|
||||
/* Settings */
|
||||
#if !PERTAG_PATCH
|
||||
static int enablegaps = 0;
|
||||
#endif
|
||||
static unsigned int borderpx = 2; /* border pixel of windows */
|
||||
static unsigned int snap = 20; /* snap pixel */
|
||||
static unsigned int gappih = 10; /* horiz inner gap between windows */
|
||||
static unsigned int gappiv = 10; /* vert inner gap between windows */
|
||||
static unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */
|
||||
static unsigned int gappov = 10; /* vert outer gap between windows and screen edge */
|
||||
static int smartgaps = 0; /* 1 means no outer gap when there is only one window */
|
||||
static int swallowfloating = 0; /* 1 means swallow floating windows by default */
|
||||
static int showbar = 1; /* 0 means no bar */
|
||||
static int topbar = 1; /* 0 means bottom bar */
|
||||
static const char *fonts[] = { "monospace:pixelsize=14", "monospace:pixelsize=20", "monospace:pixelsize=30", "Noto Color Emoji:pixelsize=14:antialias=true:autohint=true" };
|
||||
|
||||
static char color0[] = "#000000";
|
||||
static char color1[] = "#7f0000";
|
||||
static char color2[] = "#007f00";
|
||||
static char color3[] = "#7f7f00";
|
||||
static char color4[] = "#00007f";
|
||||
static char color5[] = "#7f007f";
|
||||
static char color6[] = "#007f7f";
|
||||
static char color7[] = "#cccccc";
|
||||
static char color8[] = "#333333";
|
||||
static char color9[] = "#ff0000";
|
||||
static char color10[] = "#00ff00";
|
||||
static char color11[] = "#ffff00";
|
||||
static char color12[] = "#0000ff";
|
||||
static char color13[] = "#ff00ff";
|
||||
static char color14[] = "#00ffff";
|
||||
static char color15[] = "#ffffff";
|
||||
static char bordernorm[] = "#222222";
|
||||
static char bordersel[] = "#444444";
|
||||
static char *colors[][3] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { color15, color0, bordernorm },
|
||||
[SchemeSel] = { color15, color4, bordersel },
|
||||
[SchemeStatus] = { color7, color0, "#000000" }, // Statusbar right
|
||||
[SchemeTagsSel] = { color0, color4, "#000000" }, // Tagbar left selected
|
||||
[SchemeTagsNorm] = { color7, color0, "#000000" }, // Tagbar left unselected
|
||||
[SchemeInfoSel] = { color7, color0, "#000000" }, // infobar middle selected
|
||||
[SchemeInfoNorm] = { color7, color0, "#000000" }, // infobar middle unselected
|
||||
};
|
||||
|
||||
/* Colors for SGR escapes */
|
||||
static const char *barcolors[] = {
|
||||
color0,
|
||||
color1,
|
||||
color2,
|
||||
color3,
|
||||
color4,
|
||||
color5,
|
||||
color6,
|
||||
color7,
|
||||
color8,
|
||||
color9,
|
||||
color10,
|
||||
color11,
|
||||
color12,
|
||||
color13,
|
||||
color14,
|
||||
color15,
|
||||
};
|
||||
|
||||
/* tagging */
|
||||
static 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
|
||||
static unsigned int borderpx = 2; /* border pixel of windows */
|
||||
static unsigned int snap = 20; /* snap pixel */
|
||||
static unsigned int gappih = 10; /* horiz inner gap between windows */
|
||||
static unsigned int gappiv = 10; /* vert inner gap between windows */
|
||||
static unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */
|
||||
static unsigned int gappov = 10; /* vert outer gap between windows and screen edge */
|
||||
static int smartgaps = 0; /* 1 means no outer gap when there is only one window */
|
||||
static int swallowfloating = 0; /* 1 means swallow floating windows by default */
|
||||
static int showbar = 1; /* 0 means no bar */
|
||||
static int topbar = 1; /* 0 means bottom bar */
|
||||
static const char *fonts[] = { "monospace:pixelsize=14", "monospace:pixelsize=20", "monospace:pixelsize=30", "Noto Color Emoji:pixelsize=14:antialias=true:autohint=true" };
|
||||
|
||||
static char color0[] = "#000000";
|
||||
static char color1[] = "#7f0000";
|
||||
static char color2[] = "#007f00";
|
||||
static char color3[] = "#7f7f00";
|
||||
static char color4[] = "#00007f";
|
||||
static char color5[] = "#7f007f";
|
||||
static char color6[] = "#007f7f";
|
||||
static char color7[] = "#cccccc";
|
||||
static char color8[] = "#333333";
|
||||
static char color9[] = "#ff0000";
|
||||
static char color10[] = "#00ff00";
|
||||
static char color11[] = "#ffff00";
|
||||
static char color12[] = "#0000ff";
|
||||
static char color13[] = "#ff00ff";
|
||||
static char color14[] = "#00ffff";
|
||||
static char color15[] = "#ffffff";
|
||||
static char bordernorm[] = "#222222";
|
||||
static char bordersel[] = "#444444";
|
||||
static char *colors[][3] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { color15, color0, bordernorm },
|
||||
[SchemeSel] = { color15, color4, bordersel },
|
||||
[SchemeStatus] = { color7, color0, "#000000" }, // Statusbar right
|
||||
[SchemeTagsSel] = { color0, color4, "#000000" }, // Tagbar left selected
|
||||
[SchemeTagsNorm] = { color7, color0, "#000000" }, // Tagbar left unselected
|
||||
[SchemeInfoSel] = { color7, color0, "#000000" }, // infobar middle selected
|
||||
[SchemeInfoNorm] = { color7, color0, "#000000" }, // infobar middle unselected
|
||||
};
|
||||
|
||||
/* Colors for SGR escapes */
|
||||
static const char *barcolors[] = {
|
||||
color0,
|
||||
color1,
|
||||
color2,
|
||||
color3,
|
||||
color4,
|
||||
color5,
|
||||
color6,
|
||||
color7,
|
||||
color8,
|
||||
color9,
|
||||
color10,
|
||||
color11,
|
||||
color12,
|
||||
color13,
|
||||
color14,
|
||||
color15,
|
||||
};
|
||||
|
||||
/* tagging */
|
||||
static 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
|
||||
* If X, Y, W or H are between 0 and 1 (inclusive), their values interpreted as percentages of the current monitor resolution.
|
||||
* If X or Y are negative, they are subtracted from the current monitor resolution and then that value is interpreted.
|
||||
class instance title scratch key tags mask isfloating isterminal noswallow x, y, w, h borderpx */
|
||||
{ NULL, NULL, "Event Tester", 0, 0, 0, 0, 1, 0, 0, 0, 0, -1 },
|
||||
{ "kitty", "kitty", NULL, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1 },
|
||||
{ "Qalculate-gtk", NULL, NULL, 'q', 0, 1, 0, 0, .5, .5, 722, 512, -1 },
|
||||
{ NULL, "spterm", NULL, 't', 0, 1, 1, 0, .5, .5, 1, 1, 0 },
|
||||
{ NULL, "splf", NULL, 'l', 0, 1, 0, 0, .5, .5, .8, .8, -1 },
|
||||
{ NULL, "sphtop", NULL, 'h', 0, 1, 0, 0, .5, .5, .8, .8, -1 },
|
||||
{ NULL, "spmix", NULL, 'm', 0, 1, 0, 0, -4, -4, 900, 600, -1 },
|
||||
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
static float mfact = 0.50; /* 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 int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||
|
||||
#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 Mod4Mask
|
||||
#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} },
|
||||
#define STACKKEYS(MOD,ACTION) \
|
||||
{MOD, XK_j, ACTION##stack, {.i = INC(+1)}}, \
|
||||
{MOD, XK_k, ACTION##stack, {.i = INC(-1)}}, \
|
||||
{MOD, XK_v, ACTION##stack, {.i = 0}}, \
|
||||
/*{MOD, XK_grave, ACTION##stack, {.i = PREVSEL}}, \ */
|
||||
/*{MOD, XK_a, ACTION##stack, {.i = 1}}, \ */
|
||||
/*{MOD, XK_z, ACTION##stack, {.i = 2}}, \ */
|
||||
/*{MOD, XK_x, ACTION##stack, {.i = -1}}, */
|
||||
|
||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||
#define SHCMD(cmd) { .v = (const char*[]){"/bin/sh", "-c", cmd, NULL} }
|
||||
|
||||
/* commands */
|
||||
class instance title scratch key tags mask isfloating isterminal noswallow x, y, w, h borderpx */
|
||||
{ NULL, NULL, "Event Tester", 0, 0, 0, 0, 1, 0, 0, 0, 0, -1 },
|
||||
{ "Xournalpp", "xournalpp", NULL, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1 },
|
||||
{ "Zathura", "org.pwmt.zathura", NULL, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1 },
|
||||
{ NULL, "kitty", NULL, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1 },
|
||||
{ "Qalculate-gtk", NULL, NULL, 'q', 0, 1, 0, 0, .5, .5, 722, 512, -1 },
|
||||
{ NULL, "spterm", NULL, 't', 0, 1, 1, 0, .5, .5, 1, 1, 0 },
|
||||
{ NULL, "splf", NULL, 'l', 0, 1, 0, 0, .5, .5, .8, .8, -1 },
|
||||
{ NULL, "sphtop", NULL, 'h', 0, 1, 0, 0, .5, .5, .8, .8, -1 },
|
||||
{ NULL, "spmix", NULL, 'm', 0, 1, 0, 0, -4, -4, 900, 600, -1 },
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
static float mfact = 0.50; /* 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 int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||
|
||||
#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 Mod4Mask
|
||||
#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} },
|
||||
#define STACKKEYS(MOD,ACTION) \
|
||||
{MOD, XK_j, ACTION##stack, {.i = INC(+1)}}, \
|
||||
{MOD, XK_k, ACTION##stack, {.i = INC(-1)}}, \
|
||||
{MOD, XK_v, ACTION##stack, {.i = 0}}, \
|
||||
/*{MOD, XK_grave, ACTION##stack, {.i = PREVSEL}}, \ */
|
||||
/*{MOD, XK_a, ACTION##stack, {.i = 1}}, \ */
|
||||
/*{MOD, XK_z, ACTION##stack, {.i = 2}}, \ */
|
||||
/*{MOD, XK_x, ACTION##stack, {.i = -1}}, */
|
||||
|
||||
/* 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 const char *spterm[] = { "t", "/bin/sh", "-c", "$TERMINAL --name spterm --config ~/.config/kitty/kitty.conf --config ~/.config/kitty/kittyfullscreen.conf" };
|
||||
static const char *spqalc[] = { "q", "qalculate-gtk", NULL };
|
||||
static const char *splf[] = { "l", TERMINAL, "--name", "splf", "-d", "~", "-e", "lf", NULL };
|
||||
static const char *sphtop[] = { "h", TERMINAL, "--name", "sphtop", "-e", "htop", NULL };
|
||||
static const char *spmix[] = { "m", "/bin/sh", "-c", "$TERMINAL --name spmix -e pulsemixer; pkill -RTMIN+10 dwmblocks" };
|
||||
|
||||
/*
|
||||
* Xresources preferences to load at startup
|
||||
*/
|
||||
ResourcePref resources[] = {
|
||||
{ "color0", STRING, &color0 },
|
||||
{ "color1", STRING, &color1 },
|
||||
{ "color2", STRING, &color2 },
|
||||
{ "color3", STRING, &color3 },
|
||||
{ "color4", STRING, &color4 },
|
||||
{ "color5", STRING, &color5 },
|
||||
{ "color6", STRING, &color6 },
|
||||
{ "color7", STRING, &color7 },
|
||||
{ "color8", STRING, &color8 },
|
||||
{ "color9", STRING, &color9 },
|
||||
{ "color10", STRING, &color10 },
|
||||
{ "color11", STRING, &color11 },
|
||||
{ "color12", STRING, &color12 },
|
||||
{ "color13", STRING, &color13 },
|
||||
{ "color14", STRING, &color14 },
|
||||
{ "color15", STRING, &color15 },
|
||||
{ "bordernorm", STRING, &bordernorm },
|
||||
{ "bordersel", STRING, &bordersel },
|
||||
};
|
||||
|
||||
#include <X11/XF86keysym.h>
|
||||
|
||||
static Key keys[] = {
|
||||
STACKKEYS(MODKEY, focus) STACKKEYS(MODKEY | ShiftMask, push)
|
||||
/* modifier key function argument */
|
||||
{ MODKEY, XK_F1, spawn, SHCMD("groff -mom /usr/local/share/dwm/keybinds.mom -Tpdf | zathura -") },
|
||||
{ MODKEY, XK_F2, spawn, {.v = (const char *[]){TERMINAL, "-e", "deluge-console", NULL}} },
|
||||
{ MODKEY, XK_F3, togglescratch, {.v = spmix} },
|
||||
/*{ MODKEY, XK_F4, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_F5, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_F6, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_F7, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_F8, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_F9, spawn, {.v = (const char *[]){"dmenumount", NULL}} },
|
||||
{ MODKEY, XK_F10, spawn, {.v = (const char *[]){"dmenuumount", NULL}} },
|
||||
/*{ MODKEY, XK_F11, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_F12, spawn, {.v = (const char *[]){"xkb-switch", "-n", NULL}} },
|
||||
{ MODKEY, XK_asciicircum, spawn, {.v = (const char *[]){"dmenuunicode", NULL}} },
|
||||
/*{ MODKEY | ShiftMask, XK_asciicircum, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
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 | ShiftMask, XK_0, tag, {.ui = ~0} },
|
||||
{ MODKEY, XK_ssharp, spawn, SHCMD("pamixer --allow-boost -d 5; pkill -RTMIN+10 dwmblocks)") },
|
||||
{ MODKEY | ShiftMask, XK_ssharp, spawn, SHCMD("pamixer --allow-boost -d 15; pkill -RTMIN+10 dwmblocks)") },
|
||||
{ MODKEY, XK_acute, spawn, SHCMD("pamixer --allow-boost -i 5; pkill -RTMIN+10 dwmblocks)") },
|
||||
{ MODKEY | ShiftMask, XK_acute, spawn, SHCMD("pamixer --allow-boost -i 15; pkill -RTMIN+10 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, {.v = (const char *[]){NULL}}},*/
|
||||
{ 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, togglescratch, {.v = splf} },
|
||||
/*{ MODKEY | ShiftMask, XK_e, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_r, togglescratch, {.v = sphtop} },
|
||||
{ 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_z, setlayout, {.v = &layouts[2]} }, /* spiral */
|
||||
{ MODKEY | ShiftMask, XK_z, 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 pause ; pauseallmpv") },
|
||||
{ MODKEY, XK_udiaeresis, spawn, {.v = (const char *[]){"mpc", "seek", "-10", NULL}} },
|
||||
{ MODKEY | ShiftMask, XK_udiaeresis, spawn, {.v = (const char *[]){"mpc", "seek", "-60", NULL}} },
|
||||
{ MODKEY, XK_plus, spawn, {.v = (const char *[]){"mpc", "seek", "+10", NULL}} },
|
||||
{ MODKEY | ShiftMask, XK_plus, spawn, {.v = (const char *[]){"mpc", "seek", "+60", NULL}} },
|
||||
{ MODKEY, XK_a, togglegaps, {0} },
|
||||
{ MODKEY | ShiftMask, XK_a, defaultgaps, {0} },
|
||||
/*{ MODKEY, XK_s, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_s, spawn, {.v = (const char *[]){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]} }, /* floating */
|
||||
/*{ MODKEY, XK_g, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_g, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
/*{ MODKEY | ShiftMask, XK_h, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/* J and K are automatically bound above in STACKKEYS */
|
||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||
/*{ MODKEY | ShiftMask, XK_l, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_odiaeresis, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_odiaeresis, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_adiaeresis, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_adiaeresis, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_numbersign, togglescratch, {.v = spqalc} },
|
||||
/*{ MODKEY | ShiftMask, XK_numbersign, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_Return, spawn, {.v = (const char *[]){TERMINAL, "-d", "~", NULL}} },
|
||||
{ MODKEY | ShiftMask, XK_Return, togglescratch, {.v = spterm} },
|
||||
/*{ MODKEY, XK_y, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_y, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_x, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_x, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_c, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_c, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/* V is automatically bound above in STACKKEYS */
|
||||
{ MODKEY, XK_b, togglebar, {0} },
|
||||
/*{ MODKEY | ShiftMask, XK_b, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_n, spawn, {.v = (const char *[]){TERMINAL, "-e", "nvim", "-c", "VimwikiIndex", NULL}} },
|
||||
/*{ MODKEY | ShiftMask, XK_n, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_m, spawn, {.v = (const char *[]){TERMINAL, "-e", "ncmpcpp", NULL}} },
|
||||
{ MODKEY | ShiftMask, XK_m, spawn, SHCMD("pamixer -t; 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_minus, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_minus, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_space, zoom, {0} },
|
||||
{ MODKEY | ShiftMask, XK_space, togglefloating, {0} },
|
||||
{ 0, XK_Print, spawn, SHCMD("maim ~/Photos/Screenshots/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_Scroll_Lock, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_Scroll_Lock, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_Pause, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_Pause, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_Insert, spawn, SHCMD("xdotool type $(grep -v '^#' ~/.local/share/snippets | dmenu -i -l " "50 | cut -d' ' -f1)") },
|
||||
/*{ MODKEY | ShiftMask, XK_Insert, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_Home, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_Home, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_Delete, spawn, {.v = (const char *[]){"dmenurecord", "kill", NULL}} },
|
||||
/*{ MODKEY | ShiftMask, XK_Delete, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_End, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY | ShiftMask, XK_End, quit, {0} },
|
||||
/*{ MODKEY, XK_Page_Up, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_Page_Up, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_Page_Down, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_Page_Down, spawn, {.v = (const char *[]){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_Up, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_Up, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_Down, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_Down, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
|
||||
{ 0, XF86XK_AudioMute, spawn, SHCMD("pamixer -t; pkill -RTMIN+10 dwmblocks") },
|
||||
{ 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("pamixer --allow-boost -i 3; pkill -RTMIN+10 dwmblocks") },
|
||||
{ 0, XF86XK_AudioLowerVolume, spawn, SHCMD("pamixer --allow-boost -d 3; pkill -RTMIN+10 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_WLAN, spawn, SHCMD("sleep 0.1; pkill -RTMIN+4 dwmblocks") },
|
||||
{ 0, XF86XK_DOS, spawn, {.v = (const char *[]){TERMINAL, NULL}} },
|
||||
{ 0, XF86XK_ScreenSaver, spawn, SHCMD("xset s activate & 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, {.v = (const char *[]){NULL}} }, */
|
||||
{ 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", "5", NULL}} },
|
||||
{ 0, XF86XK_MonBrightnessDown, spawn, {.v = (const char *[]){"xbacklight", "-dec", "5", NULL}} },
|
||||
};
|
||||
|
||||
/* 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} },
|
||||
{ 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} },
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Xresources preferences to load at startup
|
||||
*/
|
||||
ResourcePref resources[] = {
|
||||
{ "color0", STRING, &color0 },
|
||||
{ "color1", STRING, &color1 },
|
||||
{ "color2", STRING, &color2 },
|
||||
{ "color3", STRING, &color3 },
|
||||
{ "color4", STRING, &color4 },
|
||||
{ "color5", STRING, &color5 },
|
||||
{ "color6", STRING, &color6 },
|
||||
{ "color7", STRING, &color7 },
|
||||
{ "color8", STRING, &color8 },
|
||||
{ "color9", STRING, &color9 },
|
||||
{ "color10", STRING, &color10 },
|
||||
{ "color11", STRING, &color11 },
|
||||
{ "color12", STRING, &color12 },
|
||||
{ "color13", STRING, &color13 },
|
||||
{ "color14", STRING, &color14 },
|
||||
{ "color15", STRING, &color15 },
|
||||
{ "bordernorm", STRING, &bordernorm },
|
||||
{ "bordersel", STRING, &bordersel },
|
||||
};
|
||||
|
||||
#include <X11/XF86keysym.h>
|
||||
|
||||
static Key keys[] = {
|
||||
STACKKEYS(MODKEY, focus) STACKKEYS(MODKEY | ShiftMask, push)
|
||||
/* modifier key function argument */
|
||||
{ MODKEY, XK_F1, spawn, SHCMD("groff -mom /usr/local/share/dwm/keybinds.mom -Tpdf | zathura -") },
|
||||
{ MODKEY, XK_F2, spawn, {.v = (const char *[]){TERMINAL, "-e", "deluge-console", NULL}} },
|
||||
{ MODKEY, XK_F3, togglescratch, {.v = spmix} },
|
||||
/*{ MODKEY, XK_F4, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_F5, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_F6, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_F7, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_F8, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_F9, spawn, {.v = (const char *[]){"dmenumount", NULL}} },
|
||||
{ MODKEY, XK_F10, spawn, {.v = (const char *[]){"dmenuumount", NULL}} },
|
||||
/*{ MODKEY, XK_F11, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_F12, spawn, {.v = (const char *[]){"remaps", NULL}} },
|
||||
{ MODKEY, XK_asciicircum, spawn, {.v = (const char *[]){"dmenuunicode", NULL}} },
|
||||
/*{ MODKEY | ShiftMask, XK_asciicircum, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
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 | ShiftMask, XK_0, tag, {.ui = ~0} },
|
||||
{ MODKEY, XK_ssharp, spawn, SHCMD("pamixer --allow-boost -d 5; pkill -RTMIN+10 dwmblocks)") },
|
||||
{ MODKEY | ShiftMask, XK_ssharp, spawn, SHCMD("pamixer --allow-boost -d 15; pkill -RTMIN+10 dwmblocks)") },
|
||||
{ MODKEY, XK_acute, spawn, SHCMD("pamixer --allow-boost -i 5; pkill -RTMIN+10 dwmblocks)") },
|
||||
{ MODKEY | ShiftMask, XK_acute, spawn, SHCMD("pamixer --allow-boost -i 15; pkill -RTMIN+10 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, {.v = (const char *[]){NULL}}},*/
|
||||
{ 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, togglescratch, {.v = splf} },
|
||||
/*{ MODKEY | ShiftMask, XK_e, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_r, togglescratch, {.v = sphtop} },
|
||||
{ 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_z, setlayout, {.v = &layouts[2]} }, /* spiral */
|
||||
{ MODKEY | ShiftMask, XK_z, 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 pause ; pauseallmpv") },
|
||||
{ MODKEY, XK_udiaeresis, spawn, {.v = (const char *[]){"mpc", "seek", "-10", NULL}} },
|
||||
{ MODKEY | ShiftMask, XK_udiaeresis, spawn, {.v = (const char *[]){"mpc", "seek", "-60", NULL}} },
|
||||
{ MODKEY, XK_plus, spawn, {.v = (const char *[]){"mpc", "seek", "+10", NULL}} },
|
||||
{ MODKEY | ShiftMask, XK_plus, spawn, {.v = (const char *[]){"mpc", "seek", "+60", NULL}} },
|
||||
{ MODKEY, XK_a, togglegaps, {0} },
|
||||
{ MODKEY | ShiftMask, XK_a, defaultgaps, {0} },
|
||||
/*{ MODKEY, XK_s, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_s, spawn, {.v = (const char *[]){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]} }, /* floating */
|
||||
/*{ MODKEY, XK_g, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_g, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
/*{ MODKEY | ShiftMask, XK_h, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/* J and K are automatically bound above in STACKKEYS */
|
||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||
/*{ MODKEY | ShiftMask, XK_l, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_odiaeresis, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_odiaeresis, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_adiaeresis, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_adiaeresis, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_numbersign, togglescratch, {.v = spqalc} },
|
||||
/*{ MODKEY | ShiftMask, XK_numbersign, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_backslash, togglescratch, {.v = spqalc} },
|
||||
/*{ MODKEY | ShiftMask, XK_backslash, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_Return, spawn, {.v = (const char *[]){TERMINAL, "-d", "~", NULL}} },
|
||||
{ MODKEY | ShiftMask, XK_Return, togglescratch, {.v = spterm} },
|
||||
/*{ MODKEY, XK_y, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_y, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_x, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_x, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_c, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_c, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/* V is automatically bound above in STACKKEYS */
|
||||
{ MODKEY, XK_b, togglebar, {0} },
|
||||
/*{ MODKEY | ShiftMask, XK_b, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_n, spawn, {.v = (const char *[]){TERMINAL, "-e", "nvim", "-c", "VimwikiIndex", NULL}} },
|
||||
/*{ MODKEY | ShiftMask, XK_n, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_m, spawn, {.v = (const char *[]){TERMINAL, "-e", "ncmpcpp", NULL}} },
|
||||
{ MODKEY | ShiftMask, XK_m, spawn, SHCMD("pamixer -t; 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_minus, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_minus, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_space, zoom, {0} },
|
||||
{ MODKEY | ShiftMask, XK_space, togglefloating, {0} },
|
||||
{ 0, XK_Print, spawn, SHCMD("maim ~/Photos/Screenshots/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_Scroll_Lock, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_Scroll_Lock, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_Pause, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_Pause, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_Insert, spawn, SHCMD("xdotool type $(grep -v '^#' ~/.local/share/snippets | dmenu -i -l " "50 | cut -d' ' -f1)") },
|
||||
/*{ MODKEY | ShiftMask, XK_Insert, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_Home, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_Home, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY, XK_Delete, spawn, {.v = (const char *[]){"dmenurecord", "kill", NULL}} },
|
||||
/*{ MODKEY | ShiftMask, XK_Delete, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_End, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
{ MODKEY | ShiftMask, XK_End, quit, {0} },
|
||||
/*{ MODKEY, XK_Page_Up, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_Page_Up, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_Page_Down, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_Page_Down, spawn, {.v = (const char *[]){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_Up, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_Up, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY, XK_Down, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
/*{ MODKEY | ShiftMask, XK_Down, spawn, {.v = (const char *[]){NULL}} },*/
|
||||
|
||||
{ 0, XF86XK_AudioMute, spawn, SHCMD("pamixer -t; pkill -RTMIN+10 dwmblocks") },
|
||||
{ 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("pamixer --allow-boost -i 5; pkill -RTMIN+10 dwmblocks") },
|
||||
{ 0, XF86XK_AudioLowerVolume, spawn, SHCMD("pamixer --allow-boost -d 5; pkill -RTMIN+10 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_WLAN, spawn, SHCMD("sleep 0.1; pkill -RTMIN+4 dwmblocks") },
|
||||
{ 0, XF86XK_DOS, spawn, {.v = (const char *[]){TERMINAL, NULL}} },
|
||||
{ 0, XF86XK_ScreenSaver, spawn, SHCMD("xset s activate & 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, {.v = (const char *[]){NULL}} }, */
|
||||
{ 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}} },
|
||||
// WARN: If you have multiple backlight controllers this will fail
|
||||
{ 0, XF86XK_MonBrightnessUp, spawn, SHCMD("echo $(($(cat /sys/class/backlight/*/brightness) + 5)) | tee /sys/class/backlight/*/brightness") },
|
||||
{ 0, XF86XK_MonBrightnessDown, spawn, SHCMD("echo $(($(cat /sys/class/backlight/*/brightness) - 5)) | tee /sys/class/backlight/*/brightness") },
|
||||
};
|
||||
|
||||
/* 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} },
|
||||
{ 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} },
|
||||
};
|
||||
|
||||
|
|
548
drw.c
548
drw.c
|
@ -19,84 +19,84 @@ static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF
|
|||
static long
|
||||
utf8decodebyte(const char c, size_t *i)
|
||||
{
|
||||
for (*i = 0; *i < (UTF_SIZ + 1); ++(*i))
|
||||
if (((unsigned char)c & utfmask[*i]) == utfbyte[*i])
|
||||
return (unsigned char)c & ~utfmask[*i];
|
||||
return 0;
|
||||
for (*i = 0; *i < (UTF_SIZ + 1); ++(*i))
|
||||
if (((unsigned char)c & utfmask[*i]) == utfbyte[*i])
|
||||
return (unsigned char)c & ~utfmask[*i];
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t
|
||||
utf8validate(long *u, size_t i)
|
||||
{
|
||||
if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF))
|
||||
*u = UTF_INVALID;
|
||||
for (i = 1; *u > utfmax[i]; ++i)
|
||||
;
|
||||
return i;
|
||||
if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF))
|
||||
*u = UTF_INVALID;
|
||||
for (i = 1; *u > utfmax[i]; ++i)
|
||||
;
|
||||
return i;
|
||||
}
|
||||
|
||||
static size_t
|
||||
utf8decode(const char *c, long *u, size_t clen)
|
||||
{
|
||||
size_t i, j, len, type;
|
||||
long udecoded;
|
||||
size_t i, j, len, type;
|
||||
long udecoded;
|
||||
|
||||
*u = UTF_INVALID;
|
||||
if (!clen)
|
||||
return 0;
|
||||
udecoded = utf8decodebyte(c[0], &len);
|
||||
if (!BETWEEN(len, 1, UTF_SIZ))
|
||||
return 1;
|
||||
for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
|
||||
udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type);
|
||||
if (type)
|
||||
return j;
|
||||
}
|
||||
if (j < len)
|
||||
return 0;
|
||||
*u = udecoded;
|
||||
utf8validate(u, len);
|
||||
*u = UTF_INVALID;
|
||||
if (!clen)
|
||||
return 0;
|
||||
udecoded = utf8decodebyte(c[0], &len);
|
||||
if (!BETWEEN(len, 1, UTF_SIZ))
|
||||
return 1;
|
||||
for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
|
||||
udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type);
|
||||
if (type)
|
||||
return j;
|
||||
}
|
||||
if (j < len)
|
||||
return 0;
|
||||
*u = udecoded;
|
||||
utf8validate(u, len);
|
||||
|
||||
return len;
|
||||
return len;
|
||||
}
|
||||
|
||||
Drw *
|
||||
drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h)
|
||||
{
|
||||
Drw *drw = ecalloc(1, sizeof(Drw));
|
||||
Drw *drw = ecalloc(1, sizeof(Drw));
|
||||
|
||||
drw->dpy = dpy;
|
||||
drw->screen = screen;
|
||||
drw->root = root;
|
||||
drw->w = w;
|
||||
drw->h = h;
|
||||
drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
|
||||
drw->gc = XCreateGC(dpy, root, 0, NULL);
|
||||
XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
|
||||
drw->dpy = dpy;
|
||||
drw->screen = screen;
|
||||
drw->root = root;
|
||||
drw->w = w;
|
||||
drw->h = h;
|
||||
drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
|
||||
drw->gc = XCreateGC(dpy, root, 0, NULL);
|
||||
XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
|
||||
|
||||
return drw;
|
||||
return drw;
|
||||
}
|
||||
|
||||
void
|
||||
drw_resize(Drw *drw, unsigned int w, unsigned int h)
|
||||
{
|
||||
if (!drw)
|
||||
return;
|
||||
if (!drw)
|
||||
return;
|
||||
|
||||
drw->w = w;
|
||||
drw->h = h;
|
||||
if (drw->drawable)
|
||||
XFreePixmap(drw->dpy, drw->drawable);
|
||||
drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
|
||||
drw->w = w;
|
||||
drw->h = h;
|
||||
if (drw->drawable)
|
||||
XFreePixmap(drw->dpy, drw->drawable);
|
||||
drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
|
||||
}
|
||||
|
||||
void
|
||||
drw_free(Drw *drw)
|
||||
{
|
||||
XFreePixmap(drw->dpy, drw->drawable);
|
||||
XFreeGC(drw->dpy, drw->gc);
|
||||
drw_fontset_free(drw->fonts);
|
||||
free(drw);
|
||||
XFreePixmap(drw->dpy, drw->drawable);
|
||||
XFreeGC(drw->dpy, drw->gc);
|
||||
drw_fontset_free(drw->fonts);
|
||||
free(drw);
|
||||
}
|
||||
|
||||
/* This function is an implementation detail. Library users should use
|
||||
|
@ -105,106 +105,106 @@ drw_free(Drw *drw)
|
|||
static Fnt *
|
||||
xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
|
||||
{
|
||||
Fnt *font;
|
||||
XftFont *xfont = NULL;
|
||||
FcPattern *pattern = NULL;
|
||||
Fnt *font;
|
||||
XftFont *xfont = NULL;
|
||||
FcPattern *pattern = NULL;
|
||||
|
||||
if (fontname) {
|
||||
/* Using the pattern found at font->xfont->pattern does not yield the
|
||||
* same substitution results as using the pattern returned by
|
||||
* FcNameParse; using the latter results in the desired fallback
|
||||
* behaviour whereas the former just results in missing-character
|
||||
* rectangles being drawn, at least with some fonts. */
|
||||
if (!(xfont = XftFontOpenName(drw->dpy, drw->screen, fontname))) {
|
||||
fprintf(stderr, "error, cannot load font from name: '%s'\n", fontname);
|
||||
return NULL;
|
||||
}
|
||||
if (!(pattern = FcNameParse((FcChar8 *) fontname))) {
|
||||
fprintf(stderr, "error, cannot parse font name to pattern: '%s'\n", fontname);
|
||||
XftFontClose(drw->dpy, xfont);
|
||||
return NULL;
|
||||
}
|
||||
} else if (fontpattern) {
|
||||
if (!(xfont = XftFontOpenPattern(drw->dpy, fontpattern))) {
|
||||
fprintf(stderr, "error, cannot load font from pattern.\n");
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
die("no font specified.");
|
||||
}
|
||||
if (fontname) {
|
||||
/* Using the pattern found at font->xfont->pattern does not yield the
|
||||
* same substitution results as using the pattern returned by
|
||||
* FcNameParse; using the latter results in the desired fallback
|
||||
* behaviour whereas the former just results in missing-character
|
||||
* rectangles being drawn, at least with some fonts. */
|
||||
if (!(xfont = XftFontOpenName(drw->dpy, drw->screen, fontname))) {
|
||||
fprintf(stderr, "error, cannot load font from name: '%s'\n", fontname);
|
||||
return NULL;
|
||||
}
|
||||
if (!(pattern = FcNameParse((FcChar8 *) fontname))) {
|
||||
fprintf(stderr, "error, cannot parse font name to pattern: '%s'\n", fontname);
|
||||
XftFontClose(drw->dpy, xfont);
|
||||
return NULL;
|
||||
}
|
||||
} else if (fontpattern) {
|
||||
if (!(xfont = XftFontOpenPattern(drw->dpy, fontpattern))) {
|
||||
fprintf(stderr, "error, cannot load font from pattern.\n");
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
die("no font specified.");
|
||||
}
|
||||
|
||||
/* Do not allow using color fonts. This is a workaround for a BadLength
|
||||
* error from Xft with color glyphs. Modelled on the Xterm workaround. See
|
||||
* https://bugzilla.redhat.com/show_bug.cgi?id=1498269
|
||||
* https://lists.suckless.org/dev/1701/30932.html
|
||||
* https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916349
|
||||
* and lots more all over the internet.
|
||||
*/
|
||||
FcBool iscol;
|
||||
if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) {
|
||||
XftFontClose(drw->dpy, xfont);
|
||||
return NULL;
|
||||
}
|
||||
/* Do not allow using color fonts. This is a workaround for a BadLength
|
||||
* error from Xft with color glyphs. Modelled on the Xterm workaround. See
|
||||
* https://bugzilla.redhat.com/show_bug.cgi?id=1498269
|
||||
* https://lists.suckless.org/dev/1701/30932.html
|
||||
* https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916349
|
||||
* and lots more all over the internet.
|
||||
*/
|
||||
FcBool iscol;
|
||||
if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) {
|
||||
XftFontClose(drw->dpy, xfont);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
font = ecalloc(1, sizeof(Fnt));
|
||||
font->xfont = xfont;
|
||||
font->pattern = pattern;
|
||||
font->h = xfont->ascent + xfont->descent;
|
||||
font->dpy = drw->dpy;
|
||||
font = ecalloc(1, sizeof(Fnt));
|
||||
font->xfont = xfont;
|
||||
font->pattern = pattern;
|
||||
font->h = xfont->ascent + xfont->descent;
|
||||
font->dpy = drw->dpy;
|
||||
|
||||
return font;
|
||||
return font;
|
||||
}
|
||||
|
||||
static void
|
||||
xfont_free(Fnt *font)
|
||||
{
|
||||
if (!font)
|
||||
return;
|
||||
if (font->pattern)
|
||||
FcPatternDestroy(font->pattern);
|
||||
XftFontClose(font->dpy, font->xfont);
|
||||
free(font);
|
||||
if (!font)
|
||||
return;
|
||||
if (font->pattern)
|
||||
FcPatternDestroy(font->pattern);
|
||||
XftFontClose(font->dpy, font->xfont);
|
||||
free(font);
|
||||
}
|
||||
|
||||
Fnt*
|
||||
drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)
|
||||
{
|
||||
Fnt *cur, *ret = NULL;
|
||||
size_t i;
|
||||
Fnt *cur, *ret = NULL;
|
||||
size_t i;
|
||||
|
||||
if (!drw || !fonts)
|
||||
return NULL;
|
||||
if (!drw || !fonts)
|
||||
return NULL;
|
||||
|
||||
for (i = 1; i <= fontcount; i++) {
|
||||
if ((cur = xfont_create(drw, fonts[fontcount - i], NULL))) {
|
||||
cur->next = ret;
|
||||
ret = cur;
|
||||
}
|
||||
}
|
||||
return (drw->fonts = ret);
|
||||
for (i = 1; i <= fontcount; i++) {
|
||||
if ((cur = xfont_create(drw, fonts[fontcount - i], NULL))) {
|
||||
cur->next = ret;
|
||||
ret = cur;
|
||||
}
|
||||
}
|
||||
return (drw->fonts = ret);
|
||||
}
|
||||
|
||||
void
|
||||
drw_fontset_free(Fnt *font)
|
||||
{
|
||||
if (font) {
|
||||
drw_fontset_free(font->next);
|
||||
xfont_free(font);
|
||||
}
|
||||
if (font) {
|
||||
drw_fontset_free(font->next);
|
||||
xfont_free(font);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
||||
{
|
||||
if (!drw || !dest || !clrname)
|
||||
return;
|
||||
if (!drw || !dest || !clrname)
|
||||
return;
|
||||
|
||||
if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
|
||||
DefaultColormap(drw->dpy, drw->screen),
|
||||
clrname, dest))
|
||||
die("error, cannot allocate color '%s'", clrname);
|
||||
if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
|
||||
DefaultColormap(drw->dpy, drw->screen),
|
||||
clrname, dest))
|
||||
die("error, cannot allocate color '%s'", clrname);
|
||||
|
||||
dest->pixel |= 0xff << 24;
|
||||
dest->pixel |= 0xff << 24;
|
||||
}
|
||||
|
||||
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
||||
|
@ -212,227 +212,227 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
|||
Clr *
|
||||
drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount)
|
||||
{
|
||||
size_t i;
|
||||
Clr *ret;
|
||||
size_t i;
|
||||
Clr *ret;
|
||||
|
||||
/* need at least two colors for a scheme */
|
||||
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor))))
|
||||
return NULL;
|
||||
/* need at least two colors for a scheme */
|
||||
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor))))
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < clrcount; i++)
|
||||
drw_clr_create(drw, &ret[i], clrnames[i]);
|
||||
return ret;
|
||||
for (i = 0; i < clrcount; i++)
|
||||
drw_clr_create(drw, &ret[i], clrnames[i]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
drw_setfontset(Drw *drw, Fnt *set)
|
||||
{
|
||||
if (drw)
|
||||
drw->fonts = set;
|
||||
if (drw)
|
||||
drw->fonts = set;
|
||||
}
|
||||
|
||||
void
|
||||
drw_setscheme(Drw *drw, Clr *scm)
|
||||
{
|
||||
if (drw)
|
||||
drw->scheme = scm;
|
||||
if (drw)
|
||||
drw->scheme = scm;
|
||||
}
|
||||
|
||||
void
|
||||
drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert)
|
||||
{
|
||||
if (!drw || !drw->scheme)
|
||||
return;
|
||||
XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme[ColBg].pixel : drw->scheme[ColFg].pixel);
|
||||
if (filled)
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||
else
|
||||
XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1);
|
||||
if (!drw || !drw->scheme)
|
||||
return;
|
||||
XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme[ColBg].pixel : drw->scheme[ColFg].pixel);
|
||||
if (filled)
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||
else
|
||||
XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1);
|
||||
}
|
||||
|
||||
int
|
||||
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
|
||||
{
|
||||
char buf[1024];
|
||||
int ty;
|
||||
unsigned int ew;
|
||||
XftDraw *d = NULL;
|
||||
Fnt *usedfont, *curfont, *nextfont;
|
||||
size_t i, len;
|
||||
int utf8strlen, utf8charlen, render = x || y || w || h;
|
||||
long utf8codepoint = 0;
|
||||
const char *utf8str;
|
||||
FcCharSet *fccharset;
|
||||
FcPattern *fcpattern;
|
||||
FcPattern *match;
|
||||
XftResult result;
|
||||
int charexists = 0;
|
||||
char buf[1024];
|
||||
int ty;
|
||||
unsigned int ew;
|
||||
XftDraw *d = NULL;
|
||||
Fnt *usedfont, *curfont, *nextfont;
|
||||
size_t i, len;
|
||||
int utf8strlen, utf8charlen, render = x || y || w || h;
|
||||
long utf8codepoint = 0;
|
||||
const char *utf8str;
|
||||
FcCharSet *fccharset;
|
||||
FcPattern *fcpattern;
|
||||
FcPattern *match;
|
||||
XftResult result;
|
||||
int charexists = 0;
|
||||
|
||||
if (!drw || (render && !drw->scheme) || !text || !drw->fonts)
|
||||
return 0;
|
||||
if (!drw || (render && !drw->scheme) || !text || !drw->fonts)
|
||||
return 0;
|
||||
|
||||
if (!render) {
|
||||
w = ~w;
|
||||
} else {
|
||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||
d = XftDrawCreate(drw->dpy, drw->drawable,
|
||||
DefaultVisual(drw->dpy, drw->screen),
|
||||
DefaultColormap(drw->dpy, drw->screen));
|
||||
x += lpad;
|
||||
w -= lpad;
|
||||
}
|
||||
if (!render) {
|
||||
w = ~w;
|
||||
} else {
|
||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||
d = XftDrawCreate(drw->dpy, drw->drawable,
|
||||
DefaultVisual(drw->dpy, drw->screen),
|
||||
DefaultColormap(drw->dpy, drw->screen));
|
||||
x += lpad;
|
||||
w -= lpad;
|
||||
}
|
||||
|
||||
usedfont = drw->fonts;
|
||||
while (1) {
|
||||
utf8strlen = 0;
|
||||
utf8str = text;
|
||||
nextfont = NULL;
|
||||
while (*text) {
|
||||
utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ);
|
||||
for (curfont = drw->fonts; curfont; curfont = curfont->next) {
|
||||
charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
|
||||
if (charexists) {
|
||||
if (curfont == usedfont) {
|
||||
utf8strlen += utf8charlen;
|
||||
text += utf8charlen;
|
||||
} else {
|
||||
nextfont = curfont;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
usedfont = drw->fonts;
|
||||
while (1) {
|
||||
utf8strlen = 0;
|
||||
utf8str = text;
|
||||
nextfont = NULL;
|
||||
while (*text) {
|
||||
utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ);
|
||||
for (curfont = drw->fonts; curfont; curfont = curfont->next) {
|
||||
charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
|
||||
if (charexists) {
|
||||
if (curfont == usedfont) {
|
||||
utf8strlen += utf8charlen;
|
||||
text += utf8charlen;
|
||||
} else {
|
||||
nextfont = curfont;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!charexists || nextfont)
|
||||
break;
|
||||
else
|
||||
charexists = 0;
|
||||
}
|
||||
if (!charexists || nextfont)
|
||||
break;
|
||||
else
|
||||
charexists = 0;
|
||||
}
|
||||
|
||||
if (utf8strlen) {
|
||||
drw_font_getexts(usedfont, utf8str, utf8strlen, &ew, NULL);
|
||||
/* shorten text if necessary */
|
||||
for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > w; len--)
|
||||
drw_font_getexts(usedfont, utf8str, len, &ew, NULL);
|
||||
if (utf8strlen) {
|
||||
drw_font_getexts(usedfont, utf8str, utf8strlen, &ew, NULL);
|
||||
/* shorten text if necessary */
|
||||
for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > w; len--)
|
||||
drw_font_getexts(usedfont, utf8str, len, &ew, NULL);
|
||||
|
||||
if (len) {
|
||||
memcpy(buf, utf8str, len);
|
||||
buf[len] = '\0';
|
||||
if (len < utf8strlen)
|
||||
for (i = len; i && i > len - 3; buf[--i] = '.')
|
||||
; /* NOP */
|
||||
if (len) {
|
||||
memcpy(buf, utf8str, len);
|
||||
buf[len] = '\0';
|
||||
if (len < utf8strlen)
|
||||
for (i = len; i && i > len - 3; buf[--i] = '.')
|
||||
; /* NOP */
|
||||
|
||||
if (render) {
|
||||
ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent;
|
||||
XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg],
|
||||
usedfont->xfont, x, ty, (XftChar8 *)buf, len);
|
||||
}
|
||||
x += ew;
|
||||
w -= ew;
|
||||
}
|
||||
}
|
||||
if (render) {
|
||||
ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent;
|
||||
XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg],
|
||||
usedfont->xfont, x, ty, (XftChar8 *)buf, len);
|
||||
}
|
||||
x += ew;
|
||||
w -= ew;
|
||||
}
|
||||
}
|
||||
|
||||
if (!*text) {
|
||||
break;
|
||||
} else if (nextfont) {
|
||||
charexists = 0;
|
||||
usedfont = nextfont;
|
||||
} else {
|
||||
/* Regardless of whether or not a fallback font is found, the
|
||||
* character must be drawn. */
|
||||
charexists = 1;
|
||||
if (!*text) {
|
||||
break;
|
||||
} else if (nextfont) {
|
||||
charexists = 0;
|
||||
usedfont = nextfont;
|
||||
} else {
|
||||
/* Regardless of whether or not a fallback font is found, the
|
||||
* character must be drawn. */
|
||||
charexists = 1;
|
||||
|
||||
fccharset = FcCharSetCreate();
|
||||
FcCharSetAddChar(fccharset, utf8codepoint);
|
||||
fccharset = FcCharSetCreate();
|
||||
FcCharSetAddChar(fccharset, utf8codepoint);
|
||||
|
||||
if (!drw->fonts->pattern) {
|
||||
/* Refer to the comment in xfont_create for more information. */
|
||||
die("the first font in the cache must be loaded from a font string.");
|
||||
}
|
||||
if (!drw->fonts->pattern) {
|
||||
/* Refer to the comment in xfont_create for more information. */
|
||||
die("the first font in the cache must be loaded from a font string.");
|
||||
}
|
||||
|
||||
fcpattern = FcPatternDuplicate(drw->fonts->pattern);
|
||||
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
|
||||
FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
|
||||
FcPatternAddBool(fcpattern, FC_COLOR, FcFalse);
|
||||
fcpattern = FcPatternDuplicate(drw->fonts->pattern);
|
||||
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
|
||||
FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
|
||||
FcPatternAddBool(fcpattern, FC_COLOR, FcFalse);
|
||||
|
||||
FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
|
||||
FcDefaultSubstitute(fcpattern);
|
||||
match = XftFontMatch(drw->dpy, drw->screen, fcpattern, &result);
|
||||
FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
|
||||
FcDefaultSubstitute(fcpattern);
|
||||
match = XftFontMatch(drw->dpy, drw->screen, fcpattern, &result);
|
||||
|
||||
FcCharSetDestroy(fccharset);
|
||||
FcPatternDestroy(fcpattern);
|
||||
FcCharSetDestroy(fccharset);
|
||||
FcPatternDestroy(fcpattern);
|
||||
|
||||
if (match) {
|
||||
usedfont = xfont_create(drw, NULL, match);
|
||||
if (usedfont && XftCharExists(drw->dpy, usedfont->xfont, utf8codepoint)) {
|
||||
for (curfont = drw->fonts; curfont->next; curfont = curfont->next)
|
||||
; /* NOP */
|
||||
curfont->next = usedfont;
|
||||
} else {
|
||||
xfont_free(usedfont);
|
||||
usedfont = drw->fonts;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (d)
|
||||
XftDrawDestroy(d);
|
||||
if (match) {
|
||||
usedfont = xfont_create(drw, NULL, match);
|
||||
if (usedfont && XftCharExists(drw->dpy, usedfont->xfont, utf8codepoint)) {
|
||||
for (curfont = drw->fonts; curfont->next; curfont = curfont->next)
|
||||
; /* NOP */
|
||||
curfont->next = usedfont;
|
||||
} else {
|
||||
xfont_free(usedfont);
|
||||
usedfont = drw->fonts;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (d)
|
||||
XftDrawDestroy(d);
|
||||
|
||||
return x + (render ? w : 0);
|
||||
return x + (render ? w : 0);
|
||||
}
|
||||
|
||||
void
|
||||
drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)
|
||||
{
|
||||
if (!drw)
|
||||
return;
|
||||
if (!drw)
|
||||
return;
|
||||
|
||||
XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y);
|
||||
XSync(drw->dpy, False);
|
||||
XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y);
|
||||
XSync(drw->dpy, False);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
drw_fontset_getwidth(Drw *drw, const char *text)
|
||||
{
|
||||
if (!drw || !drw->fonts || !text)
|
||||
return 0;
|
||||
return drw_text(drw, 0, 0, 0, 0, 0, text, 0);
|
||||
if (!drw || !drw->fonts || !text)
|
||||
return 0;
|
||||
return drw_text(drw, 0, 0, 0, 0, 0, text, 0);
|
||||
}
|
||||
|
||||
void
|
||||
drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h)
|
||||
{
|
||||
XGlyphInfo ext;
|
||||
XGlyphInfo ext;
|
||||
|
||||
if (!font || !text)
|
||||
return;
|
||||
if (!font || !text)
|
||||
return;
|
||||
|
||||
XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)text, len, &ext);
|
||||
if (w)
|
||||
*w = ext.xOff;
|
||||
if (h)
|
||||
*h = font->h;
|
||||
XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)text, len, &ext);
|
||||
if (w)
|
||||
*w = ext.xOff;
|
||||
if (h)
|
||||
*h = font->h;
|
||||
}
|
||||
|
||||
Cur *
|
||||
drw_cur_create(Drw *drw, int shape)
|
||||
{
|
||||
Cur *cur;
|
||||
Cur *cur;
|
||||
|
||||
if (!drw || !(cur = ecalloc(1, sizeof(Cur))))
|
||||
return NULL;
|
||||
if (!drw || !(cur = ecalloc(1, sizeof(Cur))))
|
||||
return NULL;
|
||||
|
||||
cur->cursor = XCreateFontCursor(drw->dpy, shape);
|
||||
cur->cursor = XCreateFontCursor(drw->dpy, shape);
|
||||
|
||||
return cur;
|
||||
return cur;
|
||||
}
|
||||
|
||||
void
|
||||
drw_cur_free(Drw *drw, Cur *cursor)
|
||||
{
|
||||
if (!cursor)
|
||||
return;
|
||||
if (!cursor)
|
||||
return;
|
||||
|
||||
XFreeCursor(drw->dpy, cursor->cursor);
|
||||
free(cursor);
|
||||
XFreeCursor(drw->dpy, cursor->cursor);
|
||||
free(cursor);
|
||||
}
|
||||
|
|
28
drw.h
28
drw.h
|
@ -1,29 +1,29 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
typedef struct {
|
||||
Cursor cursor;
|
||||
Cursor cursor;
|
||||
} Cur;
|
||||
|
||||
typedef struct Fnt {
|
||||
Display *dpy;
|
||||
unsigned int h;
|
||||
XftFont *xfont;
|
||||
FcPattern *pattern;
|
||||
struct Fnt *next;
|
||||
Display *dpy;
|
||||
unsigned int h;
|
||||
XftFont *xfont;
|
||||
FcPattern *pattern;
|
||||
struct Fnt *next;
|
||||
} Fnt;
|
||||
|
||||
enum { ColFg, ColBg, ColBorder }; /* Clr scheme index */
|
||||
typedef XftColor Clr;
|
||||
|
||||
typedef struct {
|
||||
unsigned int w, h;
|
||||
Display *dpy;
|
||||
int screen;
|
||||
Window root;
|
||||
Drawable drawable;
|
||||
GC gc;
|
||||
Clr *scheme;
|
||||
Fnt *fonts;
|
||||
unsigned int w, h;
|
||||
Display *dpy;
|
||||
int screen;
|
||||
Window root;
|
||||
Drawable drawable;
|
||||
GC gc;
|
||||
Clr *scheme;
|
||||
Fnt *fonts;
|
||||
} Drw;
|
||||
|
||||
/* Drawable abstraction */
|
||||
|
|
124
dwm.c
124
dwm.c
|
@ -2674,34 +2674,34 @@ pid_t
|
|||
winpid(Window w)
|
||||
{
|
||||
|
||||
pid_t result = 0;
|
||||
pid_t result = 0;
|
||||
|
||||
#ifdef __linux__
|
||||
xcb_res_client_id_spec_t spec = {0};
|
||||
spec.client = w;
|
||||
spec.mask = XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID;
|
||||
xcb_res_client_id_spec_t spec = {0};
|
||||
spec.client = w;
|
||||
spec.mask = XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID;
|
||||
|
||||
xcb_generic_error_t *e = NULL;
|
||||
xcb_res_query_client_ids_cookie_t c = xcb_res_query_client_ids(xcon, 1, &spec);
|
||||
xcb_res_query_client_ids_reply_t *r = xcb_res_query_client_ids_reply(xcon, c, &e);
|
||||
xcb_generic_error_t *e = NULL;
|
||||
xcb_res_query_client_ids_cookie_t c = xcb_res_query_client_ids(xcon, 1, &spec);
|
||||
xcb_res_query_client_ids_reply_t *r = xcb_res_query_client_ids_reply(xcon, c, &e);
|
||||
|
||||
if (!r)
|
||||
return (pid_t)0;
|
||||
if (!r)
|
||||
return (pid_t)0;
|
||||
|
||||
xcb_res_client_id_value_iterator_t i = xcb_res_query_client_ids_ids_iterator(r);
|
||||
for (; i.rem; xcb_res_client_id_value_next(&i)) {
|
||||
spec = i.data->spec;
|
||||
if (spec.mask & XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID) {
|
||||
uint32_t *t = xcb_res_client_id_value_value(i.data);
|
||||
result = *t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
xcb_res_client_id_value_iterator_t i = xcb_res_query_client_ids_ids_iterator(r);
|
||||
for (; i.rem; xcb_res_client_id_value_next(&i)) {
|
||||
spec = i.data->spec;
|
||||
if (spec.mask & XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID) {
|
||||
uint32_t *t = xcb_res_client_id_value_value(i.data);
|
||||
result = *t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free(r);
|
||||
free(r);
|
||||
|
||||
if (result == (pid_t)-1)
|
||||
result = 0;
|
||||
if (result == (pid_t)-1)
|
||||
result = 0;
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
||||
|
@ -2720,84 +2720,84 @@ winpid(Window w)
|
|||
result = ret;
|
||||
|
||||
#endif /* __OpenBSD__ */
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
pid_t
|
||||
getparentprocess(pid_t p)
|
||||
{
|
||||
unsigned int v = 0;
|
||||
unsigned int v = 0;
|
||||
|
||||
#ifdef __linux__
|
||||
FILE *f;
|
||||
char buf[256];
|
||||
snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (unsigned)p);
|
||||
FILE *f;
|
||||
char buf[256];
|
||||
snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (unsigned)p);
|
||||
|
||||
if (!(f = fopen(buf, "r")))
|
||||
return 0;
|
||||
if (!(f = fopen(buf, "r")))
|
||||
return 0;
|
||||
|
||||
fscanf(f, "%*u %*s %*c %u", &v);
|
||||
fclose(f);
|
||||
fscanf(f, "%*u %*s %*c %u", &v);
|
||||
fclose(f);
|
||||
#endif /* __linux__*/
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
int n;
|
||||
kvm_t *kd;
|
||||
struct kinfo_proc *kp;
|
||||
int n;
|
||||
kvm_t *kd;
|
||||
struct kinfo_proc *kp;
|
||||
|
||||
kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, NULL);
|
||||
if (!kd)
|
||||
return 0;
|
||||
kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, NULL);
|
||||
if (!kd)
|
||||
return 0;
|
||||
|
||||
kp = kvm_getprocs(kd, KERN_PROC_PID, p, sizeof(*kp), &n);
|
||||
v = kp->p_ppid;
|
||||
kp = kvm_getprocs(kd, KERN_PROC_PID, p, sizeof(*kp), &n);
|
||||
v = kp->p_ppid;
|
||||
#endif /* __OpenBSD__ */
|
||||
|
||||
return (pid_t)v;
|
||||
return (pid_t)v;
|
||||
}
|
||||
|
||||
int
|
||||
isdescprocess(pid_t p, pid_t c)
|
||||
{
|
||||
while (p != c && c != 0)
|
||||
c = getparentprocess(c);
|
||||
while (p != c && c != 0)
|
||||
c = getparentprocess(c);
|
||||
|
||||
return (int)c;
|
||||
return (int)c;
|
||||
}
|
||||
|
||||
Client *
|
||||
termforwin(const Client *w)
|
||||
{
|
||||
Client *c;
|
||||
Monitor *m;
|
||||
Client *c;
|
||||
Monitor *m;
|
||||
|
||||
if (!w->pid || w->isterminal)
|
||||
return NULL;
|
||||
if (!w->pid || w->isterminal)
|
||||
return NULL;
|
||||
|
||||
for (m = mons; m; m = m->next) {
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
if (c->isterminal && !c->swallowing && c->pid && isdescprocess(c->pid, w->pid))
|
||||
return c;
|
||||
}
|
||||
}
|
||||
for (m = mons; m; m = m->next) {
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
if (c->isterminal && !c->swallowing && c->pid && isdescprocess(c->pid, w->pid))
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Client *
|
||||
swallowingclient(Window w)
|
||||
{
|
||||
Client *c;
|
||||
Monitor *m;
|
||||
Client *c;
|
||||
Monitor *m;
|
||||
|
||||
for (m = mons; m; m = m->next) {
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
if (c->swallowing && c->swallowing->win == w)
|
||||
return c;
|
||||
}
|
||||
}
|
||||
for (m = mons; m; m = m->next) {
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
if (c->swallowing && c->swallowing->win == w)
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* There's no way to check accesses to destroyed windows, thus those cases are
|
||||
|
|
56
transient.c
56
transient.c
|
@ -6,37 +6,37 @@
|
|||
#include <X11/Xutil.h>
|
||||
|
||||
int main(void) {
|
||||
Display *d;
|
||||
Window r, f, t = None;
|
||||
XSizeHints h;
|
||||
XEvent e;
|
||||
Display *d;
|
||||
Window r, f, t = None;
|
||||
XSizeHints h;
|
||||
XEvent e;
|
||||
|
||||
d = XOpenDisplay(NULL);
|
||||
if (!d)
|
||||
exit(1);
|
||||
r = DefaultRootWindow(d);
|
||||
d = XOpenDisplay(NULL);
|
||||
if (!d)
|
||||
exit(1);
|
||||
r = DefaultRootWindow(d);
|
||||
|
||||
f = XCreateSimpleWindow(d, r, 100, 100, 400, 400, 0, 0, 0);
|
||||
h.min_width = h.max_width = h.min_height = h.max_height = 400;
|
||||
h.flags = PMinSize | PMaxSize;
|
||||
XSetWMNormalHints(d, f, &h);
|
||||
XStoreName(d, f, "floating");
|
||||
XMapWindow(d, f);
|
||||
f = XCreateSimpleWindow(d, r, 100, 100, 400, 400, 0, 0, 0);
|
||||
h.min_width = h.max_width = h.min_height = h.max_height = 400;
|
||||
h.flags = PMinSize | PMaxSize;
|
||||
XSetWMNormalHints(d, f, &h);
|
||||
XStoreName(d, f, "floating");
|
||||
XMapWindow(d, f);
|
||||
|
||||
XSelectInput(d, f, ExposureMask);
|
||||
while (1) {
|
||||
XNextEvent(d, &e);
|
||||
XSelectInput(d, f, ExposureMask);
|
||||
while (1) {
|
||||
XNextEvent(d, &e);
|
||||
|
||||
if (t == None) {
|
||||
sleep(5);
|
||||
t = XCreateSimpleWindow(d, r, 50, 50, 100, 100, 0, 0, 0);
|
||||
XSetTransientForHint(d, t, f);
|
||||
XStoreName(d, t, "transient");
|
||||
XMapWindow(d, t);
|
||||
XSelectInput(d, t, ExposureMask);
|
||||
}
|
||||
}
|
||||
if (t == None) {
|
||||
sleep(5);
|
||||
t = XCreateSimpleWindow(d, r, 50, 50, 100, 100, 0, 0, 0);
|
||||
XSetTransientForHint(d, t, f);
|
||||
XStoreName(d, t, "transient");
|
||||
XMapWindow(d, t);
|
||||
XSelectInput(d, t, ExposureMask);
|
||||
}
|
||||
}
|
||||
|
||||
XCloseDisplay(d);
|
||||
exit(0);
|
||||
XCloseDisplay(d);
|
||||
exit(0);
|
||||
}
|
||||
|
|
30
util.c
30
util.c
|
@ -9,27 +9,27 @@
|
|||
void *
|
||||
ecalloc(size_t nmemb, size_t size)
|
||||
{
|
||||
void *p;
|
||||
void *p;
|
||||
|
||||
if (!(p = calloc(nmemb, size)))
|
||||
die("calloc:");
|
||||
return p;
|
||||
if (!(p = calloc(nmemb, size)))
|
||||
die("calloc:");
|
||||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
die(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
|
||||
fputc(' ', stderr);
|
||||
perror(NULL);
|
||||
} else {
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
|
||||
fputc(' ', stderr);
|
||||
perror(NULL);
|
||||
} else {
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
|
||||
exit(1);
|
||||
exit(1);
|
||||
}
|
||||
|
|
1096
vanitygaps.c
1096
vanitygaps.c
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue