You are not logged in.
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)
Offline
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
Offline
Offline
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
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)
Offline
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
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
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
Last edited by mhertz (2012-04-10 23:32:31)
Offline
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
Last edited by Army (2012-04-11 07:47:14)
Offline
I think I might have created my first patch (or well, extended another one ) 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
Arch64/DWM || My Dropbox referral link
Offline
Gah, still didn't do it correctly.. 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
@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
@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
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
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
Make it idiot-proof, and someone will breed a better idiot.
-- Oliver Elphick
Offline
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
@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
Make it idiot-proof, and someone will breed a better idiot.
-- Oliver Elphick
Offline
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
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
Thanks @Unia!
So I will have set of patches which will fit only my dwm? Cool, but there are so many work..
Why do you think OK100 (and many more) use numbers in the patch names..?
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
patch request: Is it possible to get >10 colours into the standard dwm statusbar (preferably 16-24)?
All configs @ https://github.com/w0ng
Offline