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

tdecore

  • tdecore
kdetcompmgr.cpp
1/***************************************************************************
2 * Copyright (C) 2011-2014 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 <tdeapplication.h>
25#include <tdeaboutdata.h>
26#include <tdecmdlineargs.h>
27#include <tdelocale.h>
28#include <kdebug.h>
29#include <tdeconfig.h>
30
31#include <pwd.h>
32#include <signal.h>
33
34static const char description[] =
35 I18N_NOOP("TDE composition manager detection utility");
36
37static const char version[] = "0.1";
38
39static TDECmdLineOptions options[] =
40{
41 TDECmdLineLastOption
42};
43
44int main(int argc, char **argv)
45{
46 TDEAboutData about("kdetcompmgr", I18N_NOOP("kdetcompmgr"), version, description,
47 TDEAboutData::License_GPL, "(C) 2011-2014 Timothy Pearson", 0, 0, "kb9vqf@pearsoncomputing.net");
48 about.addAuthor( "Timothy Pearson", 0, "kb9vqf@pearsoncomputing.net" );
49 TDECmdLineArgs::init(argc, argv, &about);
50 TDECmdLineArgs::addCmdLineOptions( options );
51
52 TDEApplication app;
53
54 TDEConfig config("twinrc", true);
55 config.setGroup( "Notification Messages" );
56 if (!config.readBoolEntry("UseTranslucency",false)) {
57 // Attempt to load the compton-tde pid file
58 char *filename;
59 const char *pidfile = "compton-tde.pid";
60 char uidstr[sizeof(uid_t)*8+1];
61 sprintf(uidstr, "%d", getuid());
62 int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
63 filename = (char*)malloc(n*sizeof(char)+1);
64 memset(filename,0,n);
65 strcat(filename, P_tmpdir);
66 strcat(filename, "/.");
67 strcat(filename, uidstr);
68 strcat(filename, "-");
69 strcat(filename, pidfile);
70
71 // Now that we did all that by way of introduction...read the file!
72 FILE *pFile;
73 char buffer[255];
74 pFile = fopen(filename, "r");
75 int kompmgrpid = 0;
76 if (pFile) {
77 printf("[kdetcompmgr] Using '%s' as compton-tde pidfile\n", filename);
78 // obtain file size
79 fseek (pFile , 0 , SEEK_END);
80 unsigned long lSize = ftell (pFile);
81 if (lSize > 254)
82 lSize = 254;
83 rewind (pFile);
84 fclose(pFile);
85 kompmgrpid = atoi(buffer);
86 }
87
88 free(filename);
89 filename = NULL;
90
91 if (kompmgrpid) {
92 kill(kompmgrpid, SIGTERM);
93 }
94 }
95
96 if (app.detectCompositionManagerAvailable(false, false)) { // Perform a shallow check for the composite extension (a deep check would cause noticeable flicker)
97 TDEConfig config2("twinrc", true);
98 config2.setGroup( "Notification Messages" );
99 if (config2.readBoolEntry("UseTranslucency",false)) {
100 app.detectCompositionManagerAvailable(true, true);
101 return 2;
102 }
103 else {
104 app.detectCompositionManagerAvailable(true, false);
105 return 0;
106 }
107 }
108 else {
109 app.detectCompositionManagerAvailable(true, false);
110 return 1;
111 }
112}
113
TDEAboutData
This class is used to store information about a program.
Definition: tdeaboutdata.h:183
TDEApplication
Controls and provides information to all KDE applications.
Definition: tdeapplication.h:95
TDEApplication::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: tdeapplication.cpp:2108
TDECmdLineArgs::addCmdLineOptions
static void addCmdLineOptions(const TDECmdLineOptions *options, const char *name=0, const char *id=0, const char *afterId=0)
Add options to your application.
Definition: tdecmdlineargs.cpp:206
TDECmdLineArgs::init
static void init(int _argc, char **_argv, const char *_appname, const char *programName, const char *_description, const char *_version, bool noTDEApp=false)
Initialize class.
Definition: tdecmdlineargs.cpp:127
TDEConfig
Access KDE Configuration entries.
Definition: tdeconfig.h:44
TDELocale::I18N_NOOP
#define I18N_NOOP(x)
I18N_NOOP marks a string to be translated without translating it.
Definition: tdelocale.h:51
TDECmdLineOptions
Structure that holds command line options.
Definition: tdecmdlineargs.h:41
tdelocale.h

tdecore

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

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.4
This website is maintained by Timothy Pearson.