You are not logged in.

#1 2008-12-23 02:39:17

axion419
Member
Registered: 2007-04-12
Posts: 185

How to Add patches to dwm?

I cp the dwm directory to my builds directory.
I then makepkg -i and install dwm, it runs fine.  I want to compile dwm with the bottom stack patch from their website.
I download the dwm-5.3-bstack.diff  file into my dwm directory.  I saw in another thread to add

  patch -p1 < dwm-5.3-bstack.diff  || return 1

into my package build.  I am just unclear of where to add it.

my PKGBUILD is

# $Id: PKGBUILD,v 1.19 2008/12/05 09:41:07 sergej Exp $
# Maintainer: Sergej Pupykin <sergej@aur.archlinux.org>
# Contributor: Dag Odenhall <dag.odenhall@gmail.com>
# Contributor: Grigorios Bouzakis <grbzks@gmail.com>

pkgname=dwm
pkgver=5.3
pkgrel=1
pkgdesc="A dynamic window manager for X"
url="http://www.suckless.org/wiki/dwm"
arch=('i686' 'x86_64')
license=('MIT')
options=(zipman)
depends=('libx11')
install=dwm.install
source=(http://code.suckless.org/dl/dwm/dwm-$pkgver.tar.gz \
    config.h)
md5sums=('ee47a2adcc3bbc3c053307e6ef35e3e0'
         '8093b1bea675dea404913e828cabfa04')

build() {
  cd $srcdir/$pkgname-$pkgver

  cp $srcdir/config.h config.h

  make X11INC=/usr/include/X11 X11LIB=/usr/lib/X11 || return 1
  make PREFIX=/usr DESTDIR=$pkgdir install || return 1

  install -m644 -D LICENSE $pkgdir/usr/share/licenses/$pkgname/LICENSE && \
  install -m644 -D README $pkgdir/usr/share/doc/$pkgname/README
}

I then know i need to enter #include "bstack.c" into my config.h file.  I am just a little unclear of it I add it to the original config.h in my dwm directory. Or must I add it to the config.h that is in the src directory?  Thanks, Justin.

Offline

#2 2008-12-23 03:37:10

BinkyTheClown
Member
From: The Circus
Registered: 2008-06-11
Posts: 85
Website

Re: How to Add patches to dwm?

You need to include the patch file in the sources array:

source=(
  http://code.suckless.org/dl/dwm/dwm-$pkgver.tar.gz
  config.h
  dwm-5.3-bstack.diff
)

The command to apply the patch is:

...
cd $srcdir/$pkgname-$pkgver
patch -p0 < ../dwm-5.3-bstack.diff || return 1
cp $srcdir/config.h config.h
...

And you need to replace the config.h that is in the same directory of the PKGBUILD by one that have the #include line. Make sure that line is in the bottom of the file to avoid compilation errors.

...
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} },
};

#include "bstack.c"

Don't forget to update the md5sums with

makepkg -g >> PKGBUILD

Last edited by BinkyTheClown (2008-12-23 03:48:46)


Heeeeeey cat!!!

Offline

#3 2008-12-23 04:41:30

axion419
Member
Registered: 2007-04-12
Posts: 185

Re: How to Add patches to dwm?

Thanks for the reply.  I can it to install, but I still do not get the option for bottom stack.  Do I need to add it to my config somewhere? I assumed the patch would add it to the config.h intself?
Here is a link to the patch

http://bsdgroup.org/files/dwm-5.3-bstack.diff

PKGBUILD

# $Id: PKGBUILD,v 1.19 2008/12/05 09:41:07 sergej Exp $
# Maintainer: Sergej Pupykin <sergej@aur.archlinux.org>
# Contributor: Dag Odenhall <dag.odenhall@gmail.com>
# Contributor: Grigorios Bouzakis <grbzks@gmail.com>

pkgname=dwm
pkgver=5.3
pkgrel=1
pkgdesc="A dynamic window manager for X"
url="http://www.suckless.org/wiki/dwm"
arch=('i686' 'x86_64')
license=('MIT')
options=(zipman)
depends=('libx11')
install=dwm.install
source=(http://code.suckless.org/dl/dwm/dwm-$pkgver.tar.gz \
    config.h
    http://code.suckless.org/dl/dwm/dwm-$pkgver.tar.gz \
        dwm-5.3-bstack.diff
)
md5sums=('ee47a2adcc3bbc3c053307e6ef35e3e0'
         '8093b1bea675dea404913e828cabfa04')

build() {
  cd $srcdir/$pkgname-$pkgver
  patch -p0 < ../dwm-5.3-bstack.diff || return 1
  cp $srcdir/config.h config.h

  make X11INC=/usr/include/X11 X11LIB=/usr/lib/X11 || return 1
  make PREFIX=/usr DESTDIR=$pkgdir install || return 1

  install -m644 -D LICENSE $pkgdir/usr/share/licenses/$pkgname/LICENSE && \
  install -m644 -D README $pkgdir/usr/share/doc/$pkgname/README
}

config.h

/* See LICENSE file for copyright and license details. */

/* appearance */
static const char font[]            = "-*-terminus-medium-r-normal-*-14-*-*-*-*-*-*-*";
static const char normbordercolor[] = "#cccccc";
static const char normbgcolor[]     = "#cccccc";
static const char normfgcolor[]     = "#000000";
static const char selbordercolor[]  = "#0066ff";
static const char selbgcolor[]      = "#0066ff";
static const char selfgcolor[]      = "#ffffff";
static unsigned int borderpx        = 1;        /* border pixel of windows */
static unsigned int snap            = 32;       /* snap pixel */
static Bool showbar                 = True;     /* False means no bar */
static Bool topbar                  = True;     /* False means bottom bar */
static Bool readin                  = True;     /* False means do not read stdin */
static Bool usegrab                 = False;    /* True means grabbing the X server
                                                   during mouse-based resizals */

/* tagging */
static const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
static unsigned int tagset[] = {1, 1}; /* after start, first tag is selected */

static Rule rules[] = {
    /* class      instance    title       tags mask     isfloating */
    { "Gimp",     NULL,       NULL,       0,            True },
    { "Firefox",  NULL,       NULL,       1 << 8,       True },
};

/* layout(s) */
static float mfact      = 0.55; /* factor of master area size [0.05..0.95] */
static Bool resizehints = True; /* False means respect size hints in tiled resizals */

static Layout layouts[] = {
    /* symbol     arrange function */
    { "[]=",      tile },    /* first entry is default */
    { "><>",      NULL },    /* no layout function means floating behavior */
    { "[M]",      monocle },
};

/* key definitions */
#define MODKEY Mod1Mask
#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 const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
static const char *termcmd[]  = { "uxterm", NULL };

static Key keys[] = {
    /* modifier                     key        function        argument */
    { 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_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 } },
    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 a tag number (starting at 0),
 * 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} },
};
#include "bstack.c"

I then get this

[justin@beast dwm]$ makepkg -g >> PKGBUILD
==> Retrieving Sources...
  -> Found dwm-5.3.tar.gz in build dir
  -> Found config.h in build dir
  -> Found dwm-5.3-bstack.diff in build dir
==> Generating checksums for source files...

I can then install

[justin@beast dwm]$ makepkg -efi
==> Making package: dwm 5.3-1 x86_64 (Mon Dec 22 23:39:52 EST 2008)
==> Checking Runtime Dependencies...
==> Checking Buildtime Dependencies...
==> WARNING: Skipping source retrieval        -- using existing src/ tree
==> WARNING: Skipping source integrity checks -- using existing src/ tree
==> WARNING: Skipping source extraction       -- using existing src/ tree
==> Removing existing pkg/ directory...
==> Entering fakeroot environment...
==> Starting build()...
patching file bstack.c
patching file config.def.h
Hunk #1 succeeded at 30 (offset 2 lines).
dwm build options:
CC dwm.c
CFLAGS   = -std=c99 -pedantic -Wall -Os -I. -I/usr/include -I/usr/include/X11 -DVERSION="5.3" 
LDFLAGS  = -s -L/usr/lib -lc -L/usr/lib/X11 -lX11 
CC       = cc
CC -o dwm
dwm build options:
CFLAGS   = -std=c99 -pedantic -Wall -Os -I. -I/usr/include -I/usr/X11R6/include -DVERSION="5.3" 
LDFLAGS  = -s -L/usr/lib -lc -L/usr/X11R6/lib -lX11 
CC       = cc
installing executable file to /home/justin/builds/dwm/pkg/usr/bin
installing manual page to /home/justin/builds/dwm/pkg/usr/share/man/man1
==> Tidying install...
  -> Compressing man pages...
  -> Stripping debugging symbols from binaries and libraries...
==> Creating package...
  -> Generating .PKGINFO file...
  -> Adding install script...
  -> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: dwm 5.3-1 x86_64 (Mon Dec 22 23:39:53 EST 2008)
==> Installing package dwm with pacman -U...
Password: 
loading package data...
checking dependencies...
(1/1) checking for file conflicts                   [#########################################################################################################################################################] 100%
-- Edit config.h in PKGBUILD's directory (generally /var/abs/community/x11/dwm/)
-- and rebuild package if you want to change settings.
(1/1) upgrading dwm

Thanks.

Offline

#4 2008-12-23 05:41:16

BinkyTheClown
Member
From: The Circus
Registered: 2008-06-11
Posts: 85
Website

Re: How to Add patches to dwm?

I have seen the light smile
First, remove the config.h from the sources array and from the top level directory of the PKGBUILD. Also remove the line "cp $srcdir/config.h config.h". This is necessary because the config.h file is generated from the Makefile by using the config.def.h file that the patch changes.

So, this is a modified patch to actually use the bottom stack using the Mod+s key combination:

--- bstack.c    Wed Dec 31 19:00:00 1969
+++ bstack.c    Thu Oct 16 18:59:03 2008
@@ -0,0 +1,31 @@
+void
+bstack(void) {
+    int x, y, h, w, mh;
+    unsigned int i, n;
+    Client *c;
+
+    for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++);
+    if(n == 0)
+        return;
+
+    c = nexttiled(clients);
+    mh = mfact * wh;
+    resize(c, wx, wy, ww - 2 * c->bw, (n == 1 ? wh : mh) - 2 * c->bw, resizehints);
+
+    if(--n == 0)
+        return;
+
+    x = wx;
+    y = (wy + mh > c->y + c->h) ? c->y + c->h + 2 * c->bw : wy + mh;
+    w = ww / n;
+    h = (wy + mh > c->y + c->h) ? wy + wh - y : wh - mh;
+    if(h < bh)
+        h = wh;
+
+    for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
+        resize(c, x, y, ((i + 1 == n) ? wx + ww - x : w) - 2 * c->bw,
+               h - 2 * c->bw, resizehints);
+        if(w != ww)
+            x = c->x + WIDTH(c);    
+    }
+}
--- config.def.h    Thu Oct 16 18:58:37 2008
+++ config.def.h    Thu Oct 16 18:59:31 2008
@@ -28,11 +28,13 @@ static Rule rules[] = {
 static float mfact      = 0.55; /* factor of master area size [0.05..0.95] */
 static Bool resizehints = True; /* False means respect size hints in tiled resizals */
 
+#include "bstack.c"
 static Layout layouts[] = {
     /* symbol     arrange function */
     { "[]=",      tile },    /* first entry is default */
     { "><>",      NULL },    /* no layout function means floating behavior */
     { "[M]",      monocle },
+    { "TTT",      bstack },
 };
 
 /* key definitions */
@@ -67,6 +69,7 @@ static Key keys[] = {
     { MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
     { MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
     { MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
+    { MODKEY,                       XK_s,      setlayout,      {.v = &layouts[3]} },
     { MODKEY,                       XK_space,  setlayout,      {0} },
     { MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
     { MODKEY,                       XK_0,      view,           {.ui = ~0 } },

Remember to delete the src and pkg directories before executing makepkg.

Last edited by BinkyTheClown (2008-12-23 05:44:35)


Heeeeeey cat!!!

Offline

#5 2008-12-23 17:31:38

axion419
Member
Registered: 2007-04-12
Posts: 185

Re: How to Add patches to dwm?

Alright Ill give this a try when I get off, thank you.

Offline

#6 2008-12-24 01:50:03

axion419
Member
Registered: 2007-04-12
Posts: 185

Re: How to Add patches to dwm?

thank you, that worked.

Offline

Board footer

Powered by FluxBB