autostart

Laurent Montel montel at kde.org
Tue Mar 18 14:27:11 GMT 2008


On Tuesday 18 March 2008 15:07:37 David Faure wrote:
> On Tuesday 18 March 2008, Laurent Montel wrote:
> > On Tuesday 18 March 2008 10:43:18 David Faure wrote:
> > > On Tuesday 18 March 2008, Laurent Montel wrote:
> > > > Hi,
> > > >
> > > > I worked on kcm_autostart and now we can configure autostart files.
> > > > Now I am a question:
> > > > KDE4.0 supports xdg autostart folder (.config/autostart), so it will
> > > > better to create autostart file directly in this folder.
> > > > So it will necessary to hide in kcmshell4 desktoppath "Autostart
> > > > Path" and remove in konqueror entry "Autostart" (or replace
> > > > .kde/Autostart by .config/autostart).
> > > > We keep KGlobalSettings::Autostart for compatibility.
> > > >
> > > > And we can create a script to move all .desktop (script) in
> > > > .kde/Autostart to .config/autostart.
> > > >
> > > > What do you think about it ?
> > >
> > > Maybe we need both?
> > > Using .config/autostart instead of .kde/Autostart makes a difference if
> > > you use two environments, like gnome and KDE. What you put in
> > > .config/autostart will be autostarted in both environments, and what
> > > you put in
> > > .kde/Autostart will only be started by KDE. Isn't this a feature? I
> > > mean, you might have something in your KDE autostart which you don't
> > > need/want in gnome? Looking at my own autostart folder it's pretty
> > > KDE-unrelated but maybe others have the need for the KDE-only folder?
> > > Anyone?
> >
> > Spec Desktop file has OnlyShowIn which specify if we want to start or not
> > in specific environment. (We can add a "advanced" dialog box in kcm
> > autostart to specify it)
>
> Hmm yes but my Autostart files are not .desktop files.
> Does .config/autostart also support shell scripts and binaries?
> In that case OK.

code which launchs script is here:
so we can replace  KGlobalSettings::autostartPath()  by xdg-autostart dir.

void KSMServer::runUserAutostart()
{
    // now let's execute all the stuff in the autostart folder.
    // the stuff will actually be really executed when the event loop is
    // entered, since KRun internally uses a QTimer
    QDir dir( KGlobalSettings::autostartPath() );
    if (dir.exists()) {
        const QStringList entries = dir.entryList( QDir::Files );
        foreach (const QString& file, entries) {
            // Don't execute backup files
            if ( !file.endsWith('~') && !file.endsWith(".bak") &&
                 ( file[0] != '%' || !file.endsWith('%') ) &&
                 ( file[0] != '#' || !file.endsWith('#') ) )
            {
                KUrl url( dir.absolutePath() + '/' + file );
                (void) new KRun( url, 0, true );
            }
        }
    } else {
        // Create dir so that users can find it :-)
        dir.mkpath( KGlobalSettings::autostartPath() );
    }
}

Regards.

-- 
Laurent Montel,
KDE/KOffice developer, Qt consultancy projects
Klarälvdalens Datakonsult AB, Platform-independent software solutions




More information about the kde-core-devel mailing list