Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Tricky KDE icon
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Help!
View previous topic :: View next topic  
Author Message
Lancer
LXF regular


Joined: Thu Apr 07, 2005 12:59 pm
Posts: 232

PostPosted: Sun May 01, 2005 7:20 pm    Post subject: Tricky KDE icon Reply with quote

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...

Code:
[Desktop Entry]
Comment=
Comment[en_GB]=
Encoding=UTF-8
Exec=echo; echo " You clicked me in directory..."; echo -n " "; pwd; echo;
GenericName=
GenericName[en_GB]=
Icon=emacs
MimeType=
Name=Where_am_I
Name[en_GB]=Where_am_I
Path=
StartupNotify=true
Terminal=true
TerminalOptions=--noframe --noscrollbar --notabbar --notoolbar --nomenubar --noresize --vt_sz 35x5 -T "You clicked me!" --noclose
Type=Application
Version=1.0
X-DCOP-ServiceType=none
X-KDE-SubstituteUID=false
X-KDE-Username=


The problem is, when clicked the icon always gives the users $HOME directory. Any idea on how to make it display the directory it resides in?

P.S. I'm using KDE launcher (as above) because for the other exercises I'm putting together (and the age of some of the students) it's important to have kid-friendly icons on the clickable scripts.
Back to top
View user's profile Send private message
Guest






PostPosted: Wed May 04, 2005 1:49 pm    Post subject: RE: Tricky KDE icon Reply with quote

Try creating a shell script, and providing a link to it.
Back to top
Lancer
LXF regular


Joined: Thu Apr 07, 2005 12:59 pm
Posts: 232

PostPosted: Fri May 06, 2005 11:53 am    Post subject: RE: Tricky KDE icon Reply with quote

Nope. That method does not work for I suspect the same reason.
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8457
Location: Warrington, UK

PostPosted: Fri May 06, 2005 12:39 pm    Post subject: RE: Tricky KDE icon Reply with quote

That reason being that you are always in the home directory when you run the script. What you need is the scripts directory, something like this

Code:
#!/bin/sh
echo "The current directory is $(dirname $0)"

_________________
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
Back to top
View user's profile Send private message
Lancer
LXF regular


Joined: Thu Apr 07, 2005 12:59 pm
Posts: 232

PostPosted: Sat May 07, 2005 2:12 am    Post subject: RE: Tricky KDE icon Reply with quote

Nearly there I think

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...

Code:
#!/bin/bash
xterm -geometry 50x3 -bg black -fg green +sb -T "You clicked me" -hold -e echo "I am in directory $(dirname $0)"


...this works Mr. Green 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?
Back to top
View user's profile Send private message
Lancer
LXF regular


Joined: Thu Apr 07, 2005 12:59 pm
Posts: 232

PostPosted: Sat May 07, 2005 2:32 am    Post subject: RE: Tricky KDE icon Reply with quote

Kool! Under Gnome, I can right click the icon to properties and then just choose custom icon for that one application Smile Now if only I could do the same in KDE...
Back to top
View user's profile Send private message
fdgdfgdf
Guest





PostPosted: Sun May 15, 2005 3:43 pm    Post subject: Re: RE: Tricky KDE icon Reply with quote

Back to top
skecs



Joined: Fri Apr 22, 2005 10:22 am
Posts: 76
Location: Bathurst, NSW Australia

PostPosted: Mon May 16, 2005 8:36 am    Post subject: RE: Re: RE: Tricky KDE icon Reply with quote

Lancer - you can in KDE.

Simply right-click on the desktop, choose "Create New => File =>Link to application" and browse to your shell script or whatever.

Complete the name, comments, description, etc. Select OK and your desktop link appears.

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.
_________________
Regards from
Downunder!
.... _
... (0)>
... / /\
.. / / .)
.. V_/_
Linux Powered!
Back to top
View user's profile Send private message
Lancer
LXF regular


Joined: Thu Apr 07, 2005 12:59 pm
Posts: 232

PostPosted: Mon May 16, 2005 10:49 am    Post subject: RE: Re: RE: Tricky KDE icon Reply with quote

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".
Back to top
View user's profile Send private message
jjmac
LXF regular


Joined: Fri Apr 08, 2005 2:32 am
Posts: 1996
Location: Sydney, Australia

PostPosted: Mon May 16, 2005 12:58 pm    Post subject: RE: Re: RE: Tricky KDE icon Reply with quote

Would using a perl script help. Or trying to do a 'cd' first, before the other cmds are executed ?


jm

Code:


 -:-  If the system is the answer, then the question
                   must have been really stupid                -:-

_________________
http://counter.li.org
#313537

The FVWM wm -=- www.fvwm.org -=-

Somebody stole my air guitar, It happened just the other day,
But it's ok, 'cause i've got a spare ...
Back to top
View user's profile Send private message
Guest






PostPosted: Mon May 16, 2005 7:20 pm    Post subject: RE: Re: RE: Tricky KDE icon Reply with quote

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.
Back to top
Lancer
LXF regular


Joined: Thu Apr 07, 2005 12:59 pm
Posts: 232

PostPosted: Mon May 16, 2005 7:28 pm    Post subject: RE: Re: RE: Tricky KDE icon Reply with quote

Last post was me. Rolling Eyes
(Sets mode to 'notify')
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8457
Location: Warrington, UK

PostPosted: Mon May 16, 2005 11:31 pm    Post subject: RE: Re: RE: Tricky KDE icon Reply with quote

I don't see how the language used would make any difference.
_________________
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
Back to top
View user's profile Send private message
jjmac
LXF regular


Joined: Fri Apr 08, 2005 2:32 am
Posts: 1996
Location: Sydney, Australia

PostPosted: Tue May 17, 2005 2:25 am    Post subject: RE: Re: RE: Tricky KDE icon Reply with quote

>>
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 Smile


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 ?!

I think thats basically what was hapening with your gnome test.

jm

Code:

  -:-  If the system is the answer, then the question
                     must have been really stupid              -:-
Back to top
View user's profile Send private message
jjmac
LXF regular


Joined: Fri Apr 08, 2005 2:32 am
Posts: 1996
Location: Sydney, Australia

PostPosted: Wed May 18, 2005 10:35 am    Post subject: RE: Re: RE: Tricky KDE icon Reply with quote

Just to clarify what i mean above.

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


Code:
#!/bin/bash
xterm -geometry 50x3 -bg black -fg green +sb -T "You clicked me" -hold -e echo "I am in directory $(dirname $0)"
[/code]

...this works but has the following disadvantage:
>>

It will still gives you the directory of the script.

A long way round solution ...

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 Smile, 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.

jm

Code:


 -|-  If the system is the answer, then the question
                  must have been really stupid                -|-
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Help! All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast