Vua Job VN

2010-03-07 Thread Mail
Kính gi n Bn,
Xin gii thiu:
*

[*]Mng Vic Làm Ti Vit Nam :   H Thng Ni Kt Mng Vic Làm VUA JOB - 
http://vuajob.com
*
ây là mt cu ni rng ln gia ngi tìm vic và nhà tuyn dng .  Mi dch v ca Vua Job là 
hoàn toàn min phí , ngõ hu h tr môi trng vic làm và tài nng cho mi tng lp .
 
Chân Thành Cám n,
*
http://vuajob.com

*

Notes:  This email is once time announcement-introduction only.  Thank you.
Lu ý:  Th in t email này gi i ch mt ln mà thôi, ng hu thông báo gii thiu . Cám 
n .
(Vua Job : VN Career Network in Vietnam)



scrotwm patch to change wm.

2010-03-07 Thread Edd Barrett
Hi guys,

I have had this patch sitting around in my $HOME for a while. It allows the user
to exit scrotwm to another window manager (one of the ones they define in
~/.scrotwm.conf) via a dmenu. The idea was taken from cwm.

What do you think?

OK to put into scrotwm?

-- 
Best Regards
Edd Barrett

http://www.theunixzoo.co.uk
opencvs server: Diffing inside .
Index: scrotwm.1
===
RCS file: /scrotwm/scrotwm/scrotwm.1,v
retrieving revision 1.28
diff -N -u -p -u scrotwm.1
--- scrotwm.1   7 Oct 2009 03:19:11 -   1.28
+++ scrotwm.1   21 Feb 2010 20:19:12 -
@@ -79,6 +79,8 @@ Enabling or disabling an option is done by using 1 or 
 The file supports the following keywords:
 .Pp
 .Bl -tag -width title_class_enabledXXX -offset indent -compact
+.It Cm alt_wms
+A comma separated list of alternative window managers for use with exec_alt_wm.
 .It Cm color_focus
 Border color of the currently focussed window.
 .It Cm color_unfocus
@@ -259,6 +261,8 @@ The default key bindings are described below:
 term
 .It Cm M-p
 menu
+.It Cm M-r
+exec_alt_wm
 .It Cm M-S-q
 quit
 .It Cm M-q
@@ -343,6 +347,8 @@ Menu
 (see
 .Sx PROGRAMS
 above)
+.It Cm exec_alt_wm
+Execute an alternative window manager
 .It Cm quit
 Quit
 .Nm
Index: scrotwm.c
===
RCS file: /scrotwm/scrotwm/scrotwm.c,v
retrieving revision 1.281
diff -N -u -p -u scrotwm.c
--- scrotwm.c   13 Jan 2010 23:22:31 -  1.281
+++ scrotwm.c   21 Feb 2010 20:19:13 -
@@ -179,6 +179,7 @@ int cycle_visible = 0;
 intterm_width = 0;
 intfont_adjusted = 0;
 unsigned int   mod_key = MODKEY;
+intret_status = -1; /* store return status of fork/exec */
 
 /* dialog windows */
 double dialog_ratio = .6;
@@ -385,6 +386,15 @@ struct quirk {
 intquirks_size = 0, quirks_length = 0;
 struct quirk   *quirks = NULL;
 
+/* alternative window managers */
+struct alt_wm {
+   SLIST_ENTRY(alt_wm) entries;
+   char*wm;
+};
+SLIST_HEAD(head, alt_wm)   alt_wms;
+void   exec_alt_wm();
+void   free_alt_wm_list();
+
 /* events */
 #ifdef SWM_DEBUG
 void
@@ -587,7 +597,7 @@ sighdlr(int sig)
 
switch (sig) {
case SIGCHLD:
-   while ((pid = waitpid(WAIT_ANY, NULL, WNOHANG)) != -1) {
+   while ((pid = waitpid(WAIT_ANY, ret_status, WNOHANG)) != -1) {
DNPRINTF(SWM_D_MISC, reaping: %d\n, pid);
if (pid = 0)
break;
@@ -1135,6 +1145,148 @@ restart(struct swm_region *r, union arg *args)
quit(NULL, NULL);
 }
 
+/* execute a new window manager */
+void
+exec_alt_wm(struct swm_region *r, union arg *args)
+{
+   int fd[2], fd1[2], pipe_written = 0;
+   int pipe_read = 0, found_choice = 0;
+   int max_wm_len = -1, cur_wm_len;
+   int pipe_in_sz = 0, i, pid;
+   char*new_wm = NULL, *buf = NULL, *pipe_in;
+   struct  alt_wm *wm_node;
+
+   if (SLIST_EMPTY(alt_wms))
+   return;
+
+   if ((pipe(fd) == -1) || (pipe(fd1) == -1))
+   err(1, exec_alt_wm: pipe fail);
+
+   if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
+   err(1, exec_alt_wm: could not disable SIGPIPE);
+
+   /* work out how many wms and the longest name */
+   SLIST_FOREACH(wm_node, alt_wms, entries) {
+   cur_wm_len = strlen(wm_node-wm);
+   pipe_in_sz = pipe_in_sz + cur_wm_len + 1; /* +1 \n */
+   if (max_wm_len  cur_wm_len)
+   max_wm_len = cur_wm_len;
+   }
+   pipe_in_sz ++; /* \0 */
+
+   pid = fork();
+   switch (pid) {
+   case -1:
+   err(1, exec_alt_wm: can't fork);
+   break;
+   case 0: /* we are the child */
+   close(fd1[0]);
+
+   /* build \n delimited records for dmenu */
+   pipe_in = malloc(pipe_in_sz);
+   if (pipe_in == NULL)
+   err(1, exec_alt_wm: malloc failed\n);
+
+   memset(pipe_in, 0, pipe_in_sz);
+
+   SLIST_FOREACH(wm_node, alt_wms, entries)
+   snprintf(pipe_in, pipe_in_sz, %s%s\n,
+   pipe_in, wm_node-wm);
+
+   while (pipe_written != pipe_in_sz) {
+   i = write(fd[1], pipe_in + pipe_written,
+   pipe_in_sz - pipe_written);
+
+   if (i == -1) {
+   err(1, alt_wm: can't write);
+   i = 0; /* try again */
+   }
+   pipe_written += i;
+   }

Re: scrotwm patch to change wm.

2010-03-07 Thread Darrin Chandler
On Sun, Mar 07, 2010 at 10:21:39PM +, Edd Barrett wrote:
 Hi guys,
 
 I have had this patch sitting around in my $HOME for a while. It allows the 
 user
 to exit scrotwm to another window manager (one of the ones they define in
 ~/.scrotwm.conf) via a dmenu. The idea was taken from cwm.
 
 What do you think?
 
 OK to put into scrotwm?

What happens if you are using a different menu program, or have no menu
program installed at all?

I don't like harcoding to dmenu. Aside from that it's a nice idea.


 -- 
 Best Regards
 Edd Barrett
 
 http://www.theunixzoo.co.uk

 opencvs server: Diffing inside .
 Index: scrotwm.1
 ===
 RCS file: /scrotwm/scrotwm/scrotwm.1,v
 retrieving revision 1.28
 diff -N -u -p -u scrotwm.1
 --- scrotwm.1 7 Oct 2009 03:19:11 -   1.28
 +++ scrotwm.1 21 Feb 2010 20:19:12 -
 @@ -79,6 +79,8 @@ Enabling or disabling an option is done by using 1 or 
  The file supports the following keywords:
  .Pp
  .Bl -tag -width title_class_enabledXXX -offset indent -compact
 +.It Cm alt_wms
 +A comma separated list of alternative window managers for use with 
 exec_alt_wm.
  .It Cm color_focus
  Border color of the currently focussed window.
  .It Cm color_unfocus
 @@ -259,6 +261,8 @@ The default key bindings are described below:
  term
  .It Cm M-p
  menu
 +.It Cm M-r
 +exec_alt_wm
  .It Cm M-S-q
  quit
  .It Cm M-q
 @@ -343,6 +347,8 @@ Menu
  (see
  .Sx PROGRAMS
  above)
 +.It Cm exec_alt_wm
 +Execute an alternative window manager
  .It Cm quit
  Quit
  .Nm
 Index: scrotwm.c
 ===
 RCS file: /scrotwm/scrotwm/scrotwm.c,v
 retrieving revision 1.281
 diff -N -u -p -u scrotwm.c
 --- scrotwm.c 13 Jan 2010 23:22:31 -  1.281
 +++ scrotwm.c 21 Feb 2010 20:19:13 -
 @@ -179,6 +179,7 @@ int   cycle_visible = 0;
  int  term_width = 0;
  int  font_adjusted = 0;
  unsigned int mod_key = MODKEY;
 +int  ret_status = -1; /* store return status of fork/exec */
  
  /* dialog windows */
  double   dialog_ratio = .6;
 @@ -385,6 +386,15 @@ struct quirk {
  int  quirks_size = 0, quirks_length = 0;
  struct quirk *quirks = NULL;
  
 +/* alternative window managers */
 +struct alt_wm {
 + SLIST_ENTRY(alt_wm) entries;
 + char*wm;
 +};
 +SLIST_HEAD(head, alt_wm) alt_wms;
 +void exec_alt_wm();
 +void free_alt_wm_list();
 +
  /* events */
  #ifdef SWM_DEBUG
  void
 @@ -587,7 +597,7 @@ sighdlr(int sig)
  
   switch (sig) {
   case SIGCHLD:
 - while ((pid = waitpid(WAIT_ANY, NULL, WNOHANG)) != -1) {
 + while ((pid = waitpid(WAIT_ANY, ret_status, WNOHANG)) != -1) {
   DNPRINTF(SWM_D_MISC, reaping: %d\n, pid);
   if (pid = 0)
   break;
 @@ -1135,6 +1145,148 @@ restart(struct swm_region *r, union arg *args)
   quit(NULL, NULL);
  }
  
 +/* execute a new window manager */
 +void
 +exec_alt_wm(struct swm_region *r, union arg *args)
 +{
 + int fd[2], fd1[2], pipe_written = 0;
 + int pipe_read = 0, found_choice = 0;
 + int max_wm_len = -1, cur_wm_len;
 + int pipe_in_sz = 0, i, pid;
 + char*new_wm = NULL, *buf = NULL, *pipe_in;
 + struct  alt_wm *wm_node;
 +
 + if (SLIST_EMPTY(alt_wms))
 + return;
 +
 + if ((pipe(fd) == -1) || (pipe(fd1) == -1))
 + err(1, exec_alt_wm: pipe fail);
 +
 + if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
 + err(1, exec_alt_wm: could not disable SIGPIPE);
 +
 + /* work out how many wms and the longest name */
 + SLIST_FOREACH(wm_node, alt_wms, entries) {
 + cur_wm_len = strlen(wm_node-wm);
 + pipe_in_sz = pipe_in_sz + cur_wm_len + 1; /* +1 \n */
 + if (max_wm_len  cur_wm_len)
 + max_wm_len = cur_wm_len;
 + }
 + pipe_in_sz ++; /* \0 */
 +
 + pid = fork();
 + switch (pid) {
 + case -1:
 + err(1, exec_alt_wm: can't fork);
 + break;
 + case 0: /* we are the child */
 + close(fd1[0]);
 +
 + /* build \n delimited records for dmenu */
 + pipe_in = malloc(pipe_in_sz);
 + if (pipe_in == NULL)
 + err(1, exec_alt_wm: malloc failed\n);
 +
 + memset(pipe_in, 0, pipe_in_sz);
 +
 + SLIST_FOREACH(wm_node, alt_wms, entries)
 + snprintf(pipe_in, pipe_in_sz, %s%s\n,
 + pipe_in, wm_node-wm);
 +
 + while (pipe_written != pipe_in_sz) {
 + i = write(fd[1], pipe_in + pipe_written,
 +  

Re: scrotwm patch to change wm.

2010-03-07 Thread Marco Peereboom
I agree with dwc's assesment. You need to make sure dmenu is the  
magical tool.


On Mar 7, 2010, at 5:54 PM, Darrin Chandler dwchand...@stilyagin.com  
wrote:



On Sun, Mar 07, 2010 at 10:21:39PM +, Edd Barrett wrote:

Hi guys,

I have had this patch sitting around in my $HOME for a while. It  
allows the user
to exit scrotwm to another window manager (one of the ones they  
define in

~/.scrotwm.conf) via a dmenu. The idea was taken from cwm.

What do you think?

OK to put into scrotwm?


What happens if you are using a different menu program, or have no  
menu

program installed at all?

I don't like harcoding to dmenu. Aside from that it's a nice idea.



--
Best Regards
Edd Barrett

http://www.theunixzoo.co.uk



opencvs server: Diffing inside .
Index: scrotwm.1
===
RCS file: /scrotwm/scrotwm/scrotwm.1,v
retrieving revision 1.28
diff -N -u -p -u scrotwm.1
--- scrotwm.17 Oct 2009 03:19:11 -1.28
+++ scrotwm.121 Feb 2010 20:19:12 -
@@ -79,6 +79,8 @@ Enabling or disabling an option is done by using  
1 or

The file supports the following keywords:
.Pp
.Bl -tag -width title_class_enabledXXX -offset indent -compact
+.It Cm alt_wms
+A comma separated list of alternative window managers for use with  
exec_alt_wm.

.It Cm color_focus
Border color of the currently focussed window.
.It Cm color_unfocus
@@ -259,6 +261,8 @@ The default key bindings are described below:
term
.It Cm M-p
menu
+.It Cm M-r
+exec_alt_wm
.It Cm M-S-q
quit
.It Cm M-q
@@ -343,6 +347,8 @@ Menu
(see
.Sx PROGRAMS
above)
+.It Cm exec_alt_wm
+Execute an alternative window manager
.It Cm quit
Quit
.Nm
Index: scrotwm.c
===
RCS file: /scrotwm/scrotwm/scrotwm.c,v
retrieving revision 1.281
diff -N -u -p -u scrotwm.c
--- scrotwm.c13 Jan 2010 23:22:31 -1.281
+++ scrotwm.c21 Feb 2010 20:19:13 -
@@ -179,6 +179,7 @@ intcycle_visible = 0;
intterm_width = 0;
intfont_adjusted = 0;
unsigned intmod_key = MODKEY;
+intret_status = -1; /* store return status of fork/ 
exec */


/* dialog windows */
doubledialog_ratio = .6;
@@ -385,6 +386,15 @@ struct quirk {
intquirks_size = 0, quirks_length = 0;
struct quirk*quirks = NULL;

+/* alternative window managers */
+struct alt_wm {
+SLIST_ENTRY(alt_wm)entries;
+char*wm;
+};
+SLIST_HEAD(head, alt_wm)alt_wms;
+voidexec_alt_wm();
+voidfree_alt_wm_list();
+
/* events */
#ifdef SWM_DEBUG
void
@@ -587,7 +597,7 @@ sighdlr(int sig)

   switch (sig) {
   case SIGCHLD:
-while ((pid = waitpid(WAIT_ANY, NULL, WNOHANG)) != -1) {
+while ((pid = waitpid(WAIT_ANY, ret_status, WNOHANG)) !=  
-1) {

   DNPRINTF(SWM_D_MISC, reaping: %d\n, pid);
   if (pid = 0)
   break;
@@ -1135,6 +1145,148 @@ restart(struct swm_region *r, union arg  
*args)

   quit(NULL, NULL);
}

+/* execute a new window manager */
+void
+exec_alt_wm(struct swm_region *r, union arg *args)
+{
+intfd[2], fd1[2], pipe_written = 0;
+intpipe_read = 0, found_choice = 0;
+intmax_wm_len = -1, cur_wm_len;
+intpipe_in_sz = 0, i, pid;
+char*new_wm = NULL, *buf = NULL, *pipe_in;
+structalt_wm *wm_node;
+
+if (SLIST_EMPTY(alt_wms))
+return;
+
+if ((pipe(fd) == -1) || (pipe(fd1) == -1))
+err(1, exec_alt_wm: pipe fail);
+
+if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
+err(1, exec_alt_wm: could not disable SIGPIPE);
+
+/* work out how many wms and the longest name */
+SLIST_FOREACH(wm_node, alt_wms, entries) {
+cur_wm_len = strlen(wm_node-wm);
+pipe_in_sz = pipe_in_sz + cur_wm_len + 1; /* +1 \n */
+if (max_wm_len  cur_wm_len)
+max_wm_len = cur_wm_len;
+}
+pipe_in_sz ++; /* \0 */
+
+pid = fork();
+switch (pid) {
+case -1:
+err(1, exec_alt_wm: can't fork);
+break;
+case 0: /* we are the child */
+close(fd1[0]);
+
+/* build \n delimited records for dmenu */
+pipe_in = malloc(pipe_in_sz);
+if (pipe_in == NULL)
+err(1, exec_alt_wm: malloc failed\n);
+
+memset(pipe_in, 0, pipe_in_sz);
+
+SLIST_FOREACH(wm_node, alt_wms, entries)
+snprintf(pipe_in, pipe_in_sz, %s%s\n,
+pipe_in, wm_node-wm);
+
+while (pipe_written != pipe_in_sz) {
+i = write(fd[1], pipe_in + pipe_written,
+pipe_in_sz - pipe_written);
+
+if (i == -1) {
+err(1, alt_wm: can't write);
+i = 0; /* try again */
+}
+pipe_written += i;
+}
+close(fd[1]);
+free(pipe_in);
+
+/* replace stdin/stdout */
+if (dup2(fd[0], STDIN_FILENO)