From ec985ce41d011a94bbddfe225508538f8559f9b8 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Mon, 13 Aug 2007 06:28:01 +0200 Subject: [PATCH] Probably working launcher. --- clients/gui-shell/.gitignore | 1 + clients/gui-shell/Makefile.am | 2 ++ clients/gui-shell/launch.c | 40 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 clients/gui-shell/.gitignore diff --git a/clients/gui-shell/.gitignore b/clients/gui-shell/.gitignore new file mode 100644 index 0000000..2a36245 --- /dev/null +++ b/clients/gui-shell/.gitignore @@ -0,0 +1 @@ +/dolcon-launch diff --git a/clients/gui-shell/Makefile.am b/clients/gui-shell/Makefile.am index a6aa0e4..c826a0a 100644 --- a/clients/gui-shell/Makefile.am +++ b/clients/gui-shell/Makefile.am @@ -1,3 +1,5 @@ bin_PROGRAMS=dolcon-launch dolcon_launch_SOURCES=launch.c + +AM_CPPFLAGS=-I$(top_srcdir)/include diff --git a/clients/gui-shell/launch.c b/clients/gui-shell/launch.c index f31fcc2..620e280 100644 --- a/clients/gui-shell/launch.c +++ b/clients/gui-shell/launch.c @@ -23,6 +23,7 @@ #include #include #include +#include #ifdef HAVE_CONFIG_H #include @@ -30,7 +31,44 @@ #define _(text) gettext(text) +int running(char *pf) +{ + FILE *pfs; + char buf[1024]; + int pid; + + if((pfs = fopen(pf, "r")) == NULL) { + perror(pf); + return(0); + } + fgets(buf, sizeof(buf), pfs); + fclose(pfs); + if((pid = atoi(buf)) == 0) + return(0); + return(!kill(pid, 0)); +} + int main(int argc, char **argv) { - return(0); + char cf[1024], pf[1024]; + + if(getenv("HOME") != NULL) + snprintf(cf, sizeof(cf), "%s/.doldacond.conf", getenv("HOME")); + else + snprintf(cf, sizeof(cf), "%s/.doldacond.conf", getpwuid(getuid())->pw_dir); + if(getenv("HOME") != NULL) + snprintf(pf, sizeof(pf), "%s/.doldacond.pid", getenv("HOME")); + else + snprintf(pf, sizeof(pf), "%s/.doldacond.pid", getpwuid(getuid())->pw_dir); + if(access(cf, F_OK)) { + execlp("dolconf", "dolconf", "-a", NULL); + perror("dolconf"); + } else if(access(pf, F_OK) || !running(pf)) { + execlp("doldacond-shell", "doldacond-shell", NULL); + perror("doldacond-shell"); + } else { + execlp("dolcon", "dolcon", NULL); + perror("dolcon"); + } + return(127); } -- 2.11.0