Re: [dwm] Preventing xterm from closing by killclient()
On Fri, Apr 11, 2008 at 07:15:15PM +0200, Martin Sander wrote: On Fri, Apr 11, 2008 at 06:32:54PM +0200, Valentin wrote: Just extend struct Client with Bool iskillable and set this value at the same point as isfloating is set in applyrules, then you just need to check c-iskillable in killclient(). If I do that, iskillable is set to False by default, right? Yes, thats why I changed it to isunkillable. Yea, I propose to call it isimmortal. Kind regards, -- Anselm R. Garbe http://www.suckless.org/ GPG key: 0D73F361
Re: [dwm] Preventing xterm from closing by killclient()
On Sat, Apr 12, 2008 at 11:43:52AM +0200, Anselm R. Garbe wrote: Yea, I propose to call it isimmortal. You're the boss.. I also added a test for arg in killclient, so that I can have an extra keybinding to killclient(somestring) to kill immortals. That takes care of the aforementioned cornercases. Have a nice weekend Martin diff -up dwm-4.9/config.def.h dwm-4.9-nokill/config.def.h --- dwm-4.9/config.def.h 2008-04-03 22:57:01.0 +0200 +++ dwm-4.9-nokill/config.def.h 2008-04-12 17:49:29.0 +0200 @@ -14,8 +14,9 @@ const char tags[][MAXTAGLEN] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; Rule rules[] = { - /* class instance title tags ref isfloating */ - { Gimp, NULL, NULL, NULL, True }, + /* class instance title tags ref isfloating isimmortal*/ + { Gimp, NULL, NULL, NULL, True , False}, + { UXTerm, NULL, NULL, NULL, False, True}, }; /* geometries, s{x,y,w,h} and bh are already initualized here */ @@ -55,6 +56,7 @@ Key keys[] = { { MODKEY, XK_Return, zoom, NULL }, { MODKEY, XK_Tab, viewprevtag, NULL }, { MODKEY|ShiftMask, XK_c, killclient, NULL }, + { MODKEY|ControlMask|ShiftMask, XK_c, killclient, kill_immortals}, { MODKEY, XK_space, setlayout, NULL }, { MODKEY|ShiftMask, XK_space, togglefloating, NULL }, { MODKEY|ControlMask, XK_space, setgeom, NULL }, diff -up dwm-4.9/dwm.c dwm-4.9-nokill/dwm.c --- dwm-4.9/dwm.c 2008-04-03 22:57:01.0 +0200 +++ dwm-4.9-nokill/dwm.c 2008-04-12 17:47:51.0 +0200 @@ -70,7 +70,7 @@ struct Client { int minax, maxax, minay, maxay; long flags; unsigned int bw, oldbw; - Bool isbanned, isfixed, isfloating, isurgent; + Bool isbanned, isfixed, isfloating, isurgent, isimmortal; Bool *tags; Client *next; Client *prev; @@ -117,6 +117,7 @@ typedef struct { const char *title; const char *tag; Bool isfloating; + Bool isimmortal; } Rule; /* function declarations */ @@ -266,6 +267,7 @@ applyrules(Client *c) { || (ch.res_name r-instance strstr(ch.res_name, r-instance))) { c-isfloating = r-isfloating; + c-isimmortal = r-isimmortal; if(r-tag) { c-tags[idxoftag(r-tag)] = True; matched = True; @@ -969,6 +971,8 @@ killclient(const char *arg) { if(!sel) return; + if(sel-isimmortal !arg) + return; if(isprotodel(sel)) { ev.type = ClientMessage; ev.xclient.window = sel-win;
Re: [dwm] Preventing xterm from closing by killclient()
On Fri, Apr 11, 2008 at 12:26:04PM +0200, Anselm R. Garbe wrote: Just extend struct Client with Bool iskillable and set this value at the same point as isfloating is set in applyrules, then you just need to check c-iskillable in killclient(). Thanks for the hint, that is a lot better. Though, I would propose to set c-iskillable to True during killclient() to allow getting rid of unresponsive clients which cannot be killed straight away. I have to admit I don't understand what you mean. Anyway, I can always use xkill to get rid of unresponsive clients, if thats what you mean. Thanks again Martin diff -up dwm-4.9/config.def.h dwm-4.9-nokill/config.def.h --- dwm-4.9/config.def.h 2008-04-03 22:57:01.0 +0200 +++ dwm-4.9-nokill/config.def.h 2008-04-11 16:35:49.0 +0200 @@ -14,8 +14,9 @@ const char tags[][MAXTAGLEN] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; Rule rules[] = { - /* class instance title tags ref isfloating */ - { Gimp, NULL, NULL, NULL, True }, + /* class instance title tags ref isfloating isunkillable*/ + { Gimp, NULL, NULL, NULL, True , False}, + { UXTerm, NULL, NULL, NULL, False, True}, }; /* geometries, s{x,y,w,h} and bh are already initualized here */ diff -up dwm-4.9/dwm.c dwm-4.9-nokill/dwm.c --- dwm-4.9/dwm.c 2008-04-03 22:57:01.0 +0200 +++ dwm-4.9-nokill/dwm.c 2008-04-11 16:44:26.0 +0200 @@ -70,7 +70,7 @@ struct Client { int minax, maxax, minay, maxay; long flags; unsigned int bw, oldbw; - Bool isbanned, isfixed, isfloating, isurgent; + Bool isbanned, isfixed, isfloating, isurgent, isunkillable; Bool *tags; Client *next; Client *prev; @@ -117,6 +117,7 @@ typedef struct { const char *title; const char *tag; Bool isfloating; + Bool isunkillable; } Rule; /* function declarations */ @@ -266,6 +267,7 @@ applyrules(Client *c) { || (ch.res_name r-instance strstr(ch.res_name, r-instance))) { c-isfloating = r-isfloating; + c-isunkillable = r-isunkillable; if(r-tag) { c-tags[idxoftag(r-tag)] = True; matched = True; @@ -967,7 +969,7 @@ void killclient(const char *arg) { XEvent ev; - if(!sel) + if(!sel || sel-isunkillable) return; if(isprotodel(sel)) { ev.type = ClientMessage;
Re: [dwm] Preventing xterm from closing by killclient()
On Fri, Apr 11, 2008 at 04:57:29PM +0200, Martin Sander wrote: On Fri, Apr 11, 2008 at 12:26:04PM +0200, Anselm R. Garbe wrote: Though, I would propose to set c-iskillable to True during killclient() to allow getting rid of unresponsive clients which cannot be killed straight away. I have to admit I don't understand what you mean. Anyway, I can always use xkill to get rid of unresponsive clients, if thats what you mean. Yes but there are two cornercases at least: xkill(1) might not be available, and fork() might be not available anymore -- depending how destructive X clients you are running. Of course Ctrl-Alt-Backspace is available. Kind regards, -- Anselm R. Garbe http://www.suckless.org/ GPG key: 0D73F361
Re: [dwm] Preventing xterm from closing by killclient()
On Fri, 11 Apr 2008 12:26:04 +0200 Anselm R. Garbe [EMAIL PROTECTED] wrote: Just extend struct Client with Bool iskillable and set this value at the same point as isfloating is set in applyrules, then you just need to check c-iskillable in killclient(). If I do that, iskillable is set to False by default, right? --Valentin -- Didja hear about the dyslexic devil worshipper who sold his soul to Santa?
Re: [dwm] Preventing xterm from closing by killclient()
On Fri, Apr 11, 2008 at 06:32:54PM +0200, Valentin wrote: Just extend struct Client with Bool iskillable and set this value at the same point as isfloating is set in applyrules, then you just need to check c-iskillable in killclient(). If I do that, iskillable is set to False by default, right? Yes, thats why I changed it to isunkillable. Martin
Re: [dwm] Preventing xterm from closing by killclient()
You can use close() command in the ipython window in order to close the plot window instead of killclient On Thu, 10 Apr 2008, Martin Sander wrote: On Wed, Apr 09, 2008 at 11:25:59PM +0200, Anselm R. Garbe wrote: Hmm, what about changing the binding to Ctrl-d in your setup then? Thanks for the suggestion, but I think I did not make myself entirely clear. My problem is of different nature. As an example, I have an xterm with an ipython [2] shell, which I use to plot some data using matplotlib [2]. The window showing the plot has no means of closing it but killclient() (the same with gnuplot, btw). So when I want to close that window I use MODKEY|Shiftmask, XK_c. My problem occurs when I don't realize that actually that window is not focused, but the xterm running ipython is focused instead. xterm closes, I lose everything I have typed in that window so far, including the history, which is absolutely not what I want. I know I could use BORDERPX 2 or set SELBORDERCOLOR to something very high contrast, but I'd find that rather distracting/ugly. I'd prefer just to never ever kill xterm, something like if (clientname=='xterm') return; in killclient(). I just need some hints how to do it. Regards Martin [1] http://ipython.scipy.org/ [2] http://matplotlib.sourceforge.net/
[dwm] Preventing xterm from closing by killclient()
Hey. In the last time I repeatedly closed xterm windows on accident by my killclient binding (MODKEY|ShiftMask, XK_c) because I did not see that the xterm had focus and not that stupid other client that does not provide a convenient keyboard shortcut of its own to close. I always close xterms with Ctrl-D when I want them to close, so I am looking for a way to prevent xterm from closing with killclient(). I have already looked for a solution in xterm, but there seems to be none. IceWM provides a way to disable the close-button (killclient-equivalent in WIMP..) for certain clients, so I thought maybe it is easy to do that in dwm, too. I have looked at the source, but I don't know anything about X programming and have to admit I don't know if I would have to disable the XKillClient or the XSendEvent part to do it properly. Any hints? Thanks in advance Martin
Re: [dwm] Preventing xterm from closing by killclient()
On Wed, Apr 09, 2008 at 04:03:44PM +0200, Martin Sander wrote: In the last time I repeatedly closed xterm windows on accident by my killclient binding (MODKEY|ShiftMask, XK_c) because I did not see that the xterm had focus and not that stupid other client that does not provide a convenient keyboard shortcut of its own to close. I always close xterms with Ctrl-D when I want them to close, so I am looking for a way to prevent xterm from closing with killclient(). I have already looked for a solution in xterm, but there seems to be none. IceWM provides a way to disable the close-button (killclient-equivalent in WIMP..) for certain clients, so I thought maybe it is easy to do that in dwm, too. I have looked at the source, but I don't know anything about X programming and have to admit I don't know if I would have to disable the XKillClient or the XSendEvent part to do it properly. Any hints? Hmm, what about changing the binding to Ctrl-d in your setup then? Kind regards, -- Anselm R. Garbe http://www.suckless.org/ GPG key: 0D73F361
Re: [dwm] Preventing xterm from closing by killclient()
On Wed, Apr 09, 2008 at 11:25:59PM +0200, Anselm R. Garbe wrote: Hmm, what about changing the binding to Ctrl-d in your setup then? Thanks for the suggestion, but I think I did not make myself entirely clear. My problem is of different nature. As an example, I have an xterm with an ipython [2] shell, which I use to plot some data using matplotlib [2]. The window showing the plot has no means of closing it but killclient() (the same with gnuplot, btw). So when I want to close that window I use MODKEY|Shiftmask, XK_c. My problem occurs when I don't realize that actually that window is not focused, but the xterm running ipython is focused instead. xterm closes, I lose everything I have typed in that window so far, including the history, which is absolutely not what I want. I know I could use BORDERPX 2 or set SELBORDERCOLOR to something very high contrast, but I'd find that rather distracting/ugly. I'd prefer just to never ever kill xterm, something like if (clientname=='xterm') return; in killclient(). I just need some hints how to do it. Regards Martin [1] http://ipython.scipy.org/ [2] http://matplotlib.sourceforge.net/
Re: [dwm] Preventing xterm from closing by killclient()
I recommend looking in applyrules() for some example code. You may be able to adapt it in killclient() :) On Apr 9, 2008, at 18:56, Martin Sander [EMAIL PROTECTED] wrote: On Wed, Apr 09, 2008 at 11:25:59PM +0200, Anselm R. Garbe wrote: Hmm, what about changing the binding to Ctrl-d in your setup then? Thanks for the suggestion, but I think I did not make myself entirely clear. My problem is of different nature. As an example, I have an xterm with an ipython [2] shell, which I use to plot some data using matplotlib [2]. The window showing the plot has no means of closing it but killclient() (the same with gnuplot, btw). So when I want to close that window I use MODKEY|Shiftmask, XK_c. My problem occurs when I don't realize that actually that window is not focused, but the xterm running ipython is focused instead. xterm closes, I lose everything I have typed in that window so far, including the history, which is absolutely not what I want. I know I could use BORDERPX 2 or set SELBORDERCOLOR to something very high contrast, but I'd find that rather distracting/ugly. I'd prefer just to never ever kill xterm, something like if (clientname=='xterm') return; in killclient(). I just need some hints how to do it. Regards Martin [1] http://ipython.scipy.org/ [2] http://matplotlib.sourceforge.net/