Automatically starting an application or script on login

Sometimes you will want to automatically start an application or script when a particular user logs in. For example, I like to have the system monitor gkrellm automatically started and always running. How this is done is environment-specific; here are my notes on those operating systems, desktop environments, and window managers I am familiar with.

What isn’t discussed here is how to start something on boot, or something for all users. On Linux that is done in your /etc/init.d/ scripts, and is outside the scope of this article.

Background processes should usually be run with lowered priority. How to do so is operating system-specific and illustrated below when known.

Frequently you will want your automatically started application or script to be minimized to a notification area, dock, or system tray. How to do so is specific to your application or environment; consult the applicable documentation.

General notes
To run a command with lowered priority, precede the command with nice. For example, to run the online backup client SpiderOak with lowered priority, nice SpiderOak.

In a code editor, open ~/.fluxbox/startup and find the section that begins “Applications you want to run with fluxbox”. Add what you want to this section, ending your command with an ampersand. For our example of SpiderOak, I edited this section to read:

# Applications you want to run with fluxbox.
nice SpiderOak &

Gnome 2
On the system menu, open Preferences – Startup Applications. Select “Add”, filling out the dialog box as desired. To run the bittorrent client Transmission with lowered priority and minimized to the notification area, I first consulted transmission-gtk –help for the proper option, and then entered:

  • Name: Transmission
  • Command: nice transmission-gtk -m
  • Comment: Bittorrent client

Unity (default desktop environment of Ubuntu)
See How do I start applications automatically on login? To judge from the link it appears to be done in the GUI in a manner similar to Gnome and Xfce, and to support the use of .desktop files in ~/.config/autostart/.

Xfce 4
Open the Xfce Settings Manager. Every packager has his own idea on where to place the Settings Manager on the menu, so you may need to hunt for it. On openSUSE 12.3, it’s on the menu at Settings – Settings Manager. Alternatively, open it from a terminal with xfce4-settings-manager.

Open Session and Startup – Application Autostart. Select “Add”, filling out the dialog box as desired. To run Gkrellm, I entered:

  • Name: Gkrellm
  • Description: System monitor
  • Command: nice gkrellm

If you don’t do no stinkin’ GUI tools, you can directly edit the .desktop files in ~/.config/autostart/. I suspect that this works for all desktop environments and not just Xfce, but I do not in fact know for sure. In particular I have received a report that it works for LXDE.

Some applications commonly started on login have trouble in Xfce. This is because Xfce does not use the root window and instead sets the background on a layer above the root window. Applications that draw to the root window are thus obscured. Applications that use pseudo-transparency also have trouble. These applications intend to appear transparent, but in reality read the root window and change their own backgrounds to match, which of course fails with Xfce.

Often there are per-application workarounds; check the application’s documentation and support channel. Another method widely reported to work (although I have had no opportunity to test it) is to autostart a script, which sleeps for several seconds to give Xfce time to draw its background before launching the application.

There are several ways to automatically start an application in Windows:

  • Place a shortcut in the startup folder. This is the easiest method, and it empowers the end-user by clearly indicating what is being run.
  • Call it from the Registry. This is less obvious to the end-user, and so is appropriate for damn-the-user situations such as locking down public kiosks.
  • Call it from the Group Policy Editor. I have not tried this method.
  • Rootkitting. This is a cure that is worse than the disease and I mention it here only so that you learn from Sony’s error, even if Sony itself has not.

man nice (not very helpful)

This article was last updated on 14 May 2016.


About Warren Post

So far: Customer support guy, jungle guide, IT consultant, beach bum, entrepreneur, teacher, diplomat, over-enthusiastic cyclist. Tomorrow: who knows?
This entry was posted in Uncategorized and tagged , , , , . Bookmark the permalink.

8 Responses to Automatically starting an application or script on login

  1. Pingback: System monitoring with Conky | Warren's tech notes

  2. Pingback: Using SpiderOak | Warren's tech notes

  3. Pingback: System monitoring with Gkrellm | A maze of twisty little passages

  4. Pingback: Using qBittorrent | A maze of twisty little passages

  5. Pingback: Tweaking Xfce | A maze of twisty little passages

  6. Pingback: Using Transmission | A maze of twisty little passages

  7. Pingback: Concealing a Windows service or application from users | A maze of twisty little passages

  8. Pingback: Gerencia installation notes | A maze of twisty little passages

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s