]> git.decadent.org.uk Git - ion3.git/blobdiff - pwm/pwm.c
Imported Upstream version 20090110
[ion3.git] / pwm / pwm.c
index 773aace74b43bbdf74cb77a33972e18c175bf9e8..0159ccef8ecccff04fb472dc65cd7ee2894b57c8 100644 (file)
--- a/pwm/pwm.c
+++ b/pwm/pwm.c
@@ -1,12 +1,9 @@
 /*
  * ion/pwm/pwm.c
  *
- * Copyright (c) Tuomo Valkonen 1999-2006
+ * Copyright (c) Tuomo Valkonen 1999-2009
  *
- * Ion is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
+ * See the included file LICENSE for details.
  */
 
 #include <stdlib.h>
@@ -22,6 +19,7 @@
 #include <libtu/util.h>
 #include <libtu/optparser.h>
 #include <libtu/errorlog.h>
+#include <libtu/prefix.h>
 #include <libextl/readconfig.h>
 #include <libmainloop/exec.h>
 
@@ -48,16 +46,8 @@ static OptParserOpt pwm_opts[]={
      DUMMY_TR("Add directory to search path")},
 
     {OPT_ID('o'), "oneroot",  0, NULL,
-     DUMMY_TR("Manage default root window/non-Xinerama screen only")},
-
-#if defined(CF_XINERAMA) || defined(CF_SUN_XINERAMA)
-    {OPT_ID('x'), "xinerama", OPT_ARG, "1|0",
-     DUMMY_TR("Use Xinerama screen information (default: 0/no)")},
-#else
-    {OPT_ID('x'), "xinerama", OPT_ARG, "?",
-     DUMMY_TR("Ignored: not compiled with Xinerama support")},
-#endif
-    
+     DUMMY_TR("Manage default screen only")},
+
     {OPT_ID('s'), "session",  OPT_ARG, "session_name", 
      DUMMY_TR("Name of session (affects savefiles)")},
     
@@ -84,7 +74,7 @@ static OptParserOpt pwm_opts[]={
 static void help()
 {
     int i;
-    printf(TR("Usage: %s [options]\n\n"), prog_execname());
+    printf(TR("Usage: %s [options]\n\n"), libtu_progname());
     for(i=0; pwm_opts[i].descr!=NULL; i++)
         pwm_opts[i].descr=TR(pwm_opts[i].descr);
     optparser_printhelp(OPTP_MIDLONG, pwm_opts);
@@ -97,27 +87,37 @@ int main(int argc, char*argv[])
     const char *cfgfile="cfg_pwm";
     const char *display=NULL;
     char *cmd=NULL;
-    int stflags=IONCORE_STARTUP_NOXINERAMA;
+    int stflags=0;
     int opt;
     ErrorLog el;
     FILE *ef=NULL;
     char *efnam=NULL;
     bool may_continue=FALSE;
     bool noerrorlog=FALSE;
-
+    char *localedir;
+    
     libtu_init(argv[0]);
 
-    if(!ioncore_init("pwm3", argc, argv, LOCALEDIR))
+#ifdef CF_RELOCATABLE_BIN_LOCATION
+    prefix_set(argv[0], CF_RELOCATABLE_BIN_LOCATION);
+#endif
+
+    localedir=prefix_add(LOCALEDIR);
+    
+    if(!ioncore_init("pwm3", argc, argv, localedir))
         return EXIT_FAILURE;
 
-    extl_add_searchdir(EXTRABINDIR); /* ion-completefile */
-    extl_add_searchdir(MODULEDIR);
-    extl_add_searchdir(ETCDIR);
+    if(localedir!=NULL)
+        free(localedir);
+    
+    prefix_wrap_simple(extl_add_searchdir, EXTRABINDIR); /* ion-completefile */
+    prefix_wrap_simple(extl_add_searchdir, MODULEDIR);
+    prefix_wrap_simple(extl_add_searchdir, ETCDIR);
 #ifdef PWM_ETCDIR    
-    extl_add_searchdir(PWM_ETCDIR);
+    prefix_wrap_simple(extl_add_searchdir, PWM_ETCDIR);
 #endif
-    extl_add_searchdir(SHAREDIR);
-    extl_add_searchdir(LCDIR);
+    prefix_wrap_simple(extl_add_searchdir, SHAREDIR);
+    prefix_wrap_simple(extl_add_searchdir, LCDIR);
     extl_set_userdirs("pwm3");
 
     optparser_init(argc, argv, OPTP_MIDLONG, pwm_opts);
@@ -139,17 +139,6 @@ int main(int argc, char*argv[])
         case OPT_ID('o'):
             stflags|=IONCORE_STARTUP_ONEROOT;
             break;
-        case OPT_ID('x'):
-            {
-                const char *p=optparser_get_arg();
-                if(strcmp(p, "1")==0)
-                    stflags&=~IONCORE_STARTUP_NOXINERAMA;
-                else if(strcmp(p, "0")==0)
-                    stflags|=IONCORE_STARTUP_NOXINERAMA;
-                else
-                    warn(TR("Invalid parameter to -xinerama."));
-            }
-            break;
         case OPT_ID('s'):
             extl_set_sessiondir(optparser_get_arg());
             break;
@@ -207,7 +196,7 @@ fail:
             fclose(ef);
             pid=fork();
             if(pid==0){
-                ioncore_setup_environ(DefaultScreen(ioncore_g.dpy));
+                ioncore_setup_display(DefaultScreen(ioncore_g.dpy));
                 if(!may_continue)
                     XCloseDisplay(ioncore_g.dpy);
                 else