0

I'm using Debian with Gnome3 and I'd like to know if there is an elegant way to start one program when another one is started.

My use case is the following: I use keepass as my password manager and I don't want to start it manually when I start my favorite web browser (Iceweasel). Also Iceweasel is automatically started when I log in.

For now I use desktop files to auto start Iceweasel and Keepass at log in. The problem is that keepass starts before the web browser, I start typing my password on Keepass, Iceweasel starts and take the focus so I have to go back on Keepass to finish typing my password which is not really convenient.

So my main interrogations are:

  • Does Gnome3 as a feature to automatically start a GUI program after another one is started?
  • If Gnome3 doesn't provide such a feature, should I create a shell script to do it. And if so how can I do it? (I'm familiar with basic shell scripting but I have no idea how to do this actually)
  • Is there a solution other than built-in Gnome3 feature and script?

Some notes about my question:

  • I've found a similar question using Windows but none using Linux and more precisely Gnome.
  • It would be great if the solution worked with the Iceweasel instance automatically started at login but also with others instances that I would have started later after closing the first instance.
  • EDIT Due to my Vimperator configuration I don't have a navigation bar in my Iceweasel. This implies that using plugins like KeeFox isn't that convenient because I don't have a direct access to the plugin icon.

1 Answer 1

1

First question: No, you can't be 100% sure that your program will launch in a specific order (and this isn't related to GNOME). The process are queued and every quantum of time, an other one is elected to be rang by the CPU, and it depend on kernel settings (ie, your OS). So you can use a shell script. It's not the better solution, we'll find out why.

For the shell script, a primary approach would be to invoke keepass and Iceweasel just by writing their names in a script, but this won't work

(This won't work, don't use it)

#! /bin/bash
Keepass
Iceweasel

(Any line beginning with a # will be treated as a comment. A line beginning with #! Is called a shebang and has the only purpose to indicate what shell to use, but don't bother with it for the moment if you're new to shell scripts)

This won't work because the shell will wait for the first program to be terminated before dealing with the second line.

So you have to indicate to the shell that you don't want to wait for the end of one program for the other to begin. You can do it by using & after a command Eg:

Keepass &

Using this just allows you to keep using your shell.

So you'd think you can do

#! /bin/bash
Keepass &
Iceweasel

It will work, but won't solve your problem. As it is very unlikely that any of those programs are coded in a way that makes them send a signal when there are fully loaded, we have to use a dirty trick. I only recommend it as this is for your personal convenience, but remember that using this for anything in a professional level or system level is very bad. You will tell your computer just to wait a few seconds before launching the other program. This is done by using the sleep command. Eg: sleep 10 will make your script wait for ten seconds

So your script should look like

#! /bin/bash
Keepass &
sleep 10
Iceweasel

Adjust 10 with the value that will leave you enough time to type your password, but keep in mind that using sleep for synchronisation purpose is very bad.

Then you can tell your system to start this script at login (don't forget to adjust permissions if necessary)

Finally, I advise you to use an Iceweasel plugin instead, as it is more suitable for this case. On the Keepass website, you can find more info about KeeForm and KeeFox (and many other plungins, but those ones seem to suit your needs) (I don't have rights to put enough links)

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .