title: How to launch a desktop application in Ubuntu/Debian on system startup
body: <p>I've done a hell lot of research, all of which say something like "add your script in init.d" "link symbol in rc*.d", but I still cannot understand without an example. I've tried many times but all failed.</p>
  
  <p>My problem is as simple as:
  How to launch <code>/usr/bin/gedit</code> on Ubuntu/Debian (desktop version) startup (after user login)?</p>
  
  <p>Any help is greatly appreciated!</p>
  
  <p><strong>Edit:</strong> So here is what I have done so far:</p>
  
  <p>1) I added a new line <code>/usr/bin/gedit</code> before <code>exit 0</code> in <code>/etc/rc.local</code>, and ran <code>sudo chmod a+x /etc/rc.local</code>. However, when I reboot and logged in to the desktop, nothing happened.</p>
  
  <p>2) (Having clear the new line added in <code>/etc/rc.local</code>) I created a script <code>/etc/init.d/gedit</code>, of which the content is:</p>
  
  <pre><code>case "$1" in
      start)
          /usr/bin/gedit
          ;;
      stop)
          killall gedit
          ;;
      restart)
          $0 stop
          sleep 5
          $0 start
          ;;
      reload|force-reload)
  esac
  </code></pre>
  
  <p>And then I ran <code>sudo chmod a+x /etc/init.d/gedit</code>. Next, I ran <code>sudo update-rc.d gedit defaults</code>, which gave me the following output:</p>
  
  <pre><code>update-rc.d: warning: /etc/init.d/gedit missing LSB information
  update-rc.d: see &lt;http://wiki.debian.org/LSBInitScript&gt;
   Adding system startup for /etc/init.d/gedit ...
     /etc/rc0.d/K20gedit -&gt; ../init.d/gedit
     /etc/rc1.d/K20gedit -&gt; ../init.d/gedit
     /etc/rc6.d/K20gedit -&gt; ../init.d/gedit
     /etc/rc2.d/S20gedit -&gt; ../init.d/gedit
     /etc/rc3.d/S20gedit -&gt; ../init.d/gedit
     /etc/rc4.d/S20gedit -&gt; ../init.d/gedit
     /etc/rc5.d/S20gedit -&gt; ../init.d/gedit
  </code></pre>
  
  <p>Then I tried <code>invoke-rc.d gedit start</code>, and <code>gedit</code> popped up as intended. <strong>However, when I reboot and logged in to the desktop, again nothing happened.</strong></p>
  
  <p><strong>P.S.</strong> Setting up in <code>Startup Applications</code> of Ubuntu does work, but what I want is actually a more general approach which can be used when distributing my own software package.</p>