summaryrefslogtreecommitdiffstats
path: root/twin
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2014-11-19 12:25:40 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2014-11-19 12:25:40 -0600
commit9b9b436ba88b8fab2ea20ae32e92668d1a2f96a3 (patch)
tree4b42903aa6d6f73ee6124b7a896a4ae723a48de7 /twin
parentcc05f1cba11a387934e75f1aba82b3382899ae7b (diff)
downloadtdebase-9b9b436ba88b8fab2ea20ae32e92668d1a2f96a3.tar.gz
tdebase-9b9b436ba88b8fab2ea20ae32e92668d1a2f96a3.zip
Write compton-tde pid file to tmp
This resolves Bug 887
Diffstat (limited to 'twin')
-rw-r--r--twin/compton-tde/compton.c48
-rw-r--r--twin/workspace.cpp52
2 files changed, 42 insertions, 58 deletions
diff --git a/twin/compton-tde/compton.c b/twin/compton-tde/compton.c
index a5eb67f1..3f9b65e6 100644
--- a/twin/compton-tde/compton.c
+++ b/twin/compton-tde/compton.c
@@ -105,24 +105,18 @@ int my_exit_code = 3;
void write_pid_file(pid_t pid)
{
#ifdef WRITE_PID_FILE
-#ifdef USE_ENV_HOME
- const char *home = getenv("HOME");
-#else
- const char *home;
- struct passwd *p;
- p = getpwuid(getuid());
- if (p)
- home = p->pw_dir;
- else
- home = getenv("HOME");
-#endif
const char *filename;
- const char *configfile = "/.compton-tde.pid";
- int n = strlen(home)+strlen(configfile)+1;
+ const char *pidfile = "compton-tde.pid";
+ char uidstr[sizeof(uid_t)*8+1];
+ sprintf(uidstr, "%d", getuid());
+ int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
filename = (char*)malloc(n*sizeof(char));
memset(filename,0,n);
- strcat(filename, home);
- strcat(filename, configfile);
+ strcat(filename, P_tmpdir);
+ strcat(filename, "/.");
+ strcat(filename, uidstr);
+ strcat(filename, "-");
+ strcat(filename, pidfile);
/* now that we did all that by way of introduction...write the file! */
FILE *pFile;
@@ -142,24 +136,18 @@ void write_pid_file(pid_t pid)
void delete_pid_file()
{
#ifdef WRITE_PID_FILE
-#ifdef USE_ENV_HOME
- const char *home = getenv("HOME");
-#else
- const char *home;
- struct passwd *p;
- p = getpwuid(getuid());
- if (p)
- home = p->pw_dir;
- else
- home = getenv("HOME");
-#endif
const char *filename;
- const char *configfile = "/.compton-tde.pid";
- int n = strlen(home)+strlen(configfile)+1;
+ const char *pidfile = "compton-tde.pid";
+ char uidstr[sizeof(uid_t)*8+1];
+ sprintf(uidstr, "%d", getuid());
+ int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
filename = (char*)malloc(n*sizeof(char));
memset(filename,0,n);
- strcat(filename, home);
- strcat(filename, configfile);
+ strcat(filename, P_tmpdir);
+ strcat(filename, "/.");
+ strcat(filename, uidstr);
+ strcat(filename, "-");
+ strcat(filename, pidfile);
/* now that we did all that by way of introduction...delete the file! */
unlink(filename);
diff --git a/twin/workspace.cpp b/twin/workspace.cpp
index 210ab775..b6b1e2f6 100644
--- a/twin/workspace.cpp
+++ b/twin/workspace.cpp
@@ -234,22 +234,20 @@ Workspace::Workspace( bool restore )
}
else if (!disable_twin_composition_manager)
{
- // If kompmgr is already running, send it SIGTERM
- // Attempt to load the kompmgr pid file
- const char *home;
- struct passwd *p;
- p = getpwuid(getuid());
- if (p)
- home = p->pw_dir;
- else
- home = getenv("HOME");
+ // If compton-tde is already running, send it SIGTERM
+ // Attempt to load the compton-tde pid file
char *filename;
- const char *configfile = "/.kompmgr.pid";
- int n = strlen(home)+strlen(configfile)+1;
+ const char *pidfile = "compton-tde.pid";
+ char uidstr[sizeof(uid_t)*8+1];
+ sprintf(uidstr, "%d", getuid());
+ int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
filename = (char*)malloc(n*sizeof(char));
memset(filename,0,n);
- strcat(filename, home);
- strcat(filename, configfile);
+ strcat(filename, P_tmpdir);
+ strcat(filename, "/.");
+ strcat(filename, uidstr);
+ strcat(filename, "-");
+ strcat(filename, pidfile);
// Now that we did all that by way of introduction...read the file!
FILE *pFile;
@@ -258,7 +256,7 @@ Workspace::Workspace( bool restore )
int kompmgrpid = 0;
if (pFile)
{
- printf("[twin-workspace] Using '%s' as kompmgr pidfile\n\n", filename);
+ printf("[twin-workspace] Using '%s' as compton-tde pidfile\n\n", filename);
// obtain file size
fseek (pFile , 0 , SEEK_END);
unsigned long lSize = ftell (pFile);
@@ -1085,22 +1083,20 @@ void Workspace::slotReconfigure()
{
bool tmp = options->useTranslucency;
- // If kompmgr is already running, sending SIGUSR2 will force a reload of its settings
- // Attempt to load the kompmgr pid file
- const char *home;
- struct passwd *p;
- p = getpwuid(getuid());
- if (p)
- home = p->pw_dir;
- else
- home = getenv("HOME");
+ // If compton-tde is already running, sending SIGUSR2 will force a reload of its settings
+ // Attempt to load the compton-tde pid file
char *filename;
- const char *configfile = "/.kompmgr.pid";
- int n = strlen(home)+strlen(configfile)+1;
+ const char *pidfile = "compton-tde.pid";
+ char uidstr[sizeof(uid_t)*8+1];
+ sprintf(uidstr, "%d", getuid());
+ int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
filename = (char*)malloc(n*sizeof(char));
memset(filename,0,n);
- strcat(filename, home);
- strcat(filename, configfile);
+ strcat(filename, P_tmpdir);
+ strcat(filename, "/.");
+ strcat(filename, uidstr);
+ strcat(filename, "-");
+ strcat(filename, pidfile);
// Now that we did all that by way of introduction...read the file!
FILE *pFile;
@@ -1109,7 +1105,7 @@ void Workspace::slotReconfigure()
int kompmgrpid = 0;
if (pFile)
{
- printf("[twin-workspace] Using '%s' as kompmgr pidfile\n\n", filename);
+ printf("[twin-workspace] Using '%s' as compton-tde pidfile\n\n", filename);
// obtain file size
fseek (pFile , 0 , SEEK_END);
unsigned long lSize = ftell (pFile);