Skip to content

Commit

Permalink
Merge branch 'dev' into my-conf
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoXD committed Aug 5, 2021
2 parents 6e5b3f2 + 86e853c commit 789538c
Show file tree
Hide file tree
Showing 37 changed files with 200 additions and 20 deletions.
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- NOTE: This is vanilla dwm bar (status2d patch for setting colors) not dwmblocks or polybar.

## To make installation easier and faster I made two scripts:

1. install.sh (contains the setup instructions)
2. packages.sh (install the needed packages)

Expand All @@ -13,8 +14,9 @@ To use it you need to ```chmod +x``` the scripts.
# Requirements

## Dwm
- xorg
- xorg-server

- xorg / xorg-server
- Xlib
- imlib2

## Fonts
Expand All @@ -24,7 +26,7 @@ To use it you need to ```chmod +x``` the scripts.
- JetBrains Mono Nerd Font
- Material Design Icons

Use the ```fonts``` dir if you don't want to use the aur.
There is also a ```fonts``` dir if you don't want to use the aur.

## Packages

Expand All @@ -37,6 +39,7 @@ Use the ```fonts``` dir if you don't want to use the aur.
- xbacklight
- acpi
- picom-ibhagwan-git (optional, see [St transparency](#st-transparency))

```
sudo pacman -S xorg-xsetroot xorg-xbacklight acpi pacman-contrib rofi feh
```
Expand All @@ -48,17 +51,10 @@ $ cd xmenu
$ makepkg -si
```

To install ```st``` (siduck76's build):
```
git clone https://github.com/siduck76/st
cd st
make
sudo make install
```

# Setup

- Change ```username``` in ```chadwm/dwm/config.def.h``` with your username.

```
$ cp -r fonts/* ~/.local/share/fonts
$ mkdir $HOME/Wallpapers
Expand All @@ -73,10 +69,12 @@ $ cd dwm
$ make
# sudo make install
```

- ```autostart``` file must be adjusted for your liking!
- If you are using ```xinit```, start dwm with ```exec ~/.dwm/autostart``` or copy ```dwm.desktop``` in ```/usr/share/xsessions``` folder.

## Shell packages

- [logo-ls](https://github.com/Yash-Handa/logo-ls)
- Zsh
- [Oh-My-Zsh](https://github.com/ohmyzsh/ohmyzsh)
Expand Down
2 changes: 1 addition & 1 deletion chadwm/dwm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dwm: ${OBJ}
${CC} -o $@ ${OBJ} ${LDFLAGS}

clean:
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz config.h

dist: clean
mkdir -p dwm-${VERSION}
Expand Down
16 changes: 15 additions & 1 deletion chadwm/dwm/config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,21 @@ static Button buttons[] = {
{ ClkLtSymbol, 0, Button3, layoutmenu, {0} },
{ ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },

/* Keep movemouse? */
/* { ClkClientWin, MODKEY, Button1, movemouse, {0} }, */

/* placemouse options, choose which feels more natural:
* 0 - tiled position is relative to mouse cursor
* 1 - tiled postiion is relative to window center
* 2 - mouse pointer warps to window center
*
* The moveorplace uses movemouse or placemouse depending on the floating state
* of the selected client. Set up individual keybindings for the two if you want
* to control these separately (i.e. to retain the feature to move a tiled window
* into a floating position).
*/
{ ClkClientWin, MODKEY, Button1, moveorplace, {.i = 0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
{ ClkClientWin, ControlMask, Button1, dragmfact, {0} },
Expand Down
2 changes: 1 addition & 1 deletion chadwm/dwm/drw.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ drw_clr_create(Drw *drw, Clr *dest, const char *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
Expand Down
177 changes: 172 additions & 5 deletions chadwm/dwm/dwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
#define INTERSECT(x, y, w, h, m) \
(MAX(0, MIN((x) + (w), (m)->wx + (m)->ww) - MAX((x), (m)->wx)) * \
MAX(0, MIN((y) + (h), (m)->wy + (m)->wh) - MAX((y), (m)->wy)))
#define INTERSECTC(x,y,w,h,z) (MAX(0, MIN((x)+(w),(z)->x+(z)->w) - MAX((x),(z)->x)) \
* MAX(0, MIN((y)+(h),(z)->y+(z)->h) - MAX((y),(z)->y)))
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
#define HIDDEN(C) ((getstate(C->win) == IconicState))
#define LENGTH(X) (sizeof X / sizeof X[0])
Expand Down Expand Up @@ -175,6 +177,7 @@ struct Client {
unsigned int tags;
int isfixed, iscentered, isfloating, isurgent, neverfocus, oldstate,
isfullscreen;
int beingmoved;
Client *next;
Client *snext;
Monitor *mon;
Expand Down Expand Up @@ -263,10 +266,13 @@ static void maprequest(XEvent *e);
static void monocle(Monitor *m);
static void motionnotify(XEvent *e);
static void movemouse(const Arg *arg);
static void moveorplace(const Arg *arg);
static Client *nexttiled(Client *c);
static void placemouse(const Arg *arg);
static void pop(Client *);
static void propertynotify(XEvent *e);
static void quit(const Arg *arg);
static Client *recttoclient(int x, int y, int w, int h);
static Monitor *recttomon(int x, int y, int w, int h);
static void removesystrayicon(Client *i);
static void resize(Client *c, int x, int y, int w, int h, int interact);
Expand Down Expand Up @@ -1619,18 +1625,18 @@ void focusstack(const Arg *arg) {
if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
return;
if (arg->i > 0) {
for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next)
for (c = selmon->sel->next; c && (!ISVISIBLE(c) || HIDDEN(c)); c = c->next)
;
if (!c)
for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next)
for (c = selmon->clients; c && (!ISVISIBLE(c) || HIDDEN(c)); c = c->next)
;
} else {
for (i = selmon->clients; i != selmon->sel; i = i->next)
if (ISVISIBLE(i))
if (ISVISIBLE(i) && !HIDDEN(i))
c = i;
if (!c)
for (; i; i = i->next)
if (ISVISIBLE(i))
if (ISVISIBLE(i) && !HIDDEN(i))
c = i;
}
if (c) {
Expand Down Expand Up @@ -2025,6 +2031,14 @@ void motionnotify(XEvent *e) {
mon = m;
}

void
moveorplace(const Arg *arg) {
if ((!selmon->lt[selmon->sellt]->arrange || (selmon->sel && selmon->sel->isfloating)))
movemouse(arg);
else
placemouse(arg);
}

void movemouse(const Arg *arg) {
int x, y, ocx, ocy, nx, ny;
Client *c;
Expand Down Expand Up @@ -2089,6 +2103,139 @@ Client *nexttiled(Client *c) {
return c;
}

void
placemouse(const Arg *arg)
{
int x, y, px, py, ocx, ocy, nx = -9999, ny = -9999, freemove = 0;
Client *c, *r = NULL, *at, *prevr;
Monitor *m;
XEvent ev;
XWindowAttributes wa;
Time lasttime = 0;
int attachmode, prevattachmode;
attachmode = prevattachmode = -1;

if (!(c = selmon->sel) || !c->mon->lt[c->mon->sellt]->arrange) /* no support for placemouse when floating layout is used */
return;
if (c->isfullscreen) /* no support placing fullscreen windows by mouse */
return;
restack(selmon);
prevr = c;
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[CurMove]->cursor, CurrentTime) != GrabSuccess)
return;

c->isfloating = 0;
c->beingmoved = 1;

XGetWindowAttributes(dpy, c->win, &wa);
ocx = wa.x;
ocy = wa.y;

if (arg->i == 2) // warp cursor to client center
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, WIDTH(c) / 2, HEIGHT(c) / 2);

if (!getrootptr(&x, &y))
return;

do {
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
switch (ev.type) {
case ConfigureRequest:
case Expose:
case MapRequest:
handler[ev.type](&ev);
break;
case MotionNotify:
if ((ev.xmotion.time - lasttime) <= (1000 / 60))
continue;
lasttime = ev.xmotion.time;

nx = ocx + (ev.xmotion.x - x);
ny = ocy + (ev.xmotion.y - y);

if (!freemove && (abs(nx - ocx) > snap || abs(ny - ocy) > snap))
freemove = 1;

if (freemove)
XMoveWindow(dpy, c->win, nx, ny);

if ((m = recttomon(ev.xmotion.x, ev.xmotion.y, 1, 1)) && m != selmon)
selmon = m;

if (arg->i == 1) { // tiled position is relative to the client window center point
px = nx + wa.width / 2;
py = ny + wa.height / 2;
} else { // tiled position is relative to the mouse cursor
px = ev.xmotion.x;
py = ev.xmotion.y;
}

r = recttoclient(px, py, 1, 1);

if (!r || r == c)
break;

attachmode = 0; // below
if (((float)(r->y + r->h - py) / r->h) > ((float)(r->x + r->w - px) / r->w)) {
if (abs(r->y - py) < r->h / 2)
attachmode = 1; // above
} else if (abs(r->x - px) < r->w / 2)
attachmode = 1; // above

if ((r && r != prevr) || (attachmode != prevattachmode)) {
detachstack(c);
detach(c);
if (c->mon != r->mon) {
arrangemon(c->mon);
c->tags = r->mon->tagset[r->mon->seltags];
}

c->mon = r->mon;
r->mon->sel = r;

if (attachmode) {
if (r == r->mon->clients)
attach(c);
else {
for (at = r->mon->clients; at->next != r; at = at->next);
c->next = at->next;
at->next = c;
}
} else {
c->next = r->next;
r->next = c;
}

attachstack(c);
arrangemon(r->mon);
prevr = r;
prevattachmode = attachmode;
}
break;
}
} while (ev.type != ButtonRelease);
XUngrabPointer(dpy, CurrentTime);

if ((m = recttomon(ev.xmotion.x, ev.xmotion.y, 1, 1)) && m != c->mon) {
detach(c);
detachstack(c);
arrangemon(c->mon);
c->mon = m;
c->tags = m->tagset[m->seltags];
attach(c);
attachstack(c);
selmon = m;
}

focus(c);
c->beingmoved = 0;

if (nx != -9999)
resize(c, nx, ny, c->w, c->h, 0);
arrangemon(c->mon);
}

void pop(Client *c) {
detach(c);
attach(c);
Expand Down Expand Up @@ -2160,6 +2307,22 @@ void quit(const Arg *arg) {
system("killall bar");
}

Client *
recttoclient(int x, int y, int w, int h)
{
Client *c, *r = NULL;
int a, area = 0;

for (c = nexttiled(selmon->clients); c; c = nexttiled(c->next)) {
if ((a = INTERSECTC(x, y, w, h, c)) > area) {
area = a;
r = c;
}
}
return r;
}


Monitor *recttomon(int x, int y, int w, int h) {
Monitor *m, *r = selmon;
int a, area = 0;
Expand Down Expand Up @@ -2207,7 +2370,11 @@ void resizeclient(Client *c, int x, int y, int w, int h) {
c->w = wc.width = w;
c->oldh = c->h;
c->h = wc.height = h;
wc.border_width = c->bw;

if (c->beingmoved)
return;

wc.border_width = c->bw;
XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth,
&wc);
configure(c);
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file removed fonts/jetbrains-mono-regular-nerd-font-complete.ttf
Binary file not shown.
3 changes: 2 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mkdir -p ~/.local/share/fonts
cp -r fonts/* ~/.local/share/fonts
cp -r fonts/JetBrainsMono/* ~/.local/share/fonts
cp -r fonts/MaterialDesignIcons/* ~/.local/share/fonts
mkdir $HOME/Wallpapers
mkdir -p $HOME/Public/Xresources/nord
cat nord-xresources/src/nord > $HOME/Public/Xresources/nord/.Xresources
Expand Down

0 comments on commit 789538c

Please sign in to comment.