summaryrefslogtreecommitdiffstats
path: root/kdecore/kdetcompmgr.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-08-15 04:20:12 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-08-15 04:20:12 +0000
commit5ccf69ae5927a6978b1f7bf70205822f06e61bd0 (patch)
treea1186acc4eee767c48761d96acb4fa6461cb6819 /kdecore/kdetcompmgr.cpp
parent79a4d6dfad2786fb412167638c5beb4af614b9e8 (diff)
downloadtdelibs-5ccf69ae5927a6978b1f7bf70205822f06e61bd0.tar.gz
tdelibs-5ccf69ae5927a6978b1f7bf70205822f06e61bd0.zip
Kill kcompmgr before Trinity startup if it was disabled by the user
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1247221 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdecore/kdetcompmgr.cpp')
-rw-r--r--kdecore/kdetcompmgr.cpp56
1 files changed, 53 insertions, 3 deletions
diff --git a/kdecore/kdetcompmgr.cpp b/kdecore/kdetcompmgr.cpp
index c5cbd415f..e83c640b3 100644
--- a/kdecore/kdetcompmgr.cpp
+++ b/kdecore/kdetcompmgr.cpp
@@ -28,6 +28,9 @@
#include <kdebug.h>
#include <kconfig.h>
+#include <pwd.h>
+#include <signal.h>
+
static const char description[] =
I18N_NOOP("TDE composition manager detection utility");
@@ -47,12 +50,59 @@ int main(int argc, char **argv)
KCmdLineArgs::addCmdLineOptions( options );
KApplication app;
+
+ KConfig config("kwinrc", true);
+ config.setGroup( "Notification Messages" );
+ if (!config.readBoolEntry("UseTranslucency",false)) {
+ // 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");
+ char *filename;
+ const char *configfile = "/.kompmgr.pid";
+ int n = strlen(home)+strlen(configfile)+1;
+ filename = (char*)malloc(n*sizeof(char));
+ memset(filename,0,n);
+ strcat(filename, home);
+ strcat(filename, configfile);
+
+ printf("reading '%s' as kompmgr pidfile\n\n", filename);
+
+ // Now that we did all that by way of introduction...read the file!
+ FILE *pFile;
+ char buffer[255];
+ pFile = fopen(filename, "r");
+ int kompmgrpid = 0;
+ if (pFile) {
+ // obtain file size
+ fseek (pFile , 0 , SEEK_END);
+ unsigned long lSize = ftell (pFile);
+ if (lSize > 254)
+ lSize = 254;
+ rewind (pFile);
+ size_t result = fread (buffer, 1, lSize, pFile);
+ fclose(pFile);
+ kompmgrpid = atoi(buffer);
+ }
+
+ free(filename);
+ filename = NULL;
+
+ if (kompmgrpid) {
+ kill(kompmgrpid, SIGTERM);
+ }
+ }
+
app.detectCompositionManagerAvailable();
// if (!app.isCompositionManagerAvailable()) {
- KConfig config("kwinrc", true);
- config.setGroup( "Notification Messages" );
- if (config.readBoolEntry("UseTranslucency",false)) {
+ KConfig config2("kwinrc", true);
+ config2.setGroup( "Notification Messages" );
+ if (config2.readBoolEntry("UseTranslucency",false)) {
app.detectCompositionManagerAvailable(true, true);
return 2;
}