Run gui application on startup

I can run a script at boot by adding the following line to my crontab:

@reboot perl /path/script

That works fine. But the problem arises when I try to run a gui application such as gmail notify. It simply doesn’t run.

How do I run a gui application on startup?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Cron is not the program you’re after. To run GUI programs there are different approaches. Which one to choose depends on your desktop environment.

The traditional way is to hook it into your .xinitrc file before starting the window manager. A simple example .xinitrc looks as follows:

#!/bin/sh

# Play a login sound
ogg123 -q "${HOME}/Music/login.ogg" &

# Start a terminal emulator
urxvt -T Terminal &

# Start the window manager
exec awesome

Depending on the desktop environment, you can also use ~/.config/autostart/ and create a program.desktop file. Check that directory, if it already contains entries. That’s the easiest way, I guess.

autostart […] defines a method for automatically starting applications during the startup of a desktop environment […]

Source: freedesktop autostart specification

Method 2

I just had a horrible time doing this in Lubuntu, so I thought I would share how I finally got it. Create a .desktop file in /etc/xdg/autostart. You can get the format from freedesktop Desktop Application Autostart Specification and/or just look at other desktop configuration files in that folder. My big problem was that I was trying to put it in the folders listed by the command

echo $XDG_CONFIG_DIRS/autostart

but that gives folders that don’t work, as well as the one above. Perhaps, on other systems, you could get a hint about where to put it from

sudo find / -name *.desktop

Another little hint – if you write a .desktop file, you can check it by putting it in your desktop folder. It should show up as an icon, and when opening it, it should run your program.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x