dwm

dwm

https://git.tonybtw.com/dwm.git git://git.tonybtw.com/dwm.git
11,811 bytes raw
1
/* See LICENSE file for copyright and license details. */
2
#include <X11/XF86keysym.h>
3
4
/* appearance */
5
static const unsigned int borderpx  = 2;        /* border pixel of windows */
6
static const unsigned int snap      = 32;       /* snap pixel */
7
/*defaults= 20, 10, 10, 30 */
8
static const unsigned int gappih    = 3;       /* horiz inner gap between windows */
9
static const unsigned int gappiv    = 3;       /* vert inner gap between windows */
10
static const unsigned int gappoh    = 3;       /* horiz outer gap between windows and screen edge */
11
static const unsigned int gappov    = 3;       /* vert outer gap between windows and screen edge */
12
static       int smartgaps          = 0;        /* 1 means no outer gap when there is only one window */
13
static const int showbar            = 1;        /* 0 means no bar */
14
static const int topbar             = 1;        /* 0 means bottom bar */
15
static const char *fonts[] = {
16
    "JetBrainsMono Nerd Font Mono:style=Bold:size=16",
17
};
18
static const char dmenufont[]       = "JetBrainsMono Nerd Font Mono:style=Bold:size=16";
19
static const char col_gray1[]       = "#000000";
20
static const char col_gray2[]       = "#444444";
21
static const char col_gray3[]       = "#bbbbbb";
22
static const char col_gray4[]       = "#eeeeee";
23
static const char col_cyan[]        = "#4d6a8e";
24
25
/* TokyoNight colors */
26
static const char col_bg[]     = "#1a1b26";  // background
27
static const char col_fg[]     = "#a9b1d6";  // foreground
28
static const char col_blk[]    = "#32344a";  // black (normal)
29
static const char col_red[]    = "#f7768e";  // red
30
static const char col_grn[]    = "#9ece6a";  // green
31
static const char col_ylw[]    = "#e0af68";  // yellow
32
static const char col_blu[]    = "#7aa2f7";  // blue
33
static const char col_mag[]    = "#ad8ee6";  // magenta
34
static const char col_cyn[]    = "#0db9d7";  // cyan (highlight)
35
static const char col_brblk[]  = "#444b6a";  // bright black
36
37
static const char *colors[][3] = {
38
    /*               fg       bg       border */
39
    [SchemeNorm] = { col_fg,  col_bg,   col_brblk },
40
    [SchemeSel]  = { col_cyn, col_bg,   col_mag   },
41
};
42
43
/* tagging */
44
/* static const char *tags[] = { "", "󰊯", "", "", "󰙯", "󱇤", "", "󱘶", "󰧮" }; */
45
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
46
47
static const Rule rules[] = {
48
	/* xprop(1):
49
	 *	WM_CLASS(STRING) = instance, class
50
	 *	WM_NAME(STRING) = title
51
	 */
52
	/* class            instance    title       tags mask     isfloating   monitor */
53
	{ "Gimp",            NULL,       NULL,       0,            1,           -1 },
54
    { "Google-chrome",   NULL,       NULL,       1 << 1,       0,           -1 },
55
    { "Brave-browser",   NULL,       NULL,       1 << 1,       0,           -1 },
56
	{ "firefox",         NULL,       NULL,       1 << 2,       0,           -1 },
57
	{ "Slack",           NULL,       NULL,       1 << 3,       0,           -1 },
58
	{ "discord",         NULL,       NULL,       1 << 4,       0,           -1 },
59
	{ "kdenlive",        NULL,       NULL,       1 << 7,       0,           -1 },
60
};
61
62
/* layout(s) */
63
static const float mfact     = 0.55; /* factor of master area size [0.05..0.95] */
64
static const int nmaster     = 1;    /* number of clients in master area */
65
static const int resizehints = 1;    /* 1 means respect size hints in tiled resizals */
66
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
67
68
#define FORCE_VSPLIT 1  /* nrowgrid layout: force two clients to always split vertically */
69
#include "vanitygaps.c"
70
/*#include "fibonacci.c"*/
71
72
static const Layout layouts[] = {
73
	/* symbol     arrange function */
74
	{ "󰝘",        tile },    /* first entry is default */
75
	{ "",        NULL },    /* no layout function means floating behavior */
76
	{ "[M]",      monocle },
77
 	{ "",        spiral },
78
 	{ "[\\]",     dwindle },
79
};
80
81
/* key definitions */
82
#define MODKEY Mod4Mask
83
#define TAGKEYS(KEY,TAG)                                                                                               \
84
       &((Keychord){1, {{MODKEY, KEY}},                                        view,           {.ui = 1 << TAG} }), \
85
       &((Keychord){1, {{MODKEY|ControlMask, KEY}},                            toggleview,     {.ui = 1 << TAG} }), \
86
       &((Keychord){1, {{MODKEY|ShiftMask, KEY}},                              tag,            {.ui = 1 << TAG} }), \
87
       &((Keychord){1, {{MODKEY|ControlMask|ShiftMask, KEY}},                  toggletag,      {.ui = 1 << TAG} }),
88
89
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
90
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
91
92
/* commands */
93
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
94
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
95
static const char *termcmd[]  = { "st", NULL };
96
static const char *firefoxcmd[]  = { "firefox-bin", NULL };
97
static const char *slock[]    = { "slock", NULL };
98
static const char *screenshotcmd[] = { "/bin/sh", "-c", "maim -s | xclip -selection clipboard -t image/png", NULL };
99
static const char *rofi[]  = { "rofi", "-show", "drun", "-theme", "~/.config/rofi/config.rasi", NULL };
100
static const char *emacsclient[]  = { "emacsclient", "-c", "-a", "", NULL };
101
102
static Keychord *keychords[] = {
103
    /* key count, modifier/key sequence,            function,        argument */
104
105
    &((Keychord){1, {{MODKEY, XK_r}},               spawn,          {.v = dmenucmd } }),
106
    &((Keychord){1, {{MODKEY, XK_Return}},          spawn,          {.v = termcmd } }),
107
    &((Keychord){1, {{MODKEY, XK_l}},               spawn,          {.v = slock } }),
108
    &((Keychord){1, {{ControlMask, XK_Print}},      spawn,          {.v = screenshotcmd } }),
109
    &((Keychord){1, {{MODKEY, XK_d}},               spawn,          {.v = rofi } }),
110
111
    &((Keychord){1, {{MODKEY, XK_b}},               togglebar,      {0} }),
112
    &((Keychord){1, {{MODKEY, XK_j}},               focusstack,     {.i = +1 } }),
113
    &((Keychord){1, {{MODKEY, XK_k}},               focusstack,     {.i = -1 } }),
114
    &((Keychord){1, {{MODKEY, XK_i}},               incnmaster,     {.i = +1 } }),
115
    &((Keychord){1, {{MODKEY, XK_p}},               incnmaster,     {.i = -1 } }),
116
    &((Keychord){1, {{MODKEY, XK_g}},               setmfact,       {.f = -0.05} }),
117
    &((Keychord){1, {{MODKEY, XK_h}},               setmfact,       {.f = +0.05} }),
118
119
    &((Keychord){1, {{MODKEY, XK_z}},               incrgaps,       {.i = +3 } }),
120
    &((Keychord){1, {{MODKEY, XK_x}},               incrgaps,       {.i = -3 } }),
121
    &((Keychord){1, {{MODKEY, XK_a}},               togglegaps,     {0} }),
122
    &((Keychord){1, {{MODKEY|ShiftMask, XK_a}},     defaultgaps,    {0} }),
123
124
    &((Keychord){1, {{MODKEY, XK_Tab}},             view,           {0} }),
125
    &((Keychord){1, {{MODKEY, XK_q}},               killclient,     {0} }),
126
127
    &((Keychord){1, {{MODKEY|ShiftMask, XK_t}},     setlayout,      {.v = &layouts[0]} }),
128
    // &((Keychord){1, {{MODKEY, XK_f}},               setlayout,      {.v = &layouts[1]} }),
129
    &((Keychord){1, {{MODKEY, XK_m}},               setlayout,      {.v = &layouts[2]} }),
130
    &((Keychord){1, {{MODKEY, XK_c}},               setlayout,      {.v = &layouts[3]} }),
131
    &((Keychord){1, {{MODKEY, XK_o}},               setlayout,      {.v = &layouts[4]} }),
132
    &((Keychord){1, {{MODKEY|ShiftMask, XK_Return}},setlayout,      {0} }),
133
134
    &((Keychord){1, {{MODKEY|ShiftMask, XK_f}},     fullscreen,     {0} }),
135
    &((Keychord){1, {{MODKEY|ShiftMask, XK_space}}, togglefloating, {0} }),
136
137
    &((Keychord){1, {{MODKEY, XK_0}},               view,           {.ui = ~0 } }),
138
    &((Keychord){1, {{MODKEY|ShiftMask, XK_0}},     tag,            {.ui = ~0 } }),
139
140
    &((Keychord){1, {{MODKEY, XK_comma}},           focusmon,       {.i = -1 } }),
141
    &((Keychord){1, {{MODKEY, XK_period}},          focusmon,       {.i = +1 } }),
142
    &((Keychord){1, {{MODKEY|ShiftMask, XK_comma}}, tagmon,         {.i = -1 } }),
143
    &((Keychord){1, {{MODKEY|ShiftMask, XK_period}},tagmon,         {.i = +1 } }),
144
    &((Keychord){2, {{MODKEY, XK_space}, {0, XK_f}}, spawn, {.v = (const char*[]){"firefox", NULL}} }),
145
146
    // Keychords for navigating to tags (small hands/emacs pinky)
147
    &((Keychord){2, {{MODKEY, XK_space}, {0, XK_1}}, view, {.ui = 1 << 0} }),
148
    &((Keychord){2, {{MODKEY, XK_space}, {0, XK_2}}, view, {.ui = 1 << 1} }),
149
    &((Keychord){2, {{MODKEY, XK_space}, {0, XK_3}}, view, {.ui = 1 << 2} }),
150
    &((Keychord){2, {{MODKEY, XK_space}, {0, XK_4}}, view, {.ui = 1 << 3} }),
151
    &((Keychord){2, {{MODKEY, XK_space}, {0, XK_5}}, view, {.ui = 1 << 4} }),
152
    &((Keychord){2, {{MODKEY, XK_space}, {0, XK_6}}, view, {.ui = 1 << 5} }),
153
    &((Keychord){2, {{MODKEY, XK_space}, {0, XK_7}}, view, {.ui = 1 << 6} }),
154
    &((Keychord){2, {{MODKEY, XK_space}, {0, XK_8}}, view, {.ui = 1 << 7} }),
155
    &((Keychord){2, {{MODKEY, XK_space}, {0, XK_9}}, view, {.ui = 1 << 8} }),
156
157
    // Dmenu Scripts
158
    &((Keychord){2, {{MODKEY, XK_f}, {0, XK_f}}, spawn, SHCMD("$HOME/repos/dmenu-scripts/repos-dmenu.sh")}),
159
    &((Keychord){2, {{MODKEY, XK_f}, {0, XK_o}}, spawn, SHCMD("$HOME/repos/dmenu-scripts/tmux-dmenu.sh")}),
160
    &((Keychord){2, {{MODKEY, XK_f}, {0, XK_b}}, spawn, SHCMD("$HOME/repos/dmenu-scripts/bookmarks-dmenu.sh")}),
161
    
162
    // Emacs Scripts
163
    // &((Keychord){2, {{MODKEY, XK_e}, {0, XK_t}}, spawn, SHCMD("$HOME/scripts/tmux-dmenu.sh")}),
164
    // &((Keychord){2, {{MODKEY, XK_e}, {0, XK_a}}, spawn, SHCMD("$HOME/scripts/tmux-dmenu.sh")}),
165
    // &((Keychord){2, {{MODKEY, XK_e}, {0, XK_t}}, spawn, SHCMD("$HOME/scripts/tmux-dmenu.sh")}),
166
167
    // TAGKEYS
168
    TAGKEYS(                        XK_1,                      0)
169
    TAGKEYS(                        XK_2,                      1)
170
    TAGKEYS(                        XK_3,                      2)
171
    TAGKEYS(                        XK_4,                      3)
172
    TAGKEYS(                        XK_5,                      4)
173
    TAGKEYS(                        XK_6,                      5)
174
    TAGKEYS(                        XK_7,                      6)
175
    TAGKEYS(                        XK_8,                      7)
176
    TAGKEYS(                        XK_9,                      8)
177
178
    &((Keychord){1, {{MODKEY|ShiftMask,   XK_q}},   quit,           {0} }),
179
    &((Keychord){1, {{MODKEY|ControlMask, XK_r}},   quit,           {1} }),
180
181
    &((Keychord){1, {{0, XF86XK_AudioRaiseVolume}}, spawn, {.v = (const char*[]){"pactl", "set-sink-volume", "@DEFAULT_SINK@", "+3%", NULL} } }),
182
    &((Keychord){1, {{0, XF86XK_AudioLowerVolume}}, spawn, {.v = (const char*[]){"pactl", "set-sink-volume", "@DEFAULT_SINK@", "-3%", NULL} } }),
183
};
184
185
186
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
187
static const Button buttons[] = {
188
	/* click                event mask      button          function        argument */
189
	{ ClkLtSymbol,          0,              Button1,        setlayout,      {0} },
190
	{ ClkLtSymbol,          0,              Button3,        setlayout,      {.v = &layouts[2]} },
191
	{ ClkStatusText,        0,              Button2,        spawn,          {.v = termcmd } },
192
	{ ClkClientWin,         MODKEY,         Button1,        movemouse,      {0} },
193
	{ ClkClientWin,         MODKEY,         Button2,        togglefloating, {0} },
194
	{ ClkClientWin,         MODKEY,         Button3,        resizemouse,    {0} },
195
	{ ClkTagBar,            0,              Button1,        view,           {0} },
196
	{ ClkTagBar,            0,              Button3,        toggleview,     {0} },
197
	{ ClkTagBar,            MODKEY,         Button1,        tag,            {0} },
198
	{ ClkTagBar,            MODKEY,         Button3,        toggletag,      {0} },
199
};