# class KAutostart

###

Module | kdecore
Namespace |
Class | KAutostart
Inherits | QObject

KAutostart provides a programmatic means to control the state of autostart services on a per-user basis. This is useful for applications that wish to offer a configurable means to allow the application to be autostarted.

By using this class you future-proof your applications against potential future or platform-specific changes to the autostart mechanism(s).

Typical usage might look like:

    KAutostart autostart; // without an entryName arg, gets name from KAboutData
    autostart.setAutostarts(true); // will now start up when the user logs in

    // set the value in our configuration settings to reflect whether or not
    // we will actually start up on log in
    config.setAutoStart(autostart.autoStarts());

### enums

- Condition { NoConditions, CheckCommand }
  typesafe object: Conditions
- StartPhase { BaseDesktop, DesktopServices, Applications }

enum details

### methods

- KAutostart (entryName, parent)

  returns ctor
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  entryName | QString | QString()
  parent | QObject | 0

  Creates a new KAutostart object that represents the autostart service "entryName". If the service already exists in the system then the values associated with that service, such as the executable command, will be loaded as well.

  Note that unless this service is explicitly set to autostart, simply creating a KAutostart object will not result in the service being autostarted on next log in.

  If no such service is already registered and the command to be executed on startup is not the same as entryName, then you will want to set the associated command with setExec(const QString&)

  See also setExec

  entryName - the name used to identify the service. If none is provided then it uses the name registered with KAboutData.

  parent - QObject

- KAutostart (a0, a1)

  returns ctor
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | QString | QString()
  a1 | QObject | 0

- addToAllowedEnvironments (environment)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  environment | QString |

  Adds an environment to the list of environments this service may start in.

  See also setAllowedEnvironments(), removeFromAllowedEnvironments()

- addToExcludedEnvironments (environment)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  environment | QString |

  Adds an environment to the list of environments this service may not be autostarted in

  See also removeFromExcludedEnvironments()

- allowedEnvironments ( )

  returns QStringList

  Returns the list of environments (e.g. "KDE") this service is allowed to start in.

  This does not take other autostart conditions into account. If any environment is added to the allowed environments list, then only those environments will be allowed to autoload the service. If an environment is marked as both allowed and excluded, it will be excluded.

  See also setAllowedEnvironments()

- autostarts (environment, check)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  environment | QString | QString()
  check | KAutostart.Conditions | KAutostart.NoConditions

  Returns whether or not the service represented by entryName in the autostart system is set to autostart at login or not

  environment - if provided the check will be performed as if being loaded in that environment

  check - autostart conditions to check for (see commandToCheck())

  See also setAutostarts()

- command ( )

  returns QString

  Returns the associated command for this autostart service

  See also setCommand()

- commandToCheck ( )

  returns QString

  Returns the executable to check for when attempting to autostart this service. If the executable is not found in the user's environment, it will not autostart.

  See also setCommandToCheck()

- excludedEnvironments ( )

  returns QStringList

  Returns the list of environments this service is explicitly not allowed to start in.

  This does not take other autostart conditions such as into account. If the same environment is also marked as allowed, it will still be excluded.

  See also setExcludedEnvironments()

- isServiceRegistered (entryName)

  returns bool
  static

  Argument | Type | Default
  --- | --- | ---
  entryName | QString |

  Checks whether or not a service by the given name entryName is registered with the autostart system. Does not check whether or not it is set to actually autostart or not.

  entryName - the name of the service to check for

- removeFromAllowedEnvironments (environment)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  environment | QString |

  Removes an environment to the list of environments this service may start in.

  See also addToAllowedEnvironments()

- removeFromExcludedEnvironments (environment)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  environment | QString |

  Removes an environment to the list of environments this service may not be autostarted in

  See also addToExcludedEnvironments()

- setAllowedEnvironments (environments)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  environments | QStringList |

  Sets the environments this service is allowed to start in

  See also allowedEnvironments(), addToAllowedEnvironments()

- setAutostarts (autostart)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  autostart | bool |

  Sets the given exec to start automatically at login

  autostart - will register with the autostart facility when true and deregister when false

  See also autostarts()

- setCommand (command)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  command | QString |

  Set the associated command for this autostart service

  See also command()

- setCommandToCheck (exec)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  exec | QString |

  Sets the executable to check for the existence of when autostarting this service

  See also commandToCheck()

- setExcludedEnvironments (environments)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  environments | QStringList |

  Sets the environments this service is not allowed to start in

  See also excludedEnvironments(), addToExcludedEnvironments()

- setStartPhase (phase)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  phase | KAutostart.StartPhase |

  Sets the service (by name) this service should be started after.

  Note that this is KDE specific and may not work in other environments.

  See also StartPhase, startPhase()

- setVisibleName (entryName)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  entryName | QString |

  Sets the user-visible name for this autostart service.

  See also visibleName()

- startPhase ( )

  returns KAutostart.StartPhase

  Returns the autostart phase this service is started in.

  Note that this is KDE specific and may not work in other environments.

  See also StartPhase, setStartPhase()

- visibleName ( )

  returns QString

  Returns the user-visible name this autostart service is registered as

  See also setVisibleName(), setEntryName()

### enums - detail

- Condition { NoConditions, CheckCommand }

  Flags for each of the conditions that may affect whether or not a service actually autostarted on login

  typesafe object: Conditions

NoConditions - 0 -
CheckCommand - 1 -

- StartPhase { BaseDesktop, DesktopServices, Applications }

  the essential desktop services such as panels and window managers

  | BaseDesktop | - 0 | - |
  | DesktopServices | - 1 | - |
  | Applications | - 2 | - |