Ubuntu – the startup scripts for Unity Desktop

unity

I want to run a script as soon as my lightdm authentication succeed, and my Unity starts loading. and i want to run my scripts as a root user.

where are startup scripts located in Unity ?

Best Answer

First put your script into /usr/bin and give execute permission.

Now create .desktop file in /home/[user-name]/.config/autostart/ which run your script which runs at startup.

Example:- Let your filename of script is "example" or "example.sh"

Create .desktop file with gedit with following lines and save as filename.desktop in /home/[user-name]/.config/autostart/

[Desktop Entry]
Type=Application
Exec=sudo example
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=myscript
Comment=Startup Script

Here Exec=sudo example or Exec=sudo example.sh runs your script as a root from /usr/bin Give execute permission to .desktop file.

Now, Script runs on startup.

Related Question