View | Details | Raw Unified | Return to bug 178930
Collapse All | Expand All

(-)./kcontrol/arts/Makefile.am.sav (+6 lines)
Lines 1-3 Link Here
1
bin_PROGRAMS = arts-start
2
3
arts_start_SOURCES = arts-start.cpp
4
arts_start_LDFLAGS = $(all_libraries)
5
arts_start_LDADD = $(LIB_KDECORE)
6
1
kde_module_LTLIBRARIES = kcm_arts.la
7
kde_module_LTLIBRARIES = kcm_arts.la
2
8
3
kcm_arts_la_SOURCES = arts.cpp generaltab.ui hardwaretab.ui krichtextlabel.cpp
9
kcm_arts_la_SOURCES = arts.cpp generaltab.ui hardwaretab.ui krichtextlabel.cpp
(-)./kcontrol/arts/arts-start.cpp.sav (+78 lines)
Line 0 Link Here
1
/*
2
3
    Copyright (C) 2007 Lubos Lunak <l.lunak@suse.cz>
4
5
    This program is free software; you can redistribute it and/or modify
6
    it under the terms of the GNU General Public License as published by
7
    the Free Software Foundation; either version 2 of the License, or
8
    (at your option) any later version.
9
10
    This program is distributed in the hope that it will be useful,
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
    GNU General Public License for more details.
14
15
    You should have received a copy of the GNU General Public License
16
    along with this program; if not, write to the Free Software
17
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
19
    Permission is also granted to link this program with the Qt
20
    library, treating Qt like a library that normally accompanies the
21
    operating system kernel, whether or not that is in fact the case.
22
23
*/
24
25
#include <kconfig.h>
26
#include <kinstance.h>
27
#include <stdlib.h>
28
#include <X11/Xlib.h>
29
30
static bool arts_running()
31
    {
32
    int status = system( "artsshell status >/dev/null 2>/dev/null" );
33
    return WIFEXITED( status ) && WEXITSTATUS( status ) == 0;
34
    }
35
36
int main()
37
    {
38
    // Try to launch arts this way only a single time in the whole session. After first
39
    // try set X property on the root window and following attemps bail out if it's set.
40
    Display* dpy = XOpenDisplay( NULL );
41
    if( dpy == NULL ) // don't launch arts without X
42
        return 4;
43
    Atom atom = XInternAtom( dpy, "_KDE_ARTS_TRIED", False );
44
    int count;
45
    Atom* atoms = XListProperties( dpy, DefaultRootWindow( dpy ), &count );
46
    bool tried = false;
47
    if( atoms != NULL )
48
        {
49
        for( int i = 0;
50
             i < count;
51
             ++i )
52
            if( atoms[ i ] == atom )
53
                {
54
                tried = true;
55
                break;
56
                }
57
        }
58
    if( tried ) // this should probably wait, but artsshell will result in calling this too
59
        return 2;
60
    long dummy = 1;
61
    XChangeProperty( dpy, DefaultRootWindow( dpy ), atom, atom, 32, PropModeReplace, (const unsigned char*)&dummy, 1 );
62
    XCloseDisplay( dpy );
63
    KInstance inst( "arts-start" );
64
    KConfig config("kcmartsrc", true, false);
65
    config.setGroup("Arts");
66
    if( !config.readBoolEntry("StartServer",true))
67
        return 2;
68
    system( "kcminit arts" );
69
    for( int i = 0;
70
         i < 50; // give it 5 seconds
71
         ++i )
72
        {
73
        if( arts_running())
74
            return 0;
75
        usleep( 100 * 1000 );
76
        }
77
    return 3;
78
    }

Return to bug 178930