• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kdecore
 

kdecore

  • kdecore
kdetcompmgr.cpp
1 /***************************************************************************
2  * Copyright (C) 2011 Timothy Pearson <kb9vqf@pearsoncomputing.net> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License *
15  * along with this program; if not, write to the *
16  * Free Software Foundation, Inc., *
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18  ***************************************************************************/
19 
20 #include <unistd.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 
24 #include <kapplication.h>
25 #include <kaboutdata.h>
26 #include <kcmdlineargs.h>
27 #include <klocale.h>
28 #include <kdebug.h>
29 #include <kconfig.h>
30 
31 #include <pwd.h>
32 #include <signal.h>
33 
34 static const char description[] =
35  I18N_NOOP("TDE composition manager detection utility");
36 
37 static const char version[] = "0.1";
38 
39 static KCmdLineOptions options[] =
40 {
41  KCmdLineLastOption
42 };
43 
44 int main(int argc, char **argv)
45 {
46  KAboutData about("kdetcompmgr", I18N_NOOP("kdetcompmgr"), version, description,
47  KAboutData::License_GPL, "(C) 2011 Timothy Pearson", 0, 0, "kb9vqf@pearsoncomputing.net");
48  about.addAuthor( "Timothy Pearson", 0, "kb9vqf@pearsoncomputing.net" );
49  KCmdLineArgs::init(argc, argv, &about);
50  KCmdLineArgs::addCmdLineOptions( options );
51 
52  KApplication app;
53 
54  KConfig config("kwinrc", true);
55  config.setGroup( "Notification Messages" );
56  if (!config.readBoolEntry("UseTranslucency",false)) {
57  // Attempt to load the kompmgr pid file
58  const char *home;
59  struct passwd *p;
60  p = getpwuid(getuid());
61  if (p)
62  home = p->pw_dir;
63  else
64  home = getenv("HOME");
65  char *filename;
66  const char *configfile = "/.kompmgr.pid";
67  int n = strlen(home)+strlen(configfile)+1;
68  filename = (char*)malloc(n*sizeof(char));
69  memset(filename,0,n);
70  strcat(filename, home);
71  strcat(filename, configfile);
72 
73  // Now that we did all that by way of introduction...read the file!
74  FILE *pFile;
75  char buffer[255];
76  pFile = fopen(filename, "r");
77  int kompmgrpid = 0;
78  if (pFile) {
79  printf("[kdetcompmgr] Using '%s' as kompmgr pidfile\n", filename);
80  // obtain file size
81  fseek (pFile , 0 , SEEK_END);
82  unsigned long lSize = ftell (pFile);
83  if (lSize > 254)
84  lSize = 254;
85  rewind (pFile);
86  fclose(pFile);
87  kompmgrpid = atoi(buffer);
88  }
89 
90  free(filename);
91  filename = NULL;
92 
93  if (kompmgrpid) {
94  kill(kompmgrpid, SIGTERM);
95  }
96  }
97 
98  if (app.detectCompositionManagerAvailable(false, false)) { // Perform a shallow check for the composite extension (a deep check would cause noticeable flicker)
99  KConfig config2("kwinrc", true);
100  config2.setGroup( "Notification Messages" );
101  if (config2.readBoolEntry("UseTranslucency",false)) {
102  app.detectCompositionManagerAvailable(true, true);
103  return 2;
104  }
105  else {
106  app.detectCompositionManagerAvailable(true, false);
107  return 0;
108  }
109  }
110  else {
111  app.detectCompositionManagerAvailable(true, false);
112  return 1;
113  }
114 }
115 
KStdAction::home
KAction * home(const TQObject *recvr, const char *slot, KActionCollection *parent, const char *name=0)
KApplication
Controls and provides information to all KDE applications.
Definition: kapplication.h:96
klocale.h
KCmdLineOptions
Structure that holds command line options.
Definition: kcmdlineargs.h:40
KLocale::I18N_NOOP
#define I18N_NOOP(x)
Definition: klocale.h:52
KAboutData
This class is used to store information about a program.
Definition: kaboutdata.h:182
KConfig
Access KDE Configuration entries.
Definition: kconfig.h:43
KCmdLineArgs::init
static void init(int _argc, char **_argv, const char *_appname, const char *programName, const char *_description, const char *_version, bool noKApp=false)
Initialize class.
Definition: kcmdlineargs.cpp:127
KCmdLineArgs::addCmdLineOptions
static void addCmdLineOptions(const KCmdLineOptions *options, const char *name=0, const char *id=0, const char *afterId=0)
Add options to your application.
Definition: kcmdlineargs.cpp:206
KApplication::detectCompositionManagerAvailable
bool detectCompositionManagerAvailable(bool force_available=false, bool available=true)
Detects the availability of a composition manager such as kompmgr Note that calling this method will ...
Definition: kapplication.cpp:2043

kdecore

Skip menu "kdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdecore

Skip menu "kdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdecore by doxygen 1.8.11
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |