You are not logged in.

1

Wednesday, April 11th 2007, 7:12pm

Launching a script in the "current" directory in Konqueror

Where do I look for documentation on how to get a script launched when clicking on it in Konqueror?

If the script is in my home directory it launches and runs correctly when I click on it in Konqueror. If the script is in some other directory, it still runs in my home directory.

The script runs correctly if I open a terminal window, navigate to the directory and run it.

The script in question is used to convert images to smaller sizes in a batch. It looks for files with the extension .jpg, runs convert on them and stores the new, smaller image in a directory named for the smaller size. For the script to work when started by clicking on it in Konqueror, the destination directory and the original image files must all be in my home directory. The script itself can be in some other directory. What I'd like to happen is for the script to run in the directory in which it resides, and to operate on image files in that directory.

Thanks for any pointers.
Regards,
Moonguide

2

Wednesday, April 11th 2007, 9:36pm

you could try to keep the script in your home directory, and place .desktop-files pointing to that script in the directories you want it to run in.
in the .desktop file you can configure a working directory for the script.

You can create the .desktop file by right clicking on an empty space in the directory in konqueror, selecting [create new -> link to application]. At tab [Application] set the working path to the current directory and provide the command for the script to start.
Help mee om KDE 3.5.5 in het Nederlands te vertalen

3

Wednesday, April 11th 2007, 10:11pm

Many thanks. That was the missing piece of information I needed.

To summarize:

Create a shell script, such as MyShellScript.
In Konqueror, create a link to the shell script:
Right click on the empty space in the Konqueror "folder contents" pane and select
Create New > Link to Application...
Give the link an appropriate name such as "Link to MyShellScript"
At the Application tab of the Link Properties window find the line labeled Command:,
click "Browse" and, once you've browsed to it, select MyShellScript.
At the line labeled Work Path: click on the "Open file dialog" icon, make sure the dialog
has the correct directory highlighted, and click OK.
Finally, click OK on the Link Properties window.

As an additional feature, if you are having trouble debugging your shell script, you can
click on Advanced Options, check the boxes, "Run in terminal" and
"Do not close when command exits". You'll get to see what's actually happening
under the hood.
Regards,
Moonguide

sonota

Beginner

Posts: 1

Location: Japan

  • Send private message

4

Wednesday, June 20th 2007, 7:31pm

how about adding this in the first line of the script?

cd `dirname $0`