Browse Source

README

master
RinRi-D 3 years ago
parent
commit
ab94690a2e
10 changed files with 305 additions and 14 deletions
  1. +78
    -0
      README.md
  2. +2
    -0
      config.def.h
  3. +2
    -0
      config.h
  4. +145
    -0
      config.h.orig
  5. +10
    -0
      config.h.rej
  6. BIN
      dwm
  7. +43
    -2
      dwm.c
  8. +24
    -12
      dwm.c.orig
  9. BIN
      dwm.o
  10. +1
    -0
      patches.txt

+ 78
- 0
README.md View File

@@ -0,0 +1,78 @@
# My dwm build

This my own patched and configured dwm build with following pathes:

- alwaysontop
- cool-autostart
- center
- fullgaps

You can define autostarting programs in:

```c
static const char *const autostart[] = {
"sh", "-c", "sh ~/scripts/xinit.sh", NULL,
"dunst", NULL,
"slstatus", NULL,
NULL /* terminate */
};
```

Also I use dunst notification manager, slstatus statusbar, picom compositor and font awesome. First, you need to install them. I recommend to install `ttf-font-awesome-4` from AUR, because icons are too small in font awesome 5.

You can change config.def.h configuration and then run this commands to compile dwm:

```bash
cp config.def.h config.h
sudo make install
```

Here is dwm's README:

# dwm - dynamic windows manager

dwm is an extremely fast, small, and dynamic window manager for X.

# Requirements

In order to build dwm you need the Xlib header files.

# Installation

Edit config.mk to match your local setup (dwm is installed into
the /usr/local namespace by default).

Afterwards enter the following command to build and install dwm (if
necessary as root):

```bash
make clean install
```

# Running dwm

Add the following line to your .xinitrc to start dwm using startx:

```bash
exec dwm
```

In order to connect dwm to a specific display, make sure that
the DISPLAY environment variable is set correctly, e.g.:

```bash
DISPLAY=foo.bar:1 exec dwm
```

(This will start dwm on display :1 of the host foo.bar.)

In order to display status info in the bar, you can do something
like this in your .xinitrc:

```bash
while xsetroot -name "`date` `uptime | sed 's/.*,//'`"
do
sleep 1
done &
exec dwm
```

+ 2
- 0
config.def.h View File

@@ -71,6 +71,7 @@ static const char *termcmd[] = { "st", NULL };

static Key keys[] = {
/* modifier key function argument */
{ 0, Print, spawn, SHCMD("scrot") },
{ 0, XF86XK_PowerOff, spawn, SHCMD("~/scripts/poweroff.sh") },
{ 0, XF86XK_AudioMute, spawn, SHCMD("pulsemixer --toggle-mute") },
{ 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("pulsemixer --change-volume +1") },
@@ -82,6 +83,7 @@ static Key keys[] = {
{ 0, XF86XK_AudioStop, spawn, SHCMD("cmus-remote --stop") },
{ 0, XF86XK_AudioRewind, spawn, SHCMD("cmus-remote --seek -10") },
{ 0, XF86XK_AudioForward, spawn, SHCMD("cmus-remote --seek +10") },
{ MODKEY|ShiftMask, XK_space, togglealwaysontop, {0} },
{ MODKEY, XK_w, spawn, SHCMD("firefox") },
{ MODKEY|ShiftMask, XK_l, spawn, SHCMD("xsecurelock") },
{ MODKEY|ShiftMask, XK_m, spawn, SHCMD("st ~/scripts/autostart.sh") },


+ 2
- 0
config.h View File

@@ -71,6 +71,7 @@ static const char *termcmd[] = { "st", NULL };

static Key keys[] = {
/* modifier key function argument */
{ 0, Print, spawn, SHCMD("scrot") },
{ 0, XF86XK_PowerOff, spawn, SHCMD("~/scripts/poweroff.sh") },
{ 0, XF86XK_AudioMute, spawn, SHCMD("pulsemixer --toggle-mute") },
{ 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("pulsemixer --change-volume +1") },
@@ -82,6 +83,7 @@ static Key keys[] = {
{ 0, XF86XK_AudioStop, spawn, SHCMD("cmus-remote --stop") },
{ 0, XF86XK_AudioRewind, spawn, SHCMD("cmus-remote --seek -10") },
{ 0, XF86XK_AudioForward, spawn, SHCMD("cmus-remote --seek +10") },
{ MODKEY|ShiftMask, XK_space, togglealwaysontop, {0} },
{ MODKEY, XK_w, spawn, SHCMD("firefox") },
{ MODKEY|ShiftMask, XK_l, spawn, SHCMD("xsecurelock") },
{ MODKEY|ShiftMask, XK_m, spawn, SHCMD("st ~/scripts/autostart.sh") },


+ 145
- 0
config.h.orig View File

@@ -0,0 +1,145 @@
/* See LICENSE file for copyright and license details. */

/* appearance */
static const unsigned int borderpx = 2; /* border pixel of windows */
static const unsigned int gappx = 15;
static const unsigned int snap = 32; /* snap pixel */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = { "monospace:size=13", "fontawesome:size=15"};
static const char dmenufont[] = "monospace:size=13";
static const char col_gray1[] = "#222222";
static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb";
static const char col_gray4[] = "#eeeeee";
static const char col_cyan[] = "#41008c";
static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
};

static const char *const autostart[] = {
"sh", "-c", "sh ~/scripts/xinit.sh", NULL,
"dunst", NULL,
"slstatus", NULL,
NULL /* terminate */
};

/* tagging */
static const char *tags[] = { "", "", "", "", "", "", "" };

static const Rule rules[] = {
/* xprop(1):
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
*/
/* class instance title tags mask iscentered isfloating monitor */
{ "Gimp", NULL, NULL, 0, 0, 1, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, 0, -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 Layout layouts[] = {
/* symbol arrange function */
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
};

/* 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} },

/* 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 char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char *termcmd[] = { "st", NULL };

#include <X11/XF86keysym.h>

static Key keys[] = {
/* modifier key function argument */
{ 0, XF86XK_PowerOff, spawn, SHCMD("~/scripts/poweroff.sh") },
{ 0, XF86XK_AudioMute, spawn, SHCMD("pulsemixer --toggle-mute") },
{ 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("pulsemixer --change-volume +1") },
{ 0, XF86XK_AudioLowerVolume, spawn, SHCMD("pulsemixer --change-volume -1") },
{ 0, XF86XK_AudioPrev, spawn, SHCMD("cmus-remote --prev") },
{ 0, XF86XK_AudioNext, spawn, SHCMD("cmus-remote --next") },
{ 0, XF86XK_AudioPause, spawn, SHCMD("cmus-remote --pause") },
{ 0, XF86XK_AudioPlay, spawn, SHCMD("cmus-remote --pause") },
{ 0, XF86XK_AudioStop, spawn, SHCMD("cmus-remote --stop") },
{ 0, XF86XK_AudioRewind, spawn, SHCMD("cmus-remote --seek -10") },
{ 0, XF86XK_AudioForward, spawn, SHCMD("cmus-remote --seek +10") },
{ MODKEY, XK_w, spawn, SHCMD("firefox") },
{ MODKEY|ShiftMask, XK_l, spawn, SHCMD("xsecurelock") },
{ MODKEY|ShiftMask, XK_m, spawn, SHCMD("st ~/scripts/autostart.sh") },
{ MODKEY|ShiftMask, XK_j, spawn, SHCMD("joplin-desktop") },
{ MODKEY|ShiftMask, XK_s, spawn, SHCMD("deepin-screenshot") },
{ MODKEY|ShiftMask, XK_n, spawn, SHCMD("networkmanager_dmenu") },
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
{ MODKEY, XK_Return, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
{ MODKEY, XK_minus, setgaps, {.i = -5 } },
{ MODKEY, XK_equal, setgaps, {.i = +5 } },
{ MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
TAGKEYS( XK_4, 3)
TAGKEYS( XK_5, 4)
TAGKEYS( XK_6, 5)
TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
{ MODKEY|ShiftMask, XK_q, quit, {0} },
};

/* 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} },
{ 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} },
};


+ 10
- 0
config.h.rej View File

@@ -0,0 +1,10 @@
--- config.h
+++ config.h
@@ -178,6 +178,7 @@ static Key keys[] = {
{ MODKEY, XK_e, setlayout, {.v = &layouts[LAYOUT_I_grid]} },
{ MODKEY, XK_space, togglefloating, {0} },
+ { MODKEY|ShiftMask, XK_space, togglealwaysontop, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } },

BIN
dwm View File


+ 43
- 2
dwm.c View File

@@ -92,7 +92,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
unsigned int tags;
int isfixed, iscentered, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
int isfixed, iscentered, isfloating, isalwaysontop, isurgent, neverfocus, oldstate, isfullscreen;
Client *next;
Client *snext;
Monitor *mon;
@@ -214,6 +214,7 @@ static void tagmon(const Arg *arg);
static void tile(Monitor *);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
static void togglealwaysontop(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unfocus(Client *c, int setfocus);
@@ -767,8 +768,11 @@ drawbar(Monitor *m)
if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
if (m->sel->isfloating)
if (m->sel->isfloating) {
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
if (m->sel->isalwaysontop)
drw_rect(drw, x + boxs, bh - boxw, boxw, boxw, 0, 0);
}
} else {
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1);
@@ -1405,6 +1409,17 @@ restack(Monitor *m)
return;
if (m->sel->isfloating || !m->lt[m->sellt]->arrange)
XRaiseWindow(dpy, m->sel->win);

/* raise the aot window */
for(Monitor *m_search = mons; m_search; m_search = m_search->next){
for(c = m_search->clients; c; c = c->next){
if(c->isalwaysontop){
XRaiseWindow(dpy, c->win);
break;
}
}
}

if (m->lt[m->sellt]->arrange) {
wc.stack_mode = Below;
wc.sibling = m->barwin;
@@ -1791,6 +1806,32 @@ togglefloating(const Arg *arg)
if (selmon->sel->isfloating)
resize(selmon->sel, selmon->sel->x, selmon->sel->y,
selmon->sel->w, selmon->sel->h, 0);
else
selmon->sel->isalwaysontop = 0; /* disabled, turn this off too */
arrange(selmon);
}

void
togglealwaysontop(const Arg *arg)
{
if (!selmon->sel)
return;
if (selmon->sel->isfullscreen)
return;

if(selmon->sel->isalwaysontop){
selmon->sel->isalwaysontop = 0;
}else{
/* disable others */
for(Monitor *m = mons; m; m = m->next)
for(Client *c = m->clients; c; c = c->next)
c->isalwaysontop = 0;

/* turn on, make it float too */
selmon->sel->isfloating = 1;
selmon->sel->isalwaysontop = 1;
}

arrange(selmon);
}



+ 24
- 12
dwm.c.orig View File

@@ -119,6 +119,7 @@ struct Monitor {
int by; /* bar geometry */
int mx, my, mw, mh; /* screen size */
int wx, wy, ww, wh; /* window area */
int gappx; /* gaps between windows */
unsigned int seltags;
unsigned int sellt;
unsigned int tagset[2];
@@ -200,6 +201,7 @@ static void sendmon(Client *c, Monitor *m);
static void setclientstate(Client *c, long state);
static void setfocus(Client *c);
static void setfullscreen(Client *c, int fullscreen);
static void setgaps(const Arg *arg);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setup(void);
@@ -670,6 +672,7 @@ createmon(void)
m->nmaster = nmaster;
m->showbar = showbar;
m->topbar = topbar;
m->gappx = gappx;
m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
@@ -751,10 +754,9 @@ drawbar(Monitor *m)
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
if (occ & 1 << i)
drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw,
m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
urg & 1 << i);

drw_rect(drw, x + boxs, boxs, boxw, boxw,
m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
urg & 1 << i);
x += w;
}
w = blw = TEXTW(m->ltsymbol);
@@ -1544,6 +1546,16 @@ setfullscreen(Client *c, int fullscreen)
}
}

void
setgaps(const Arg *arg)
{
if ((arg->i == 0) || (selmon->gappx + arg->i < 0))
selmon->gappx = 0;
else
selmon->gappx += arg->i;
arrange(selmon);
}

void
setlayout(const Arg *arg)
{
@@ -1746,16 +1758,16 @@ tile(Monitor *m)
if (n > m->nmaster)
mw = m->nmaster ? m->ww * m->mfact : 0;
else
mw = m->ww;
for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
mw = m->ww - m->gappx;
for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
my += HEIGHT(c);
h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0);
my += HEIGHT(c) + m->gappx;
} else {
h = (m->wh - ty) / (n - i);
resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
ty += HEIGHT(c);
h = (m->wh - ty) / (n - i) - m->gappx;
resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0);
ty += HEIGHT(c) + m->gappx;
}
}



BIN
dwm.o View File


+ 1
- 0
patches.txt View File

@@ -1,4 +1,5 @@
activetagindicator
alwaysontop
cool-autostart
center
fullgaps

Loading…
Cancel
Save