I'm wanting to make a launcher / icon for KDE which will help me in teaching Linux to school children. Basically, wherever the icon is placed, when clicked on in Konqueror, it should launch a terminal saying the directory it is in. Opening the icon with a text editor gives the following...

Linking to the script has the problem of echo "The current directory is $(dirname $0)" returning the directory of the original script... not the desktop shortcut / KDE icon location I want. What this means is that students cannot move the KDE icon around into different directories, click it and have it report "I am now in <whereever they moved the icon>".

I tried embedding the $(dirname $0) function into the KDE destop icon itself like so...
Exec=echo " You clicked me in directory..."; echo " $(dirname $0)";...but that only returns "."

I guess another way would be to actually move a shell script around which itself opens a terminal like so...

...this works but has the following disadvantage: There seems to be no way of changing the icon to a custom one without affecting all other occurances of *.sh type files. For classroom exercises I want to have a range of icons which do different things (open xterm with different messages), and each should look different. This is why I had been trying to do use a KDE desktop icon for the job. Is there a work around?

Right click (or do this before selecting OK) and on the General tab you'll see the curent icon or shortcut, simply click on this and you will have a number of standard icons available or browse and choose your own. This only affects the current link.

Ah.... but you miss the whole point. If I do it that way, the address in the shell script does not return the address location of the shortcut icon, but only that of where the original shell script is located. I want to make an icon which can be dragged from dir to dir and when clicked on launches an alert or shell reading "I am in xxx directory".

Perl is not something I'm proficient in. If you can get any script to work, please show me.

If you could 'cd' to a location, then surely you would be able to echo/printf that location as well.

The trick here is in transfering the location of the icon itself into the script. I can get it to work in Gnome by setting an individual icon to the shell script which launches the an xterm (the script was the last one I showed). However, this will not work under KDE, as there appears to be no sensible way of assigning a custom icon to an individual script. Once you make a shortcut/link to a script, no one seems to know of a useable variable which would give the location of the original shortcut/link icon.

>>
The trick here is in transfering the location of the icon itself into the script. I can get it to work in Gnome by setting an individual icon to the shell script which launches the an xterm (the script was the last one I showed). However, this will not work under KDE, as there appears to be no sensible way of assigning a custom icon to an individual script
>>

Yes, i can see what you mean... Perl being what it is, i just though it may well have some magic along those lines hidden away somewhere.

Tricky. But then,... is it really a good idea to have icons following you around your fs to easily. What if your in a sensitive area, then so will it, opening up potential problems. Especially if for some bug, it decided to stay there..

Maybe a seperate menu branch in the filemanager might be more practical

Maybe ... if you could get the filemanager to write to a file in your $HOME directory, reflecting directory changes. Then ... if the icon can source that file first, then do a cd based on the path string found there ... By sourcing, i mean, using the "Exec=' config option in the above file example.

... but as you say, show an example, hmmm. Some ideas at least

Appended:

After a few tests ...

I could get it to invoke an rxvt window, but if i tryed to get it to do more, such as with the '-e' switch, or using '&&', even trying to pipe 'ls' to 'rxvt' (grin), all that happened was that the shell would flash open .. then close.

I think it boils down to the icon belonging to the original session shell that the wm itself is bound to. Rather than being a child of that.

If it could be made to have it's own shell when it is created ... then there might be a chance to move it about ?!

Grep through the file managers source and look for the function that retrives the current directory, as reflected in the file managers window.

What ever variable is used there ... use it to write that path to a file in your own HOME directory. Overwriting it each time.
Then, have the script retrieve the saved string contained in it.

Recompile the manager with an altered name, so as the extra burden of continuously writing to the file wont hold you down for ordinary usage.

I know ... greping through source can be a pain, but ... is there really another way to overcome the problem of the icon and the script being in a different working directories as to the file managers navigation.

I must be missing your point somewhere though, as part of your original comment ...

>>
Basically, wherever the icon is placed, when clicked on in Konqueror, it should launch a terminal saying the directory it is in
>>

i find a bit confusing ...

How can you get a desktop icon to follow a filemanager/browsers tree navigation. ???

How do you get the root window in a file manager. Can kde really do that (grin) wow ...

sorry if i've been wasting your time there , it just seemed alike a really interesting delima, from my interpretation ... which may well be missing your point. As i get the felling that your suggesting that the icon should change directories as you do. Doesn't solve the script being where ever it is ... but i cant see how the icon could travel about. Unless its the directory icon ... hmmm, i guess that must be what you mean there.