[kde-linux] Working directory for Konqueror "Open with...." set to home

Kevin Krammer kevin.krammer at gmx.at
Mon Oct 9 10:36:16 UTC 2006


On Friday 06 October 2006 21:27, Matt Seitz wrote:
> If I right click a file and select "Open with....", and check the "Run in
> terminal" and "Do not close..." checkboxes, the working directory appears
> to be set to my home directory, rather than the directory containing the
> file I selected.  For example, if I right click a file, select "Open
> with...", and enter the command "pwd;ls", I get the following output:

Having the home directory as the default working directory seems to be some 
kind of usual behaviour. Maybe because using a common user owned directory as 
the working directory ensures that programs can write there.

If you need to start a program that cannot change the working directory on its 
own and want it to always use the directory your file is in, you can do a 
wrapper script with something like this

#!/bin/bash
cd $(dirname $1)
application %1

Where $1 is the first parameter to the script, assuming the file is passed as 
the first parameters

Another option is to have the directory passed to the program, for example in 
case of unzip using the -d option.

The command called from Konqueror (or actually any other filemanager) 
understands format parameters like %f for file and %d for directory, see [1]

Entries of the main menu, which can be directly added as file associations, 
are decsribed that way, i.e. being specified by a file following the .desktop 
file specification.
An easy way to create one of those it o use the "New->create link to program" 
option from the desktop's context menu.

Cheers,
Kevin

[1] http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html

-- 
Kevin Krammer <kevin.krammer at gmx.at>
Qt/KDE Developer, Debian User
Moderator: www.mrunix.de (German), www.qtcentre.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-linux/attachments/20061009/eec645c4/attachment.sig>


More information about the kde-linux mailing list