Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start Script when Gnome Starts Up

Tags:

gnome

I have a script that I need to start up after the user logs in via a nx client. From what I understand, Gnome starts up after a user logs in (correct me if I am wrong here). Where would I put my script so that it starts up after the user logs in?

Relevant Information: I am working on a redhat machine and assume that I have access only to the files within the home directory (the ~ directory) and not the / directory (can someone tell me what that directory is called? the / one). Are there any files that I can modify/add in the home directory that will help me start up my script? What about if I wanted to start the script from / directory?

Just to clarify since it might've not been clear. The ~/home directory implies all files in the home directory including the ones in the subdirectories; same with the / directory.

like image 814
Jason Zhu Avatar asked Nov 23 '11 19:11

Jason Zhu


People also ask

How to Start gnome on boot?

If you want GNOME to start automatically, try installing gdm . GDM is the default X display manager (which provides the login screen, and launches GNOME on login), and it should automatically start on boot.

How do I start Gnome Shell from terminal?

restart("Restarting…")' This is a single command - triple click the line to select it. Since this is what GNOME Shell does when running Alt + F2 and typing r , this is the best way of restarting GNOME Shell from the command line.


2 Answers

There is a specification for this purpose, and it works with any desktop environment that supports the specification (eg. KDE, GNOME2, GNOME3, ...).

You should put a Desktop Entry file (with .desktop extension) inside of ~/.config/autostart (for a user) or /etc/xdg/autostart (for the whole system). In the file you set the script to run (see the option Exec). For more information, check the Desktop Application Autostart Specification.

For example, you can put a file with the following content:

[Desktop Entry] Name=MyScript GenericName=A descriptive name Comment=Some description about your script Exec=/path/to/my/script.sh Terminal=false Type=Application X-GNOME-Autostart-enabled=true 

You can also use the graphical user interface to create one entry or Add a new entry:

  • in GNOME 2 is System/Preferences/Startup Applications.
  • in GNOME 3, press Alt+R and look for Startup Applications Preferences (typing the first letters of the name will filter it quickly) or run gnome-session-properties from there or a terminal.
like image 167
gpoo Avatar answered Oct 05 '22 10:10

gpoo


In gnome3, if you prefer a GUI based approach you could run the command: ALT + F2, then type in the window that pop ups:

gnome-session-properties 
like image 21
ernesto Avatar answered Oct 05 '22 12:10

ernesto