[dev] [st] Add a newline to the string printed in die
After a call to die the program exits and the shell take the control, so it is better for the user the shell begins in an new line, and it is better for the programmer don't have to explicitly add it in each call to die. --- st.c | 45 +++-- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/st.c b/st.c index da5f78d..9789eef 100644 --- a/st.c +++ b/st.c @@ -431,7 +431,7 @@ xmalloc(size_t len) { void *p = malloc(len); if(!p) - die(Out of memory\n); + die(Out of memory); return p; } @@ -439,7 +439,7 @@ xmalloc(size_t len) { void * xrealloc(void *p, size_t len) { if((p = realloc(p, len)) == NULL) - die(Out of memory\n); + die(Out of memory); return p; } @@ -449,7 +449,7 @@ xcalloc(size_t nmemb, size_t size) { void *p = calloc(nmemb, size); if(!p) - die(Out of memory\n); + die(Out of memory); return p; } @@ -890,6 +890,7 @@ die(const char *errstr, ...) { va_start(ap, errstr); vfprintf(stderr, errstr, ap); + fputc('\n', stderr); va_end(ap); exit(EXIT_FAILURE); } @@ -934,7 +935,7 @@ sigchld(int a) { int stat = 0; if(waitpid(pid, stat, 0) 0) - die(Waiting for pid %hd failed: %s\n, pid, SERRNO); + die(Waiting for pid %hd failed: %s, pid, SERRNO); if(WIFEXITED(stat)) { exit(WEXITSTATUS(stat)); @@ -950,11 +951,11 @@ ttynew(void) { /* seems to work fine on linux, openbsd and freebsd */ if(openpty(m, s, NULL, NULL, w) 0) - die(openpty failed: %s\n, SERRNO); + die(openpty failed: %s, SERRNO); switch(pid = fork()) { case -1: - die(fork failed\n); + die(fork failed); break; case 0: setsid(); /* create a new process group */ @@ -962,7 +963,7 @@ ttynew(void) { dup2(s, STDOUT_FILENO); dup2(s, STDERR_FILENO); if(ioctl(s, TIOCSCTTY, NULL) 0) - die(ioctl TIOCSCTTY failed: %s\n, SERRNO); + die(ioctl TIOCSCTTY failed: %s, SERRNO); close(s); close(m); execsh(); @@ -1004,7 +1005,7 @@ ttyread(void) { /* append read bytes to unprocessed bytes */ if((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) 0) - die(Couldn't read from shell: %s\n, SERRNO); + die(Couldn't read from shell: %s, SERRNO); /* process every complete utf8 char */ buflen += ret; @@ -1024,7 +1025,7 @@ ttyread(void) { void ttywrite(const char *s, size_t n) { if(write(cmdfd, s, n) == -1) - die(write error on tty: %s\n, SERRNO); + die(write error on tty: %s, SERRNO); } void @@ -2204,7 +2205,7 @@ xloadcols(void) { if(!colorname[i]) continue; if(!XftColorAllocName(xw.dpy, xw.vis, xw.cmap, colorname[i], dc.col[i])) { - die(Could not allocate color '%s'\n, colorname[i]); + die(Could not allocate color '%s', colorname[i]); } } @@ -2216,7 +2217,7 @@ xloadcols(void) { color.green = g == 0 ? 0 : 0x3737 + 0x2828 * g; color.blue = b == 0 ? 0 : 0x3737 + 0x2828 * b; if(!XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, color, dc.col[i])) { - die(Could not allocate color %d\n, i); + die(Could not allocate color %d, i); } i++; } @@ -2227,7 +2228,7 @@ xloadcols(void) { color.red = color.green = color.blue = 0x0808 + 0x0a0a * r; if(!XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, color, dc.col[i])) { - die(Could not allocate color %d\n, i); + die(Could not allocate color %d, i); } } } @@ -2314,7 +2315,7 @@ xloadfonts(char *fontstr, int fontsize) { } if(!pattern) - die(st: can't open font %s\n, fontstr); + die(st: can't open font %s, fontstr); if(fontsize 0) { FcPatternDel(pattern, FC_PIXEL_SIZE); @@ -2335,7 +2336,7 @@ xloadfonts(char *fontstr, int fontsize) { } if(xloadfont(dc.font, pattern)) - die(st: can't open font %s\n, fontstr); + die(st: can't open font %s, fontstr); /* Setting character width and height. */ xw.cw = dc.font.width; @@ -2344,16 +2345,16 @@ xloadfonts(char *fontstr, int fontsize) { FcPatternDel(pattern, FC_WEIGHT);
[dev] [PATCH] dwm: replace deprecated XKeycodeToKeysym
XKeycodeToKeysym is now deprecated in favour of XkbKeycodeToKeysym (X11/XKBlib.h). This patch substitutes the former with the latter in dwm.c Signed-off-by: Antonio Quartulli or...@autistici.org --- dwm.c | 21 - 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/dwm.c b/dwm.c index d9443da..3ad3bf2 100644 --- a/dwm.c +++ b/dwm.c @@ -33,6 +33,7 @@ #include X11/cursorfont.h #include X11/keysym.h #include X11/Xatom.h +#include X11/XKBlib.h #include X11/Xlib.h #include X11/Xproto.h #include X11/Xutil.h @@ -1080,7 +1081,7 @@ keypress(XEvent *e) { XKeyEvent *ev; ev = e-xkey; - keysym = XKeycodeToKeysym(dpy, (KeyCode)ev-keycode, 0); + keysym = XkbKeycodeToKeysym(dpy, (KeyCode)ev-keycode, 0, 0); for(i = 0; i LENGTH(keys); i++) if(keysym == keys[i].keysym CLEANMASK(keys[i].mod) == CLEANMASK(ev-state) @@ -1413,6 +1414,20 @@ resizemouse(const Arg *arg) { focus(NULL); } } +void +setwmname(const char *name) { + Window wincheck = XCreateSimpleWindow(dpy, root, -10, -10, 5, 5, 0, 0, 0); + + if(wincheck != None) { + Atom m_net_supporting_wm_check = XInternAtom(dpy, _NET_SUPPORTING_WM_CHECK, False); + Atom utf8_string = XInternAtom(dpy, UTF8_STRING, False); + + XChangeProperty(dpy, root, m_net_supporting_wm_check, XA_WINDOW, 32, PropModeReplace, (unsigned char *)wincheck, 1); + XChangeProperty(dpy, wincheck, m_net_supporting_wm_check, XA_WINDOW, 32, PropModeReplace, (unsigned char *)wincheck, 1); + XChangeProperty(dpy, wincheck, netatom[NetWMName], utf8_string, 8, PropModeReplace, (unsigned char *)name, strlen(name)); + } +} + void restack(Monitor *m) { @@ -1615,6 +1630,7 @@ setup(void) { netatom[NetWMWindowType] = XInternAtom(dpy, _NET_WM_WINDOW_TYPE, False); netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, _NET_WM_WINDOW_TYPE_DIALOG, False); netatom[NetClientList] = XInternAtom(dpy, _NET_CLIENT_LIST, False); + setwmname(LG3D); /* init cursors */ cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); @@ -1626,6 +1642,9 @@ setup(void) { dc.sel[ColBorder] = getcolor(selbordercolor); dc.sel[ColBG] = getcolor(selbgcolor); dc.sel[ColFG] = getcolor(selfgcolor); + dc.urg[ColBorder] = getcolor(urgbordercolor); + dc.urg[ColBG] = getcolor(selbgcolor); + dc.urg[ColFG] = getcolor(selfgcolor); dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen)); dc.gc = XCreateGC(dpy, root, 0, NULL); XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); -- 1.8.0
Re: [dev] [st] Add a newline to the string printed in die
Greetings. On Tue, 11 Dec 2012 09:40:16 +0100 Roberto E. Vargas Caballero k...@shike2.com wrote: After a call to die the program exits and the shell take the control, so it is better for the user the shell begins in an new line, and it is better for the programmer don't have to explicitly add it in each call to die. No, this will change the die() behaviour between all suckless projects. Rejected. Please send patches as attached files. Sincerely, Christoph Lohmann
Re: [dev] [dwm] Looking for a focusonclick that with MODKEY+Button3
On Sat, Dec 8, 2012 at 7:55 PM, Eric Pruitt eric.pru...@gmail.com wrote: Is there a focusonclick patch that anyone is aware of that still works with things like Right Click + Alt? Because of the change from Async to Sync in grabbuttons in the focusonclick patch, I am unable to use certain mouse shortcuts. The attached patch works for me. Bert dwm-6.0-clickfocus.diff Description: Binary data
Re: [dev] [st] Add a newline to the string printed in die
No, this will change the die() behaviour between all suckless projects. Then, change die in all the projects, it is the usual way of working with other issues, no? Please send patches as attached files. Since we are using now git, it is easier and logic send the patches in this way, so the code of the patch can be included and modified in replies. You only have to use git am if you want to incorpore then to the main repository ,and it will keep the correct author and commiter, that I can see this information is lost now (I think it is not the correct way put a 'thanks' in the commit message). Best regards,
Re: [dev] [PATCH] dwm: replace deprecated XKeycodeToKeysym
On Tue, Dec 11, 2012 at 09:35:12AM +0100, Antonio Quartulli wrote: XKeycodeToKeysym is now deprecated in favour of XkbKeycodeToKeysym (X11/XKBlib.h). This patch substitutes the former with the latter in dwm.c Signed-off-by: Antonio Quartulli or...@autistici.org --- } +void +setwmname(const char *name) { + Window wincheck = XCreateSimpleWindow(dpy, root, -10, -10, 5, 5, 0, 0, 0); + + if(wincheck != None) { + Atom m_net_supporting_wm_check = XInternAtom(dpy, _NET_SUPPORTING_WM_CHECK, False); + Atom utf8_string = XInternAtom(dpy, UTF8_STRING, False); + + XChangeProperty(dpy, root, m_net_supporting_wm_check, XA_WINDOW, 32, PropModeReplace, (unsigned char *)wincheck, 1); + XChangeProperty(dpy, wincheck, m_net_supporting_wm_check, XA_WINDOW, 32, PropModeReplace, (unsigned char *)wincheck, 1); + XChangeProperty(dpy, wincheck, netatom[NetWMName], utf8_string, 8, PropModeReplace, (unsigned char *)name, strlen(name)); + } +} + void restack(Monitor *m) { @@ -1615,6 +1630,7 @@ setup(void) { netatom[NetWMWindowType] = XInternAtom(dpy, _NET_WM_WINDOW_TYPE, False); netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, _NET_WM_WINDOW_TYPE_DIALOG, False); netatom[NetClientList] = XInternAtom(dpy, _NET_CLIENT_LIST, False); + setwmname(LG3D); /* init cursors */ cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); @@ -1626,6 +1642,9 @@ setup(void) { dc.sel[ColBorder] = getcolor(selbordercolor); dc.sel[ColBG] = getcolor(selbgcolor); dc.sel[ColFG] = getcolor(selfgcolor); + dc.urg[ColBorder] = getcolor(urgbordercolor); + dc.urg[ColBG] = getcolor(selbgcolor); + dc.urg[ColFG] = getcolor(selfgcolor); dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen)); dc.gc = XCreateGC(dpy, root, 0, NULL); XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); -- 1.8.0 sorry this was not intended to be committed. Will send v2 Cheers, -- Antonio Quartulli ..each of us alone is worth nothing.. Ernesto Che Guevara pgpLSWB7m7Ewn.pgp Description: PGP signature
[dev] [PATCHv2] dwm: replace deprecated XKeycodeToKeysym
XKeycodeToKeysym is now deprecated in favour of XkbKeycodeToKeysym (X11/XKBlib.h). This patch substitutes the former with the latter in dwm.c Signed-off-by: Antonio Quartulli or...@autistici.org --- dwm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dwm.c b/dwm.c index d9443da..5d497b0 100644 --- a/dwm.c +++ b/dwm.c @@ -33,6 +33,7 @@ #include X11/cursorfont.h #include X11/keysym.h #include X11/Xatom.h +#include X11/XKBlib.h #include X11/Xlib.h #include X11/Xproto.h #include X11/Xutil.h @@ -1080,7 +1081,7 @@ keypress(XEvent *e) { XKeyEvent *ev; ev = e-xkey; - keysym = XKeycodeToKeysym(dpy, (KeyCode)ev-keycode, 0); + keysym = XkbKeycodeToKeysym(dpy, (KeyCode)ev-keycode, 0, 0); for(i = 0; i LENGTH(keys); i++) if(keysym == keys[i].keysym CLEANMASK(keys[i].mod) == CLEANMASK(ev-state) -- 1.8.0
Re: [dev] [st] Add a newline to the string printed in die
Greetings. On Tue, 11 Dec 2012 10:39:55 +0100 Roberto E. Vargas Caballero k...@shike2.com wrote: No, this will change the die() behaviour between all suckless projects. Then, change die in all the projects, it is the usual way of working with other issues, no? Why should your taste change all the behaviour of die() in all suckless projects? Appending the \n by the programmer adds flexibility, so there is no need to write a die‐no‐newline() function. Please send patches as attached files. Since we are using now git, it is easier and logic send the patches in this way, so the code of the patch can be included and modified in replies. You only have to use git am if you want to incorpore then to the main repository ,and it will keep the correct author and commiter, that I can see this information is lost now (I think it is not the correct way put a 'thanks' in the commit message). I won’t accept such patches. Please send attached files. I won’t imple‐ ment the outdated mbox or Maildir format for this. Sincerely, Christoph Lohmann
Re: [dev] [st] Add a newline to the string printed in die
On Tue, Dec 11, 2012 at 10:39:55AM +0100, Christoph Lohmann wrote: Please send patches as attached files. Since we are using now git, it is easier and logic send the patches in this way, so the code of the patch can be included and modified in replies. You only have to use git am if you want to incorpore then to the main repository ,and it will keep the correct author and commiter, that I can see this information is lost now (I think it is not the correct way put a 'thanks' in the commit message). I won’t accept such patches. Please send attached files. I won’t imple‐ ment the outdated mbox or Maildir format for this. That is retarded. Inline patches which facilitate commenting are the prefered patch format. Get familiar with your git tools. Marc -- Marc Andre Tanner http://www.brain-dump.org/ GPG key: CF7D56C0
Re: [dev] [st] Add a newline to the string printed in die
Greetings. On Tue, 11 Dec 2012 18:25:04 +0100 Marc Andre Tanner m...@brain-dump.org wrote: On Tue, Dec 11, 2012 at 10:39:55AM +0100, Christoph Lohmann wrote: Please send patches as attached files. Since we are using now git, it is easier and logic send the patches in this way, so the code of the patch can be included and modified in replies. You only have to use git am if you want to incorpore then to the main repository ,and it will keep the correct author and commiter, that I can see this information is lost now (I think it is not the correct way put a 'thanks' in the commit message). I won’t accept such patches. Please send attached files. I won’t imple‐ ment the outdated mbox or Maildir format for this. That is retarded. Inline patches which facilitate commenting are the prefered patch format. Get familiar with your git tools. No. Sincerely, Christoph Lohmann
Re: [dev] [st] Add a newline to the string printed in die
On Tue, Dec 11, 2012 at 06:25:04PM +0100, Christoph Lohmann wrote: Greetings. On Tue, 11 Dec 2012 18:25:04 +0100 Marc Andre Tanner m...@brain-dump.org wrote: On Tue, Dec 11, 2012 at 10:39:55AM +0100, Christoph Lohmann wrote: Please send patches as attached files. Since we are using now git, it is easier and logic send the patches in this way, so the code of the patch can be included and modified in replies. You only have to use git am if you want to incorpore then to the main repository ,and it will keep the correct author and commiter, that I can see this information is lost now (I think it is not the correct way put a 'thanks' in the commit message). I won’t accept such patches. Please send attached files. I won’t imple‐ ment the outdated mbox or Maildir format for this. That is retarded. Inline patches which facilitate commenting are the prefered patch format. Get familiar with your git tools. No. Ah, I just got onto this thread..maybe this is why my patch: [PATCHv2] dwm: replace deprecated XKeycodeToKeysym had not been reviewed/commented? :) Cheers, -- Antonio Quartulli ..each of us alone is worth nothing.. Ernesto Che Guevara pgpDfwirSxUrd.pgp Description: PGP signature
Re: [dev] [st] Add a newline to the string printed in die
Greetings. On Tue, 11 Dec 2012 18:34:19 +0100 Antonio Quartulli or...@autistici.org wrote: On Tue, Dec 11, 2012 at 06:25:04PM +0100, Christoph Lohmann wrote: Greetings. On Tue, 11 Dec 2012 18:25:04 +0100 Marc Andre Tanner m...@brain-dump.org wrote: On Tue, Dec 11, 2012 at 10:39:55AM +0100, Christoph Lohmann wrote: Please send patches as attached files. Since we are using now git, it is easier and logic send the patches in this way, so the code of the patch can be included and modified in replies. You only have to use git am if you want to incorpore then to the main repository ,and it will keep the correct author and commiter, that I can see this information is lost now (I think it is not the correct way put a 'thanks' in the commit message). I won’t accept such patches. Please send attached files. I won’t imple‐ ment the outdated mbox or Maildir format for this. That is retarded. Inline patches which facilitate commenting are the prefered patch format. Get familiar with your git tools. No. Ah, I just got onto this thread..maybe this is why my patch: [PATCHv2] dwm: replace deprecated XKeycodeToKeysym had not been reviewed/commented? :) No, Anselm is the maintainer of dwm. He needs some time to answer your patch. For the thread: I don’t know why people prefer to see the big patches inline, so you have the scroll past the whole patch to the next e‐mail, when you are using a pager to read your e‐mail. It’s easier when the MUA is filtering the patch file out, by simply showing, that some properly formatted patch is attached, which you can download, view in your favourite editor and apply it with git apply. This also allows to do easier prefiltering in your mailcap file, without having to scan all e‐mails with heuris‐ tics. Even if MIME sucks, it’s shorter to use the proper MIME type in‐ stead of filtering whole e‐mail blocks. People don’t know how to properly format e‐mails, so they will toppost on top of long patches and simply attach the whole thing. This is just a preliminary filter, so you can configure your MUA to not show everything. And that’s why I am against inline patches. It was a hard fight to allow proper attachments, now use them. It was a hard fight to have UTF‐8 and 8bit e‐mails too, but that fight is at least won. Now for the next fight. Sincerely, Christoph Lohmann
Re: [dev] [st] Add a newline to the string printed in die
On 11 December 2012 18:33, Antonio Quartulli or...@autistici.org wrote: On Tue, Dec 11, 2012 at 06:25:04PM +0100, Christoph Lohmann wrote: On Tue, 11 Dec 2012 18:25:04 +0100 Marc Andre Tanner m...@brain-dump.org wrote: On Tue, Dec 11, 2012 at 10:39:55AM +0100, Christoph Lohmann wrote: Please send patches as attached files. Since we are using now git, it is easier and logic send the patches in this way, so the code of the patch can be included and modified in replies. You only have to use git am if you want to incorpore then to the main repository ,and it will keep the correct author and commiter, that I can see this information is lost now (I think it is not the correct way put a 'thanks' in the commit message). I won’t accept such patches. Please send attached files. I won’t imple‐ ment the outdated mbox or Maildir format for this. That is retarded. Inline patches which facilitate commenting are the prefered patch format. Get familiar with your git tools. No. Ah, I just got onto this thread..maybe this is why my patch: [PATCHv2] dwm: replace deprecated XKeycodeToKeysym had not been reviewed/commented? :) We had a similar patch already which I first applied and then reverted to the old XKeycodeToKeysym() call, as it would require cumbersome fallback behavior to XKeycoceToKeysym() on older X servers. Cheers, Anselm
Re: [dev] [PATCHv2] dwm: replace deprecated XKeycodeToKeysym
Please see the other mail. This patch won't make it into dwm, as this doesn't work in several X server setups and we don't want to introduce case-handling as long as the modern X servers still support the old behavior. Best regards, Anselm On 11 December 2012 10:25, Antonio Quartulli or...@autistici.org wrote: XKeycodeToKeysym is now deprecated in favour of XkbKeycodeToKeysym (X11/XKBlib.h). This patch substitutes the former with the latter in dwm.c Signed-off-by: Antonio Quartulli or...@autistici.org --- dwm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dwm.c b/dwm.c index d9443da..5d497b0 100644 --- a/dwm.c +++ b/dwm.c @@ -33,6 +33,7 @@ #include X11/cursorfont.h #include X11/keysym.h #include X11/Xatom.h +#include X11/XKBlib.h #include X11/Xlib.h #include X11/Xproto.h #include X11/Xutil.h @@ -1080,7 +1081,7 @@ keypress(XEvent *e) { XKeyEvent *ev; ev = e-xkey; - keysym = XKeycodeToKeysym(dpy, (KeyCode)ev-keycode, 0); + keysym = XkbKeycodeToKeysym(dpy, (KeyCode)ev-keycode, 0, 0); for(i = 0; i LENGTH(keys); i++) if(keysym == keys[i].keysym CLEANMASK(keys[i].mod) == CLEANMASK(ev-state) -- 1.8.0
Re: [dev] [PATCHv2] dwm: replace deprecated XKeycodeToKeysym
On Tue, Dec 11, 2012 at 06:55:47PM +0100, Anselm R Garbe wrote: Please see the other mail. This patch won't make it into dwm, as this doesn't work in several X server setups and we don't want to introduce case-handling as long as the modern X servers still support the old behavior. Yap, I have read that. Oky, sounds good! Thank you! -- Antonio Quartulli ..each of us alone is worth nothing.. Ernesto Che Guevara pgp7Bb49JHAqG.pgp Description: PGP signature
Re: [dev] [dwm] Looking for a focusonclick that with MODKEY+Button3
Hey Bert, On Tue, Dec 11, 2012 at 09:46:14AM +0100, Bert Münnich wrote: On Sat, Dec 8, 2012 at 7:55 PM, Eric Pruitt eric.pru...@gmail.com wrote: Is there a focusonclick patch that anyone is aware of that still works with things like Right Click + Alt? Because of the change from Async to Sync in grabbuttons in the focusonclick patch, I am unable to use certain mouse shortcuts. The attached patch works for me. Bert This patch seems to work well and I have not encountered any oddities with it so far. Thank you very much, Eric
Re: [dev] [dwm] Looking for a focusonclick that with MODKEY+Button3
Hey, On Tue, Dec 11, 2012 at 09:46:14AM +0100, Bert Münnich wrote: The attached patch works for me. Bert Do you know where this patch came from? I like to keep attribution and source information for my patches, but I have been unable to locate where this patch came from. Eric