On Tue, 30 Jan 2001, Sean 'Shaleh' Perry wrote:
>
> make bbkeys do something useful when the key is clicked and the gui tool is
> not
> installed and I will gladly remove the qt depends.
 
Ok, here's the diff to bbkeys.cc. It tries to launch the QT gui tool, and if
it fails, launches an xterm with 'bbkeysConfigC'.

--gile

--- /filez/bbkeys-0.3.5/bbkeys-0.3.5/bbkeys.cc  Thu Sep 28 17:15:11 2000
+++ bbkeys.cc   Tue Jan 30 14:44:26 2001
@@ -591,42 +591,17 @@
  
void ToolWindow::setKeygrabs(void)
{
-       int pid, status;
-       char command[80];
-       extern char **environ;
-
-       memset(command, 0, 80);
-
-       if (noQt) {
-               sprintf(command, "xterm -bg black -fg green -e bbkeysConfigC");
-       } else {
-               sprintf(command, "bbkeysconf");
+       int res;
+       /* This tries to execute 'bbkeysconf', and if it fails, defaults to
+          the command line conflagulator. This function never returns. */
+       if (! fork()) {
+               /* We don't use the shell to do this b/c we don't need shell functions.
*/
+               res = execlp("bbkeysconf", "bbkeysconf", NULL);
+               if (res != 0) { /* Any problem, try to start text mode */
+                       execlp("xterm", "xterm", "-bg", "black", "-fg", "green", "-e",
"bbkeysConfigC", NULL);
+               }
+               exit(0);
        }
-
-       pid = fork();
-       if (pid == -1) {
-               fprintf(stderr,
-                                               "bbkeys: Couldn't fork a process to 
launch configurator.\n");
-               return;
-       }
-
-       if (pid == 0) {
-               char *argv[4];
-               argv[0] = "sh";
-               argv[1] = "-c";
-               argv[2] = command;
-               argv[3] = 0;
-               execve("/bin/sh", argv, environ);
-               exit(127);
-       }
-
-       do {
-               if (waitpid(pid, &status, 0) == -1) {
-                       if (errno != EINTR)
-                               return;
-               } else
-                       return;
-       } while (1);
}
 
void ToolWindow::loadKeygrabs(void)

-- 
"...I've got a grand piano to prop up my mortal remains..."

Reply via email to