tdecore
kdetcompmgr.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <unistd.h>
00021 #include <stdio.h>
00022 #include <stdlib.h>
00023
00024 #include <tdeapplication.h>
00025 #include <tdeaboutdata.h>
00026 #include <tdecmdlineargs.h>
00027 #include <tdelocale.h>
00028 #include <kdebug.h>
00029 #include <tdeconfig.h>
00030
00031 #include <pwd.h>
00032 #include <signal.h>
00033
00034 static const char description[] =
00035 I18N_NOOP("TDE composition manager detection utility");
00036
00037 static const char version[] = "0.1";
00038
00039 static TDECmdLineOptions options[] =
00040 {
00041 TDECmdLineLastOption
00042 };
00043
00044 int main(int argc, char **argv)
00045 {
00046 TDEAboutData about("kdetcompmgr", I18N_NOOP("kdetcompmgr"), version, description,
00047 TDEAboutData::License_GPL, "(C) 2011-2014 Timothy Pearson", 0, 0, "kb9vqf@pearsoncomputing.net");
00048 about.addAuthor( "Timothy Pearson", 0, "kb9vqf@pearsoncomputing.net" );
00049 TDECmdLineArgs::init(argc, argv, &about);
00050 TDECmdLineArgs::addCmdLineOptions( options );
00051
00052 TDEApplication app;
00053
00054 TDEConfig config("twinrc", true);
00055 config.setGroup( "Notification Messages" );
00056 if (!config.readBoolEntry("UseTranslucency",false)) {
00057
00058 char *filename;
00059 const char *pidfile = "compton-tde.pid";
00060 char uidstr[sizeof(uid_t)*8+1];
00061 sprintf(uidstr, "%d", getuid());
00062 int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
00063 filename = (char*)malloc(n*sizeof(char)+1);
00064 memset(filename,0,n);
00065 strcat(filename, P_tmpdir);
00066 strcat(filename, "/.");
00067 strcat(filename, uidstr);
00068 strcat(filename, "-");
00069 strcat(filename, pidfile);
00070
00071
00072 FILE *pFile;
00073 char buffer[255];
00074 pFile = fopen(filename, "r");
00075 int kompmgrpid = 0;
00076 if (pFile) {
00077 printf("[kdetcompmgr] Using '%s' as compton-tde pidfile\n", filename);
00078
00079 fseek (pFile , 0 , SEEK_END);
00080 unsigned long lSize = ftell (pFile);
00081 if (lSize > 254)
00082 lSize = 254;
00083 rewind (pFile);
00084 fclose(pFile);
00085 kompmgrpid = atoi(buffer);
00086 }
00087
00088 free(filename);
00089 filename = NULL;
00090
00091 if (kompmgrpid) {
00092 kill(kompmgrpid, SIGTERM);
00093 }
00094 }
00095
00096 if (app.detectCompositionManagerAvailable(false, false)) {
00097 TDEConfig config2("twinrc", true);
00098 config2.setGroup( "Notification Messages" );
00099 if (config2.readBoolEntry("UseTranslucency",false)) {
00100 app.detectCompositionManagerAvailable(true, true);
00101 return 2;
00102 }
00103 else {
00104 app.detectCompositionManagerAvailable(true, false);
00105 return 0;
00106 }
00107 }
00108 else {
00109 app.detectCompositionManagerAvailable(true, false);
00110 return 1;
00111 }
00112 }
00113