Author: me@beroal.in.ua http://www.beroal.in.ua/ Title: config file on command line, multiple Xorg displays This patch adds to SLiM version 1.3.5: * A command line option "-c $CONFIGURATION_FILENAME". Options in CONFIGURATION_FILENAME overrides options in "/etc/slim.conf". * An option "display_name" for use in its configuration file. These allows to start SLiM in several processes on different virtual terminals and displays. Example https://bbs.archlinux.org/viewtopic.php?pid=1192964#p1192964 . There are similar old patches on developer's website, see https://developer.berlios.de/patch/?func=detailpatch&patch_id=2695&group_id=2663 and https://developer.berlios.de/patch/?func=detailpatch&patch_id=2207&group_id=2663 diff -u a/app.cpp b/app.cpp --- a/app.cpp 2012-12-31 15:03:42.000000000 +0200 +++ b/app.cpp 2013-03-25 19:08:47.444065483 +0200 @@ -137,12 +137,13 @@ mcookie = string(App::mcookiesize, 'a'); daemonmode = false; force_nodaemon = false; + confArgIs = false; firstlogin = true; Dpy = NULL; /* Parse command line Note: we force a option for nodaemon switch to handle "-nodaemon" */ - while((tmp = getopt(argc, argv, "vhp:n:d?")) != EOF) { + while((tmp = getopt(argc, argv, "c:vhp:n:d?")) != EOF) { switch (tmp) { case 'p': /* Test theme */ testtheme = optarg; @@ -163,6 +164,10 @@ std::cout << APPNAME << " version " << VERSION << endl; exit(OK_EXIT); break; + case 'c': + confArgIs = true; + confArgFn = optarg; + break; case '?': /* Illegal */ logStream << endl; case 'h': /* Help */ @@ -186,7 +191,14 @@ } void App::Run() { - DisplayName = DISPLAY; + // Read configuration and theme + cfg = new Cfg; + cfg->readConf(CFGFILE); + if (confArgIs) { + cfg->readConf(confArgFn); + } + + DisplayName = cfg->getOption("display_name").c_str(); #ifdef XNEST_DEBUG char* p = getenv("DISPLAY"); @@ -196,9 +208,6 @@ } #endif - /* Read configuration and theme */ - cfg = new Cfg; - cfg->readConf(CFGFILE); string themebase = ""; string themefile = ""; string themedir = ""; @@ -892,9 +901,7 @@ static const int MAX_XSERVER_ARGS = 256; static char* server[MAX_XSERVER_ARGS+2] = { NULL }; server[0] = (char *)cfg->getOption("default_xserver").c_str(); - string argOption = cfg->getOption("xserver_arguments"); - /* Add mandatory -xauth option */ - argOption = argOption + " -auth " + cfg->getOption("authfile"); + string argOption = cfg->getOption("display_name") + " " + cfg->getOption("xserver_arguments") + " -auth " + cfg->getOption("authfile"); char* args = new char[argOption.length()+2]; /* NULL plus vt */ strcpy(args, argOption.c_str()); @@ -1213,7 +1220,7 @@ authfile = cfg->getOption("authfile"); remove(authfile.c_str()); putenv(StrConcat("XAUTHORITY=", authfile.c_str())); - Util::add_mcookie(mcookie, ":0", cfg->getOption("xauth_path"), + Util::add_mcookie(mcookie, cfg->getOption("display_name").c_str(), cfg->getOption("xauth_path"), authfile); } diff -u a/app.h b/app.h --- a/app.h 2012-12-31 15:03:42.000000000 +0200 +++ b/app.h 2013-03-25 19:09:18.623946895 +0200 @@ -104,6 +104,8 @@ bool firstlogin; bool daemonmode; bool force_nodaemon; + bool confArgIs; + const char* confArgFn; /* For testing themes */ char *testtheme; bool testing; diff -u a/cfg.cpp b/cfg.cpp --- a/cfg.cpp 2012-12-31 15:03:42.000000000 +0200 +++ b/cfg.cpp 2013-03-25 19:10:25.057027305 +0200 @@ -30,6 +30,7 @@ /* Configuration options */ options.insert(option("default_path","/bin:/usr/bin:/usr/local/bin")); options.insert(option("default_xserver","/usr/bin/X")); + options.insert(option("display_name",":0.0")); options.insert(option("xserver_arguments","")); options.insert(option("numlock","")); options.insert(option("daemon","")); diff -u a/switchuser.cpp b/switchuser.cpp --- a/switchuser.cpp 2012-12-31 15:03:42.000000000 +0200 +++ b/switchuser.cpp 2013-03-25 19:10:55.040246585 +0200 @@ -55,6 +55,6 @@ string home = string(Pw->pw_dir); string authfile = home + "/.Xauthority"; remove(authfile.c_str()); - r = Util::add_mcookie(mcookie, ":0", cfg->getOption("xauth_path"), + r = Util::add_mcookie(mcookie, displayName.c_str(), cfg->getOption("xauth_path"), authfile); }