mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-07-04 15:23:03 +02:00
250 lines
13 KiB
C
250 lines
13 KiB
C
|
|
/* dwm config.h — generated by setup_dwm.sh to mirror an i3 setup.
|
||
|
|
*
|
||
|
|
* NOTE ON THE FOCUS MODEL: dwm is master/stack, not a tree like i3, so there is
|
||
|
|
* no true 2-D directional focus. The closest familiar mapping is used:
|
||
|
|
* Mod+j / Mod+k -> focus next / previous window in the stack
|
||
|
|
* Mod+Shift+j / +k -> move the focused window down / up the stack
|
||
|
|
* Mod+h / Mod+l -> shrink / grow the master area (i3's resize mode)
|
||
|
|
* Mod+Return -> open terminator (i3: same)
|
||
|
|
* Mod+Shift+Return -> promote window to master (zoom; dwm idiom, no i3 eq)
|
||
|
|
* Everything that carries muscle memory (Mod4, Mod+d dmenu, Mod+1..0 tags,
|
||
|
|
* Mod+Shift+q kill, Mod+Shift+e exit, Mod+f fullscreen) is mirrored exactly.
|
||
|
|
*/
|
||
|
|
|
||
|
|
#include <X11/XF86keysym.h>
|
||
|
|
|
||
|
|
/* ---- appearance --------------------------------------------------------- */
|
||
|
|
static const unsigned int borderpx = 2; /* 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 = 0; /* 0 = bottom bar (matches the request) */
|
||
|
|
static const char *fonts[] = { "monospace:size=10" };
|
||
|
|
|
||
|
|
/* Dracula palette, matching the i3 config */
|
||
|
|
static const char col_bg[] = "#282A36"; /* background */
|
||
|
|
static const char col_fg[] = "#F8F8F2"; /* foreground (active) */
|
||
|
|
static const char col_inactive[] = "#BFBFBF"; /* foreground (idle) */
|
||
|
|
static const char col_accent[] = "#6272A4"; /* focused accent */
|
||
|
|
static const char *colors[][3] = {
|
||
|
|
/* fg bg border */
|
||
|
|
[SchemeNorm] = { col_inactive, col_bg, col_bg },
|
||
|
|
[SchemeSel] = { col_fg, col_accent, col_accent },
|
||
|
|
};
|
||
|
|
|
||
|
|
/* ---- tagging (10 tags == i3's 10 workspaces) ---------------------------- */
|
||
|
|
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" };
|
||
|
|
|
||
|
|
static const Rule rules[] = {
|
||
|
|
/* class instance title tags mask isfloating monitor */
|
||
|
|
/* dwm needs >=1 rule (zero-length arrays are illegal in C). Gimp is the
|
||
|
|
* canonical harmless example — add your own with `xprop` to find a class. */
|
||
|
|
{ "Gimp", NULL, NULL, 0, 1, -1 },
|
||
|
|
};
|
||
|
|
|
||
|
|
/* ---- layout(s) ---------------------------------------------------------- */
|
||
|
|
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
||
|
|
static const int nmaster = 1; /* number of clients in master area */
|
||
|
|
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
||
|
|
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||
|
|
|
||
|
|
static const Layout layouts[] = {
|
||
|
|
/* symbol arrange function */
|
||
|
|
{ "[]=", tile }, /* first entry is default */
|
||
|
|
{ "><>", NULL }, /* no layout function means floating behaviour */
|
||
|
|
{ "[M]", monocle },
|
||
|
|
};
|
||
|
|
|
||
|
|
/* ---- key definitions ---------------------------------------------------- */
|
||
|
|
#define MODKEY Mod4Mask /* Super, matching the i3 `set $mod Mod4` */
|
||
|
|
#define TAGKEYS(KEY,TAG) \
|
||
|
|
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||
|
|
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||
|
|
{ MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
|
||
|
|
{ MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
|
||
|
|
|
||
|
|
/* helper for commands that need a shell (pipes, &&, env vars) */
|
||
|
|
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||
|
|
|
||
|
|
/* ---- extra behaviours (defined here so dwm.c stays untouched) ----------- */
|
||
|
|
|
||
|
|
/* movestack: shift the focused window up/down the client stack (i3-like move) */
|
||
|
|
static void
|
||
|
|
movestack(const Arg *arg)
|
||
|
|
{
|
||
|
|
Client *c = NULL, *p = NULL, *pc = NULL, *i;
|
||
|
|
|
||
|
|
if (arg->i > 0) {
|
||
|
|
/* find the client after selmon->sel */
|
||
|
|
for (c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
|
||
|
|
if (!c)
|
||
|
|
for (c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
|
||
|
|
} else {
|
||
|
|
/* find the client before selmon->sel */
|
||
|
|
for (i = selmon->clients; i != selmon->sel; i = i->next)
|
||
|
|
if (ISVISIBLE(i) && !i->isfloating)
|
||
|
|
c = i;
|
||
|
|
if (!c)
|
||
|
|
for (; i; i = i->next)
|
||
|
|
if (ISVISIBLE(i) && !i->isfloating)
|
||
|
|
c = i;
|
||
|
|
}
|
||
|
|
/* find the client before selmon->sel and c */
|
||
|
|
for (i = selmon->clients; i && (!p || !pc); i = i->next) {
|
||
|
|
if (i->next == selmon->sel)
|
||
|
|
p = i;
|
||
|
|
if (i->next == c)
|
||
|
|
pc = i;
|
||
|
|
}
|
||
|
|
|
||
|
|
/* swap c and selmon->sel in the selmon->clients list */
|
||
|
|
if (c && c != selmon->sel) {
|
||
|
|
Client *temp = selmon->sel->next == c ? selmon->sel : selmon->sel->next;
|
||
|
|
selmon->sel->next = c->next == selmon->sel ? c : c->next;
|
||
|
|
c->next = temp;
|
||
|
|
|
||
|
|
if (p && p != c)
|
||
|
|
p->next = c;
|
||
|
|
if (pc && pc != selmon->sel)
|
||
|
|
pc->next = selmon->sel;
|
||
|
|
|
||
|
|
if (selmon->sel == selmon->clients)
|
||
|
|
selmon->clients = c;
|
||
|
|
else if (c == selmon->clients)
|
||
|
|
selmon->clients = selmon->sel;
|
||
|
|
|
||
|
|
arrange(selmon);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/* togglefullscr: true fullscreen for the focused window (i3's Mod+f) */
|
||
|
|
static void
|
||
|
|
togglefullscr(const Arg *arg)
|
||
|
|
{
|
||
|
|
(void)arg;
|
||
|
|
if (selmon->sel)
|
||
|
|
setfullscreen(selmon->sel, !selmon->sel->isfullscreen);
|
||
|
|
}
|
||
|
|
|
||
|
|
/* ---- spawn commands ----------------------------------------------------- */
|
||
|
|
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
|
||
|
|
static const char *dmenucmd[] = {
|
||
|
|
"dmenu_run", "-m", dmenumon,
|
||
|
|
"-nf", "#F8F8F2", "-nb", "#282A36", "-sb", "#6272A4", "-sf", "#F8F8F2",
|
||
|
|
"-fn", "monospace-10", "-p", "dmenu%", NULL
|
||
|
|
};
|
||
|
|
static const char *termcmd[] = { "terminator", NULL };
|
||
|
|
static const char *rebuildcmd[] = { "terminator", "-T", "dwm-rebuild", "-e", "dwm-rebuild", NULL };
|
||
|
|
/* panic key: force-release the auto fullscreen pointer-lock if it ever sticks */
|
||
|
|
static const char *pconfoffcmd[] = { "pconfine-auto", "off", NULL };
|
||
|
|
|
||
|
|
static const Key keys[] = {
|
||
|
|
/* modifier key function argument */
|
||
|
|
{ MODKEY, XK_d, spawn, {.v = dmenucmd } },
|
||
|
|
{ MODKEY, XK_Return, spawn, {.v = termcmd } },
|
||
|
|
|
||
|
|
/* focus the stack (see header note on the master/stack model) */
|
||
|
|
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||
|
|
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||
|
|
{ MODKEY, XK_Down, focusstack, {.i = +1 } },
|
||
|
|
{ MODKEY, XK_Up, focusstack, {.i = -1 } },
|
||
|
|
|
||
|
|
/* move the focused window within the stack (i3-like Mod+Shift+dir) */
|
||
|
|
{ MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } },
|
||
|
|
{ MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } },
|
||
|
|
{ MODKEY|ShiftMask, XK_Down, movestack, {.i = +1 } },
|
||
|
|
{ MODKEY|ShiftMask, XK_Up, movestack, {.i = -1 } },
|
||
|
|
|
||
|
|
/* resize the master area (i3's resize mode, without the mode) */
|
||
|
|
{ MODKEY, XK_h, setmfact, {.f = -0.05 } },
|
||
|
|
{ MODKEY, XK_l, setmfact, {.f = +0.05 } },
|
||
|
|
{ MODKEY, XK_Left, setmfact, {.f = -0.05 } },
|
||
|
|
{ MODKEY, XK_Right, setmfact, {.f = +0.05 } },
|
||
|
|
|
||
|
|
/* number of windows in the master area */
|
||
|
|
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||
|
|
{ MODKEY|ShiftMask, XK_i, incnmaster, {.i = -1 } },
|
||
|
|
|
||
|
|
/* promote focused window to master (dwm zoom) */
|
||
|
|
{ MODKEY|ShiftMask, XK_Return, zoom, {0} },
|
||
|
|
|
||
|
|
/* fullscreen + floating (mirror i3's Mod+f and Mod+Shift+space) */
|
||
|
|
{ MODKEY, XK_f, togglefullscr, {0} },
|
||
|
|
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||
|
|
|
||
|
|
/* layouts: tile / monocle. i3 mnemonics mapped to the nearest dwm layout. */
|
||
|
|
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, /* tiling */
|
||
|
|
{ MODKEY, XK_e, setlayout, {.v = &layouts[0]} }, /* ~ toggle split -> tiling */
|
||
|
|
{ MODKEY, XK_w, setlayout, {.v = &layouts[2]} }, /* ~ tabbed -> monocle */
|
||
|
|
{ MODKEY, XK_s, setlayout, {.v = &layouts[2]} }, /* ~ stacking -> monocle */
|
||
|
|
{ MODKEY, XK_space, setlayout, {0} }, /* ~ focus mode_toggle -> prev layout */
|
||
|
|
|
||
|
|
{ MODKEY, XK_b, togglebar, {0} },
|
||
|
|
|
||
|
|
/* ---- multi-monitor: the i3 "move a window to the other screen" workflow --
|
||
|
|
* dwm differs from i3 here: there is ONE shared set of tags (1-10), and each
|
||
|
|
* monitor independently shows one of them — instead of i3's per-output
|
||
|
|
* workspaces. You don't pick "the workspace that lives on screen 2"; you just
|
||
|
|
* move focus (or the window) to the other screen directly, which is one key:
|
||
|
|
* focus other screen : Mod+, Mod+. (or Mod+Ctrl+Left / Right)
|
||
|
|
* throw window there : Mod+Shift+, Mod+Shift+. (or Mod+Ctrl+Shift+L/R)
|
||
|
|
* Arrow variants are added because comma/period are easy to forget. */
|
||
|
|
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
|
||
|
|
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
||
|
|
{ MODKEY|ControlMask, XK_Left, focusmon, {.i = -1 } },
|
||
|
|
{ MODKEY|ControlMask, XK_Right, focusmon, {.i = +1 } },
|
||
|
|
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||
|
|
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||
|
|
{ MODKEY|ControlMask|ShiftMask, XK_Left, tagmon, {.i = -1 } },
|
||
|
|
{ MODKEY|ControlMask|ShiftMask, XK_Right, tagmon, {.i = +1 } },
|
||
|
|
|
||
|
|
/* microphone mute (i3's Mod+m). Uses volume_control.sh micmute — same pactl
|
||
|
|
* backend as the media keys, with a notification and NO pacman side-effects.
|
||
|
|
* (toggle_mic.sh is deliberately avoided here: it runs `sudo pacman -S dunst`
|
||
|
|
* if dunst is missing, which deadlocks pacman when spawned without a tty.) */
|
||
|
|
{ MODKEY, XK_m, spawn, SHCMD("$HOME/testsAndMisc/linux_configuration/scripts/single_use/utils/volume_control.sh micmute") },
|
||
|
|
|
||
|
|
/* media keys — routed through volume_control.sh, same as the (now-fixed) i3 config */
|
||
|
|
{ 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("$HOME/testsAndMisc/linux_configuration/scripts/single_use/utils/volume_control.sh up") },
|
||
|
|
{ 0, XF86XK_AudioLowerVolume, spawn, SHCMD("$HOME/testsAndMisc/linux_configuration/scripts/single_use/utils/volume_control.sh down") },
|
||
|
|
{ 0, XF86XK_AudioMute, spawn, SHCMD("$HOME/testsAndMisc/linux_configuration/scripts/single_use/utils/volume_control.sh mute") },
|
||
|
|
{ 0, XF86XK_AudioMicMute, spawn, SHCMD("$HOME/testsAndMisc/linux_configuration/scripts/single_use/utils/volume_control.sh micmute") },
|
||
|
|
|
||
|
|
/* tags 1-10 (i3 workspaces 1-10) */
|
||
|
|
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)
|
||
|
|
TAGKEYS( XK_0, 9)
|
||
|
|
|
||
|
|
/* kill window / exit session (mirror i3 Mod+Shift+q and Mod+Shift+e) */
|
||
|
|
{ MODKEY|ShiftMask, XK_q, killclient, {0} },
|
||
|
|
{ MODKEY|ShiftMask, XK_e, quit, {0} },
|
||
|
|
|
||
|
|
/* recompile from source (i3's Mod+Shift+r restart, dwm-style) */
|
||
|
|
{ MODKEY|ShiftMask, XK_r, spawn, {.v = rebuildcmd } },
|
||
|
|
|
||
|
|
/* panic: force-release the automatic fullscreen pointer-lock (pointer-confine) */
|
||
|
|
{ MODKEY|ShiftMask, XK_p, spawn, {.v = pconfoffcmd } },
|
||
|
|
};
|
||
|
|
|
||
|
|
/* ---- mouse: Mod+drag to move/resize floats (i3's floating_modifier) ----- */
|
||
|
|
static const Button buttons[] = {
|
||
|
|
/* click event mask button function argument */
|
||
|
|
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
||
|
|
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
||
|
|
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||
|
|
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
||
|
|
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||
|
|
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
||
|
|
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||
|
|
{ ClkTagBar, 0, Button1, view, {0} },
|
||
|
|
{ ClkTagBar, 0, Button3, toggleview, {0} },
|
||
|
|
{ ClkTagBar, MODKEY, Button1, tag, {0} },
|
||
|
|
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
|
||
|
|
};
|