You are not logged in.

#1 2012-02-14 12:53:58

alpa8le
Member
Registered: 2012-02-04
Posts: 24

[SOLVED]Patching dwm

Hi, I know there is a post about it but when I follow the steps I get this:

can't find file to patch at input line 72
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|
|diff -r 23b71491e149 config.def.h
|--- a/config.def.h	Thu Dec 02 10:16:47 2010 +0000
|+++ b/config.def.h	Fri Jan 07 15:10:06 2011 +0100
--------------------------
File to patch: 

What the hell is config.def.h? It isn't in my dwm folder? And nobody talks about it in the wiki page?
Can you give me  step by step instructions to patch dwm? I really didn't understand the PKGBUILD concept.
I am trying to patch bottomstack.

Last edited by alpa8le (2012-02-19 14:33:11)

Offline

#2 2012-02-14 14:01:42

stlarch
Member
From: hell
Registered: 2010-12-25
Posts: 1,265

Re: [SOLVED]Patching dwm

Hi. First off, they probably won't give you a step by step instruction for anything. Especially dwm. Hand holding is frowned upon. Once you prove yourself and have specific questions, people will be more inclined to help. Did you check the dwm website? There are also several helpful threads on this forum about dwm. I'll give you a hint to help you get started. A lot of people just use the source instead of using a PKGBUILD. You don't have to install it after running make. Just copy the executable to /bin or somewhere in your path and run it. It might be easier for you that way. I'm not trying to talk you out of using abs (people do it both ways), but it's one of the exceptions imo. Good luck.

Offline

#3 2012-02-14 14:27:22

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: [SOLVED]Patching dwm

Sounds more like an issue of not understanding how patch(1) works... See the -p option.

Offline

#4 2012-02-14 14:37:13

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: [SOLVED]Patching dwm

Once you have copied the dwm directory from abs, i believe you need to run makepkg once to fetch all the sources from the suckless hg repo. After that you can find config.def.h in the src/dwm directory under your build directory.

However, the supplied config.h is a verbatim copy of the original config.def.h, so you can just use that for any configuration.


ᶘ ᵒᴥᵒᶅ

Offline

#5 2012-02-14 14:57:07

alpa8le
Member
Registered: 2012-02-04
Posts: 24

Re: [SOLVED]Patching dwm

Thanks for the replies. I have a config.def.h in ~/dwm/src/dwm-6.0. But I still couldn't figure out how to apply the bstack.diff.

Offline

#6 2012-02-14 15:59:40

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: [SOLVED]Patching dwm

Ok, here's what you do:
Use this PKGBUILD

pkgname=dwm
pkgver=6.0
pkgrel=1
pkgdesc='A dynamic window manager for X'
url='http://dwm.suckless.org'
arch=('i686' 'x86_64')
license=('MIT')
depends=('libx11' 'libxinerama' 'dmenu')
source=(http://dl.suckless.org/$pkgname/$pkgname-$pkgver.tar.gz)

build() {
	cd $srcdir/$pkgname-$pkgver
	if test -e $startdir/config.h
	then
		msg "use custom config.h"
		cp ${startdir}/config.h .
	else
		msg "use default config.h"
	fi

	for i in $startdir/*\.patch
	do
		msg "patching with $i"
		patch -i $i
	done
	make X11INC=/usr/include/X11 X11LIB=/usr/lib/X11
}

package() {
	cd $srcdir/$pkgname-$pkgver
	make PREFIX=/usr DESTDIR="${pkgdir}" install
	install -m644 -D LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
	install -m644 -D README "${pkgdir}/usr/share/doc/${pkgname}/README"
}
md5sums=('8bb00d4142259beb11e13473b81c0857')

It's more practical than the one you find on abs.

First, you want to download the sourcecode. This can be done with e.g. "makepkg -o". After that, you'll have the tarball with the sources in it. Extract this tarball with "bsdtar -xf dwm-6.0.tar.gz". Then copy the default config to the current directory with "cp dwm-6.0/config.def.h config.h". Yes it has to be renamed from config.def.h to config.h, that's not a mistake I made here. After that, edit the config.h so it fits your needs. Read it carefully, so you see how it works. Also customize the key combinations that are used in the config.h. You definitely should remember how to open a terminal!!
You don't really need to know C to get it, I'm no programmer and can do it, so you can too.

Applying the patch:
Here's a working patch, download it and name it e.g. 01-bstack.patch. The 01 at the beginning is important, because if you add other patches later, you have to be sure, that the order stays right, otherwise you might run into problems. It's also important to have .patch as extension, because that's how my PKGBUILD works.
Now, after you've edited the config.h and downloaded the patch, you can run "makepkg -sirfc" (I use that one). You'll (hopefully) see the following output

...
patching file dwm.c
dwm build options:
CC dwm.c
CFLAGS   = -std=c99 -pedantic -Wall -Os -I. -I/usr/include -I/usr/include/X11 -DVERSION="6.0" -DXINERAMA
LDFLAGS  = -s -L/usr/lib -lc -L/usr/lib/X11 -lX11 -L/usr/lib/X11 -lXinerama
CC       = cc
dwm.c: In function ‘keypress’:
dwm.c:1088:2: warning: ‘XKeycodeToKeysym’ is deprecated (declared at /usr/include/X11/Xlib.h:1695) [-Wdeprecated-declarations]
dwm.c: At top level:
dwm.c:2131:1: warning: ‘bstack’ defined but not used [-Wunused-function]
CC -o dwm
==> Entering fakeroot environment...
==> Starting package()...
dwm build options:
CFLAGS   = -std=c99 -pedantic -Wall -Os -I. -I/usr/include -I/usr/X11R6/include -DVERSION="6.0" -DXINERAMA
LDFLAGS  = -s -L/usr/lib -lc -L/usr/X11R6/lib -lX11 -L/usr/X11R6/lib -lXinerama
CC       = cc
installing executable file to /home/army/Programme/AUR/dwm/dwm-dau/pkg/usr/bin
installing manual page to /home/army/Programme/AUR/dwm/dwm-dau/pkg/usr/share/man/man1
...

Look at the warning

dwm.c:2131:1: warning: ‘bstack’ defined but not used [-Wunused-function]

(I don't know where the warnings on top of that come from, they aren't supposed to be there...)
This means (like it reads), that bstack is defined, but not being used. So you'll have to put this into the config.h. Since you looked through the config.h, you'll know, that there are two sections, which are required for layouts. Bstack is a new layout, so you'll have to add this to the others.

first section:

before:

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

after:

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

Ok, before, "tile" was the first entry, "NULL" was the second and "monocle" was the third. Now the order has changed a bit. This is important for the second section:

before:

     { MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
     { MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
     { MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },

after:

     { MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
     { MODKEY,                       XK_b,      setlayout,      {.v = &layouts[1]} },
     { MODKEY,                       XK_f,      setlayout,      {.v = &layouts[2]} },
     { MODKEY,                       XK_m,      setlayout,      {.v = &layouts[3]} },

You see, the layouts are accessed by the numbers, so you'll have to be careful with the order. Of course it would have been easier to just add bstack to the bottom of the layouts list, but I think now this way has a better learning effect.

Ok, now, save the config.h and rebuild it with "makepkg -sirfc" and everything should be fine.

Last edited by Army (2012-02-14 16:02:03)

Offline

#7 2012-02-14 17:31:24

alpa8le
Member
Registered: 2012-02-04
Posts: 24

Re: [SOLVED]Patching dwm

Done! Thanks man, that was what i was searching for. I am just a newbie - or noob - in this stuff. So thanks for the reply. No, I didn't just copy and paste what you said. I really tried to understand the concept.
But, isnt togglebar and setlayout overlap?

Last edited by alpa8le (2012-02-14 17:40:22)

Offline

#8 2012-02-14 17:41:26

alpa8le
Member
Registered: 2012-02-04
Posts: 24

Re: [SOLVED]Patching dwm

{ MODKEY,                       XK_b,      setlayout,      {.v = &layouts[1]} },
and
{ MODKEY,                       XK_b,      togglebar,      {0} },
Do they overlap?

Offline

#9 2012-02-14 18:17:04

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: [SOLVED]Patching dwm

Oh, you're right! I actually don't use those key combinations, so I didn't look too closely for overlaps. As I said, use your custom key combinations! I just wanted to show you how it's done.

Are you planning to use other patches as well? If so, you might run into problems, because e.g. the patch is created for the original source code, which now is changed a bit. To solve such problems, you'll maybe have to patch manually. Should I write a howto about this too?

If you want, check out my git account, I have some neat patches including bstack.

Offline

#10 2012-02-14 18:21:56

stlarch
Member
From: hell
Registered: 2010-12-25
Posts: 1,265

Re: [SOLVED]Patching dwm

^^You can do something like

{ MODKEY|ShiftMask,                       XK_b,      togglebar,      {0} },

or change the other part to something like

{ MODKEY,                       XK_v,      setlayout,      {.v = &layouts[1]} },

or whatever you want. I wasn't trying to be a jerk before either.

edit:too slow

Last edited by stlarch (2012-02-14 18:22:19)

Offline

#11 2012-02-14 18:56:16

alpa8le
Member
Registered: 2012-02-04
Posts: 24

Re: [SOLVED]Patching dwm

Army, Ok I am checking them now. If I run into problems I'll ask you. Thanks.
stlarch, I already changed them. I posted that to inform just if somebody else will use this help and face the overlap.

Last edited by alpa8le (2012-02-14 19:18:05)

Offline

Board footer

Powered by FluxBB