KDE 4.9 PyKDE API Reference

- KDE's Python API

# KAutostart Class Reference

`from PyKDE4.kdecore import *`

Inherits: QObject

## Detailed Description

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());

## Enumerations

Condition | { NoConditions, CheckCommand, CheckCondition, CheckAll }
StartPhase | { BaseDesktop, DesktopServices, Applications }

## Methods

| __init__ (self, QString entryName=QString(), QObject parent=0)
| addToAllowedEnvironments (self, QString environment)
| addToExcludedEnvironments (self, QString environment)
QStringList | allowedEnvironments (self)
bool | autostarts (self, QString environment=QString(), KAutostart.Conditions check=KAutostart.NoConditions)
bool | checkAllowedEnvironment (self, QString environment)
QString | command (self)
QString | commandToCheck (self)
QStringList | excludedEnvironments (self)
| removeFromAllowedEnvironments (self, QString environment)
| removeFromExcludedEnvironments (self, QString environment)
| setAllowedEnvironments (self, QStringList environments)
| setAutostarts (self, bool autostart)
| setCommand (self, QString command)
| setCommandToCheck (self, QString exec)
| setExcludedEnvironments (self, QStringList environments)
| setStartPhase (self, KAutostart.StartPhase phase)
| setVisibleName (self, QString entryName)
QString | startAfter (self)
KAutostart.StartPhase | startPhase (self)
QString | visibleName (self)

## Static Methods

bool | isServiceRegistered (QString entryName)

## Method Documentation

__init__ | ( | self, |
|  | QString | entryName=QString(),
|  | QObject | parent=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

Parameters:

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

addToAllowedEnvironments | ( | self, |
|  | QString | environment
| ) |  |  |

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

See also:
  setAllowedEnvironments(), removeFromAllowedEnvironments()

addToExcludedEnvironments | ( | self, |
|  | QString | environment
| ) |  |  |

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

See also:
  removeFromExcludedEnvironments()

QStringList allowedEnvironments | ( |  | self ) |

Returns the list of environments (e.g. "KDE") this service is allowed to start in. Use checkAllowedEnvironment() or autostarts() for actual checks.

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. It is not allowed to specify both allowed and excluded environments at the same time.

See also:
  setAllowedEnvironments()

bool autostarts | ( | self, |
|  | QString | environment=QString(),
|  | KAutostart.Conditions | check=KAutostart.NoConditions
| ) |  |  |

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

Parameters:

  | 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()

bool checkAllowedEnvironment | ( | self, |
|  | QString | environment
| ) |  |  |

Checks whether autostart is allowed in the given environment, depending on allowedEnvironments() and excludedEnvironments().

Since:
  4.3

QString command | ( |  | self ) |

Returns the associated command for this autostart service

See also:
  setCommand()

QString commandToCheck | ( |  | self ) |

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()

QStringList excludedEnvironments | ( |  | self ) |

Returns the list of environments this service is explicitly not allowed to start in. Use checkAllowedEnvironment() or autostarts() for actual checks.

This does not take other autostart conditions such as into account. It is not allowed to specify both allowed and excluded environments at the same time.

See also:
  setExcludedEnvironments()

removeFromAllowedEnvironments | ( | self, |
|  | QString | environment
| ) |  |  |

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

See also:
  addToAllowedEnvironments()

removeFromExcludedEnvironments | ( | self, |
|  | QString | environment
| ) |  |  |

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

See also:
  addToExcludedEnvironments()

setAllowedEnvironments | ( | self, |
|  | QStringList | environments
| ) |  |  |

Sets the environments this service is allowed to start in

See also:
  allowedEnvironments(), addToAllowedEnvironments()

setAutostarts | ( | self, |
|  | bool | autostart
| ) |  |  |

Sets the given exec to start automatically at login

Parameters:

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

See also:
  autostarts()

setCommand | ( | self, |
|  | QString | command
| ) |  |  |

Set the associated command for this autostart service

See also:
  command()

setCommandToCheck | ( | self, |
|  | QString | exec
| ) |  |  |

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

See also:
  commandToCheck()

setExcludedEnvironments | ( | self, |
|  | QStringList | environments
| ) |  |  |

Sets the environments this service is not allowed to start in

See also:
  excludedEnvironments(), addToExcludedEnvironments()

setStartPhase | ( | self, |
|  | KAutostart.StartPhase | phase
| ) |  |  |

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 | ( | self, |
|  | QString | entryName
| ) |  |  |

Sets the user-visible name for this autostart service.

See also:
  visibleName()

QString startAfter | ( |  | self ) |

Returns the name of another service that should be autostarted before this one (if that service would be autostarted).

Internal:

Since:
  4.3

KAutostart.StartPhase startPhase | ( |  | self ) |

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()

QString visibleName | ( |  | self ) |

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

See also:
  setVisibleName(), setEntryName()

## Static Method Documentation

bool isServiceRegistered | ( | QString | entryName
| ) |  |  |

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.

Parameters:

  | entryName | the name of the service to check for

## Enumeration Documentation

Condition

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

Enumerator:

  NoConditions = 0x0 |
  CheckCommand = 0x1 |
  CheckCondition = 0x2 |
  CheckAll = 0xff |

StartPhase

Enumerates the various autostart phases that occur during start-up.

Enumerator:

  BaseDesktop = 0 |
  DesktopServices = 1 |
  Applications = 2 |