How to create a menu item and tell the program to start in a specific directory?

Asked by Uqbar

I'm running Ubuntu 8.10.
I've installed a software which has no menu item. So I created one.
I'd need it to start and use as current working directory at least my home dir and not /usr/local/bin (or whatever it thinks is its cwd).
How can I do that?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Arnaud Soyez
Solved:
Last query:
Last reply:
Revision history for this message
Arnaud Soyez (weboide) said :
#1

Edit your menu item and change the command to (for example with gnome-terminal):

cd /the/path/you/want && gnome-terminal

Revision history for this message
Uqbar (uqbar) said :
#2

Trivially not working.

Could not launch menu item
Failed to execute child process "cd" (No such file or directory)

Revision history for this message
Pierre Ferrari (piferrari) said :
#3

Hi Uqbar,

What is the program you want to launch? Maybe he have parameters.
For example for gnome-terminal if you type «gnome-terminal --help» in an shell

$gnome-terminal --help
...
 --working-directory=DIRNAME
...

Then, in your menu item, write the command

gnome-terminal --working-directory=/path/to/your/dir

Regards

Revision history for this message
enzo (vincenzo-romano-notorand) said :
#4

I've checked and none of the programs has a "cwd" command line argument.
I can hardly believe that such a feature is missing, but the documentation I've seen so far doesn't show it.

Revision history for this message
Uqbar (uqbar) said :
#5

I confirm this: very few programs have an option much like the gnome-terminal's.
And now what?
How are you guys coping with such a need?

Revision history for this message
Best Arnaud Soyez (weboide) said :
#6

This works for me, you can replace gnome-terminal with your app:

bash -c "cd /tmp && (gnome-terminal &)"

Revision history for this message
Uqbar (uqbar) said :
#7

This last answer seems "dirt and tricky" but it works for me too.

Revision history for this message
Uqbar (uqbar) said :
#8

Thanks Arnaud Soyez (Weboide), that solved my question.

Revision history for this message
Arnaud Soyez (weboide) said :
#9

This is still a clean way to do this because "cd /tmp" only works with bash, so you need to start bash to execute it.