movestack, rebinds

This commit is contained in:
Arthur 2023-10-06 02:34:39 +03:00
parent 4c7bc4051e
commit 9b6dc5b72d
3 changed files with 91 additions and 36 deletions

View file

@ -8,7 +8,7 @@ static const unsigned int gappov = 10;
static int smartgaps = 1;
static const int showbar = 1;
static const int topbar = 1;
static const char *fonts[] = { "Mononoki Nerd Font:size=12" };
static const char *fonts[] = { "Mononoki Nerd Font:size=12", "Noto Color Emoji" };
static const char dmenufont[] = "Mononoki Nerd Font:size=12";
static const char col_gray1[] = "#222222";
static const char col_gray2[] = "#444444";
@ -18,45 +18,46 @@ static const char col_accent[] = "#db8402";
static const unsigned int baralpha = 0xd0;
static const unsigned int borderalpha = OPAQUE;
static const char *colors[][3] = {
static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_gray2, col_accent },
};
static const unsigned int alphas[][3] = {
/* fg bg border*/
[SchemeNorm] = { OPAQUE, baralpha, borderalpha },
[SchemeSel] = { OPAQUE, baralpha, borderalpha },
/* fg bg border*/
[SchemeNorm] = { OPAQUE, baralpha, borderalpha },
[SchemeSel] = { OPAQUE, baralpha, borderalpha },
};
/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9"};
static const Rule rules[] = {
/* xprop(1):
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
*/
/* class instance title tags mask isfloating monitor */
{ "Firefox", NULL, "Picture-in-Picture", 0, 1, -1 },
/* class instance name tags mask isfloating monitor */
{ "Firefox", NULL, "Picture-in-Picture", 0, 1, -1 },
};
/* layout(s) */
static const float mfact = 0.60; /* 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 int inversedirection = 1; /* 1 will attach windows to the end of the stack */
static const float mfact = 0.60;
static const int nmaster = 1;
static const int resizehints = 1;
static const int lockfullscreen = 1;
int inversedirection = 1;
#define FORCE_VSPLIT 1
#include "vanitygaps.c"
static const Layout layouts[] = {
/* symbol arrange function */
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[\\]", dwindle},
{ "[]=", tile },
{ "[M]", monocle },
{ "><>", NULL },
};
/* key definitions */
@ -68,14 +69,14 @@ static const Layout layouts[] = {
{ MODKEY|Mod1Mask, KEY, toggletag, {.ui = 1 << TAG} }, \
{ MODKEY|ControlMask|ShiftMask, KEY, toggleview, {.ui = 1 << TAG} }, \
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(...) { .v = (const char*[]){ __VA_ARGS__, NULL } }
/* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static char dmenumon[2] = "0";
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_accent, "-sf", col_gray4, NULL };
static const char *termcmd[] = { "st", NULL };
#include "movestack.c"
static const Key keys[] = {
/* modifier key function argument */
// movement
@ -93,12 +94,16 @@ static const Key keys[] = {
{ MODKEY, XK_q, killclient, {0} },
// layout
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_y, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_u, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_f, togglefullscr, {0} },
{ MODKEY|ShiftMask, XK_f, togglefloating, {0} },
{ MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } },
{ MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } },
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_p, invertdir, {0} },
// apps
{ MODKEY, XK_w, spawn, SHCMD("firefox") },
@ -106,12 +111,7 @@ static const Key keys[] = {
{ MODKEY|ShiftMask, XK_s, spawn, SHCMD("flameshot", "gui") },
{ MODKEY, XK_i, spawn, SHCMD("dunstctl", "history-pop") },
{ MODKEY, XK_o, spawn, SHCMD("dunstctl", "close") },
/*
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },*/
// tags
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
@ -128,17 +128,17 @@ static const Key keys[] = {
/* button definitions */
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
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} },
/* 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} },
};

7
dwm.c
View file

@ -183,6 +183,7 @@ static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
static void grabbuttons(Client *c, int focused);
static void grabkeys(void);
static void incnmaster(const Arg *arg);
static void invertdir(const Arg *arg);
static void keypress(XEvent *e);
static void killclient(const Arg *arg);
static void manage(Window w, XWindowAttributes *wa);
@ -1017,6 +1018,12 @@ incnmaster(const Arg *arg)
arrange(selmon);
}
static void
invertdir(const Arg *arg)
{
inversedirection = !inversedirection;
}
#ifdef XINERAMA
static int
isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info)

48
movestack.c Normal file
View file

@ -0,0 +1,48 @@
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 selmon->clients 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);
}
}