You are not logged in.

#701 2012-04-08 20:19:58

ivoarch
Member
Registered: 2011-03-31
Posts: 436

Re: DWM Hackers Unite! Share (or request) dwm patches.

add this in 

/init screen/ 

  -  bh = dc.h = dc.font.height + 6; 
+ bh = dc.h = dc.font.height + 4; 

void
drawtext(const char *text, unsigned long col[ColLast], Bool invert) {
 

 -    y = dc.y  + (dc.h / 2) - (h / 2) + dc.font.ascent;  
 +    y = dc.y + 2 + (dc.h / 2) - (h / 2) + dc.font.ascent;  

and testing

Last edited by ivoarch (2012-04-08 20:20:52)


I love GnuEmacs, GnuScreen, ratpoison, and conkeror.
Github )||( Weblog

Offline

#702 2012-04-08 20:26:09

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

I can't find the y = dc.y + 2 + (dc.h / 2) .... line. The only thing that comes close is

void
drawtext(const char *text, unsigned long col[ColLast], Bool pad) {
        char buf[256];
        int i, x, y, h, len, olen;

        XSetForeground(dpy, dc.gc, col[ColBG]);
        XFillRectangle(dpy, dc.drawable, dc.gc, dc.x, dc.y, dc.w, dc.h);
        if(!text)
                return;
        olen = strlen(text);
    h = pad ? (dc.font.ascent + dc.font.descent) : 0;
    y = dc.y + ((dc.h + dc.font.ascent - dc.font.descent) / 2);

EDIT: It turns out that part is edited because of the statuscolors patch. So, what do I do with this part to get the same result?

Last edited by Unia (2012-04-08 20:29:49)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#703 2012-04-08 20:41:31

ivoarch
Member
Registered: 2011-03-31
Posts: 436

Re: DWM Hackers Unite! Share (or request) dwm patches.


I love GnuEmacs, GnuScreen, ratpoison, and conkeror.
Github )||( Weblog

Offline

#704 2012-04-08 20:46:52

ivoarch
Member
Registered: 2011-03-31
Posts: 436

Re: DWM Hackers Unite! Share (or request) dwm patches.

You have to edit some lines from  statuscolor.patch   
look in the dwm.c from the autor @kcirick

But you can break something


I love GnuEmacs, GnuScreen, ratpoison, and conkeror.
Github )||( Weblog

Offline

#705 2012-04-08 20:49:49

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

I see. I applied those lines over the ones I have and things seem to work. Now I gotta figure out how to get a bar above occupied inactive tags and play with the colors!

EDIT: No wait, there's a little thingie that's off: my statusbar is cut off on the right of my screen. How can I fix this...?

Last edited by Unia (2012-04-08 20:55:03)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#706 2012-04-08 21:00:22

ivoarch
Member
Registered: 2011-03-31
Posts: 436

Re: DWM Hackers Unite! Share (or request) dwm patches.

Unia wrote:

I see. I applied those lines over the ones I have and things seem to work. Now I gotta figure out how to get a bar above occupied inactive tags and play with the colors!

The problem is here 

 
// draw tag names
	for(i = 0; i < LENGTH(tags); i++) {
		dc.w = TEXTW(tags[i]);
	>	col = m->tagset[m->seltags] & 1 << i ? dc.colors[1] : dc.colors[0];
	>	ltcol = occ & 1 << i || m->tagset[m->seltags] & 1 << i ? dc.colors[0] : dc.colors[2]; 

Last edited by ivoarch (2012-04-08 21:01:25)


I love GnuEmacs, GnuScreen, ratpoison, and conkeror.
Github )||( Weblog

Offline

#707 2012-04-08 21:16:51

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

Yea I assumed so. Can you help me with the off-placed statusbar too?


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#708 2012-04-10 22:02:24

whooper
Member
From: Germany
Registered: 2008-12-24
Posts: 37

Re: DWM Hackers Unite! Share (or request) dwm patches.

Hi,

I know it's against dwm's philosophy but is there a patch that makes dwm follow a new spawned window to a tag?

Also could somebody write a patch to remove borders on bstack mode when there's only 1 window?

Thanks

Offline

#709 2012-04-10 23:30:33

mhertz
Member
From: Denmark
Registered: 2010-06-19
Posts: 681

Re: DWM Hackers Unite! Share (or request) dwm patches.

On Army's github, he has a patch for no-borders when max 1 client, so I guess that also works on bstack mode, but I dunno...

https://github.com/UliArmy/dwm-hg-patches/

Jokerboy also has a "borderless" patch, but I think it's just for monocle mode...

As to moving to tag of newly spawned app automatically, then I've never seen such patch, except the viewontag patch, but that's just for when moving clients from tag to tag...

Btw, monsterwm features these nice requests allready wink

Last edited by mhertz (2012-04-10 23:32:31)

Offline

#710 2012-04-11 07:46:00

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

Re: DWM Hackers Unite! Share (or request) dwm patches.

Yes, it works for every layout, because it counts clients. And to be fair, Jokerboy made this patch, right here in this thread somewhere.

That reminds me, I should update my github stuff smile

Last edited by Army (2012-04-11 07:47:14)

Offline

#711 2012-04-15 17:29:39

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

I think I might have created my first patch (or well, extended another one tongue) In the monthly screenshot thread, Kuraku shared a patch that removes the title of the selected client in the bar. I have achieved the same endresult by applying the patch that gives you the option to set a maximum value for the title and I set it to zero, but I think this fix is cleaner.

However, his patch still showed the little square on floating clients. I have looked into this and I have extended the patch so that it doesn't show the square on selected floating clients anymore. I'm not quite sure that what I have done is actually the right thing to do and I simply just removed one more line to accomplish this result. So my request would be that you, the DWM/C/patch guru's, could check my patch to see that what I have done is the correct way of doing this or that there's any other better way.

Here's my patch:

 --- dwm.c.orig  2012-04-15 19:21:46.462941023 +0200
+++ dwm.c.patched       2012-04-15 19:21:35.649607874 +0200
@@ -800,8 +800,7 @@
                if(m->sel) {
         col = dc.colors[ m == selmon ? 1 : 0 ];
         drawtext(m->sel->name, col, True);
-        drawsquare(m->sel->isfixed, m->sel->isfloating, col);
-               }
+               }
                else
                        drawtext(NULL, dc.colors[0], False);
        }
@@ -2107,10 +2106,7 @@
 
 void
 updatetitle(Client *c) {
-       if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
-               gettextprop(c->win, XA_WM_NAME, c->name, sizeof c->name);
-       if(c->name[0] == '\0') /* hack to mark broken clients */
-               strcpy(c->name, broken);
+       *c->name = '\0';
 }
 
 void

Thanks in advance guys!


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#712 2012-04-16 08:11:37

JokerBoy
Member
From: România
Registered: 2009-09-24
Posts: 641

Re: DWM Hackers Unite! Share (or request) dwm patches.

Offline

#713 2012-04-16 10:53:24

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

Gah, still didn't do it correctly.. big_smile It's fun to play with though, now to find some other small things I can play with! (got any recommendations as for a book or something to learn basic C? You can send me an email on this if you got any suggestions!)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#714 2012-04-18 23:53:00

kuraku
Member
Registered: 2012-01-03
Posts: 202

Re: DWM Hackers Unite! Share (or request) dwm patches.

@Unia
Actually, that little square is good for finding aout what clients are not stacked (eg. floating). If client is floating, you will see that (empty) square. It is pretty neat i can say.

p.s. I renamed that patch to remove "." from the end (silly me, it was pretty late when i uploaded it).

Offline

#715 2012-04-19 07:47:25

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

kuraku wrote:

@Unia
Actually, that little square is good for finding aout what clients are not stacked (eg. floating). If client is floating, you will see that (empty) square. It is pretty neat i can say.

p.s. I renamed that patch to remove "." from the end (silly me, it was pretty late when i uploaded it).

The only windows I have floating are either mplayer video or Skype webcam. I don't need any indicator for those wink


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#716 2012-04-19 16:28:23

frony0
Member
From: United Kingdom
Registered: 2011-05-01
Posts: 44

Re: DWM Hackers Unite! Share (or request) dwm patches.

After a long search it seems nobody has posted a volume patch for DWM. I know it's nice to keep it simple, but the overhead of calling amixer 25 times per second just isn't reasonable in my opinion so I wrote a patch myself. I'm no C guru and the code is pretty awful so feel free to amend it, but it does the job.

NB: Assumes "default" card and both "Master" and "PCM" channels are available.

diff -rup a/config.def.h b/config.def.h
--- a/config.def.h	2011-12-19 15:02:46.000000000 +0000
+++ b/config.def.h	2012-04-19 16:59:13.000000000 +0100
@@ -74,6 +74,16 @@ static Key keys[] = {
 	{ MODKEY,                       XK_period, focusmon,       {.i = +1 } },
 	{ MODKEY|ShiftMask,             XK_comma,  tagmon,         {.i = -1 } },
 	{ MODKEY|ShiftMask,             XK_period, tagmon,         {.i = +1 } },
+	{ ControlMask|ShiftMask,		0x1008ff13, incvolpcm,     {.i = +16 } },    
+	{ ControlMask|ShiftMask,		0x1008ff11, incvolpcm,     {.i = -16 } },
+	{ ControlMask,					0x1008ff13, incvolmaster,  {.i = +8 } },    
+	{ ControlMask,					0x1008ff11, incvolmaster,  {.i = -8 } },
+	{ ShiftMask,                    0x1008ff13, incvolmaster,  {.i = +2 } },    
+	{ ShiftMask,                    0x1008ff11, incvolmaster,  {.i = -2 } },
+	{ 0,							0x1008ff13, incvolmaster,  {.i = +1 } },    
+	{ 0,                            0x1008ff11, incvolmaster,  {.i = -1 } },
+	{ ShiftMask,					0x1008ff12, mutevol,       {.i =  0 } }, /* definite mute */
+	{ 0,                            0x1008ff12, mutevol,       {.i = -1 } }, /* toggle mute */
 	TAGKEYS(                        XK_1,                      0)
 	TAGKEYS(                        XK_2,                      1)
 	TAGKEYS(                        XK_3,                      2)
diff -rup a/config.mk b/config.mk
--- a/config.mk	2011-12-19 15:02:46.000000000 +0000
+++ b/config.mk	2012-04-19 16:59:13.000000000 +0100
@@ -16,7 +16,7 @@ XINERAMAFLAGS = -DXINERAMA
 
 # includes and libs
 INCS = -I. -I/usr/include -I${X11INC}
-LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS}
+LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS} -lasound
 
 # flags
 CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
diff -rup a/dwm.c b/dwm.c
--- a/dwm.c	2011-12-19 15:02:46.000000000 +0000
+++ b/dwm.c	2012-04-19 16:59:13.000000000 +0100
@@ -285,6 +285,7 @@ static Monitor *mons = NULL, *selmon = N
 static Window root;
 
 /* configuration, allows nested code to access above variables */
+#include "volume.h"
 #include "config.h"
 
 /* compile-time check if all tags fit into an unsigned int bit array. */
diff -rup a/Makefile b/Makefile
--- a/Makefile	2011-12-19 15:02:46.000000000 +0000
+++ b/Makefile	2012-04-19 16:59:13.000000000 +0100
@@ -3,7 +3,7 @@
 
 include config.mk
 
-SRC = dwm.c
+SRC = dwm.c volume.c
 OBJ = ${SRC:.c=.o}
 
 all: options dwm
diff -rup a/volume.c b/volume.c
--- a/volume.c	2012-04-19 16:38:04.000000000 +0100
+++ b/volume.c	2012-04-19 16:38:04.000000000 +0100
@@ -0,0 +1,133 @@
+#include <alloca.h>
+#include <alsa/asoundlib.h>
+
+typedef union {
+	int i;
+	unsigned int ui;
+	float f;
+	const void *v;
+} Arg;
+
+#include <volume.h>
+
+snd_mixer_t *handle;
+snd_mixer_selem_id_t *sid;
+
+snd_mixer_elem_t *getelem(const char *selem_name) {
+	if (handle == NULL) init();
+
+	snd_mixer_selem_id_alloca(&sid);
+	snd_mixer_selem_id_set_index(sid, 0);
+	snd_mixer_selem_id_set_name(sid, selem_name);
+
+	return snd_mixer_find_selem(handle, sid);
+}
+
+long getvol(const char *selem_name) {
+	long min, max, vol;
+
+	snd_mixer_elem_t* elem = getelem(selem_name);
+
+	snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
+	snd_mixer_selem_get_playback_volume(elem, 0, &vol);
+	
+	return vol;
+}
+
+void setvol(long vol, const char *selem_name) {
+	long min, max;
+
+	snd_mixer_elem_t* elem = getelem(selem_name);
+
+	snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
+
+	if (vol < min) vol = min;
+	if (vol > max) vol = max;
+
+	snd_mixer_selem_set_playback_volume_all(elem, vol);
+}
+
+int getmute(void) {
+	const char channel[] = "Master";
+	int status;
+
+	snd_mixer_elem_t* elem = getelem(channel);
+
+	snd_mixer_selem_get_playback_switch(elem, 0, &status);
+
+	return status;
+}
+
+void setmute(int status) {
+	const char channel[] = "Master";
+
+	snd_mixer_elem_t* elem = getelem(channel);
+
+	snd_mixer_selem_set_playback_switch(elem, 0, status);
+}
+
+void togglemute(void) {
+	const char channel[] = "Master";
+	int status;
+
+	snd_mixer_elem_t* elem = getelem(channel);
+
+	snd_mixer_selem_get_playback_switch(elem, 0, &status);
+	switch (status) {
+		case 0:
+			status = 1;
+			break;
+		case 1:
+			status = 0;
+			break;
+		default:
+			return;
+	}
+	snd_mixer_selem_set_playback_switch(elem, 0, status);
+}
+
+void init(void) {
+	const char card[] = "default";
+
+	snd_mixer_open(&handle, 0);
+	snd_mixer_attach(handle, card);
+	snd_mixer_selem_register(handle, NULL, NULL);
+	snd_mixer_load(handle);
+}
+
+void deinit(void) {
+	snd_mixer_close(handle);
+}
+
+void incvolmaster(const Arg *arg) {
+	const char channel[] = "Master";
+	int delta = arg->i;
+	long vol = getvol(channel);
+
+	setvol(vol+delta, channel);
+}
+
+void incvolpcm(const Arg *arg) {
+	const char channel[] = "PCM";
+	int delta = arg->i;
+	long vol = getvol(channel);
+
+	setvol(vol+delta, channel);
+}
+
+void mutevol(const Arg *arg) {
+	switch (arg->i) {
+		case -1:
+			togglemute();
+			return;
+		case 0:
+			setmute(0);
+			return;
+		case 1:
+			setmute(1);
+			return;
+	}
+
+	return;
+}
+
diff -rup a/volume.h b/volume.h
--- a/volume.h	2012-04-19 16:38:40.000000000 +0100
+++ b/volume.h	2012-04-19 16:38:40.000000000 +0100
@@ -0,0 +1,5 @@
+void init(void);
+void deinit(void);
+void incvolmaster(const Arg*);
+void incvolpcm(const Arg*);
+void mutevol(const Arg*);

Enjoy smile


Make it idiot-proof, and someone will breed a better idiot.
-- Oliver Elphick

Offline

#717 2012-04-19 19:07:01

kemmotar
Member
From: Ukraine
Registered: 2012-01-08
Posts: 43
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

Hi!
I'm just few days in dwm and today try to patch (my first patching) it with systray patch dwm.suckless.org/patches/systray, but when compiling I got this errors - https://gist.github.com/2423098

Offline

#718 2012-04-19 19:34:52

frony0
Member
From: United Kingdom
Registered: 2011-05-01
Posts: 44

Re: DWM Hackers Unite! Share (or request) dwm patches.

@Kemmotar the patch changes config.def.h, not config.h - You have to copy the changes across manually to preserve your custom config. That's all that's missing smile


Make it idiot-proof, and someone will breed a better idiot.
-- Oliver Elphick

Offline

#719 2012-04-19 20:17:50

kemmotar
Member
From: Ukraine
Registered: 2012-01-08
Posts: 43
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

@frony0 Thanks! smile

Offline

#720 2012-04-24 10:28:09

kemmotar
Member
From: Ukraine
Registered: 2012-01-08
Posts: 43
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

Can't patch vanilla dwm. Trying this or this. Geting this:

 11:05 [ dwm ] $ patch < 01-dwm-6.0-scratchpad.diff 
patching file dwm.c
Hunk #1 succeeded at 230 (offset -10 lines).
Hunk #2 succeeded at 288 (offset -11 lines).
Hunk #3 succeeded at 1145 (offset -28 lines).
Hunk #4 succeeded at 1760 with fuzz 2 (offset -28 lines).
Hunk #5 FAILED at 2115.
Hunk #6 FAILED at 2133.
2 out of 6 hunks FAILED -- saving rejects to file dwm.c.rej
 11:06 [ dwm ] $ 

As I understand, I must edit patch, but how to do this correctly?

Offline

#721 2012-04-24 10:42:58

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

kemmotar wrote:

Can't patch vanilla dwm. Trying this or this. Geting this:

 11:05 [ dwm ] $ patch < 01-dwm-6.0-scratchpad.diff 
patching file dwm.c
Hunk #1 succeeded at 230 (offset -10 lines).
Hunk #2 succeeded at 288 (offset -11 lines).
Hunk #3 succeeded at 1145 (offset -28 lines).
Hunk #4 succeeded at 1760 with fuzz 2 (offset -28 lines).
Hunk #5 FAILED at 2115.
Hunk #6 FAILED at 2133.
2 out of 6 hunks FAILED -- saving rejects to file dwm.c.rej
 11:06 [ dwm ] $ 

As I understand, I must edit patch, but how to do this correctly?

You can manually patch it in. I do it like so:

1. Copy ${srcdir}/dwm-6.0/dwm.c and name it dwm.c.patched
2. Open the patch and dwm.c.patched and search for the strings to replace/add. Do so manually.
3. Create a new, vanilla dwm.c or use the one you copied and run diff -u dwm.c.orig dwm.c.patched > nameofthepatch.diff.

That'll create a "new" patched, which will work against vanilla dwm.c

Last edited by Unia (2012-04-24 10:43:44)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#722 2012-04-24 10:53:31

kemmotar
Member
From: Ukraine
Registered: 2012-01-08
Posts: 43
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

Thanks @Unia! smile
So I will have set of patches which will fit only my dwm? Cool, but there are so many work.. hmm

Offline

#723 2012-04-24 10:56:40

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

kemmotar wrote:

Thanks @Unia! smile
So I will have set of patches which will fit only my dwm? Cool, but there are so many work.. hmm

Why do you think OK100 (and many more) use numbers in the patch names..? wink


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#724 2012-04-24 11:12:23

kemmotar
Member
From: Ukraine
Registered: 2012-01-08
Posts: 43
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

Patches queue smile
Thanks, now I'm deeper understanding dwm!

Offline

#725 2012-04-24 15:32:18

w0ng
Member
From: Australia
Registered: 2009-06-04
Posts: 88
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

patch request: Is it possible to get >10 colours into the standard dwm statusbar (preferably 16-24)?

Offline

Board footer

Powered by FluxBB