Hi On Tuesday 08 January 2008 19:45:05 Wendell Nichols wrote:
Kate drives me nuts. Its a good editor but every time you right click to edit a file in konqueror using kate it starts a new window. If I use a command window and specify --use it will "reuse" an existing window if one is started for the session I specify. However because kdeinit starts it I cannot pass a parm through konqueror. So I get 30 kate windows on my desktop when all I want is one. Ideally I'd like kate to open the file I've chosen in the instance of kate which is already open ON THAT DESKTOP.
Has anyone figured this out? Sorry if this is an inappropriate forum... well not all that sorry.... wcn
Now the simple answer is (of course) DCOP! But how to make it work was not so easy :-) What you need to do is 1. Keep track of which virtual desktop you are on 2. Keep track of which Kate process is on which virtual desktop 3. Use DCOP to instruct (the correct) Kate to open the selected file. Here is a way to do it (with some quick'n'ugly scripts): First make a directory to keep some tempfiles mkdir ~/.kate_pid then we make 2 bash scripts, put them in your ~/bin/ or where ever you fancy. 1: start_kate.sh --------------------<cut here>--------------------------- #!/bin/bash # Get current virtual desktop VIRT_DESKTOP=$(dcop kwin KWinInterface currentDesktop) #Now we start kate with all the arguments that we recived kate $@& echo -n $! > ~/.kate_pid/kate_pid.$VIRT_DESKTOP exit 0; --------------------<cut here>--------------------------- 2: kate_open_file.sh --------------------<cut here>--------------------------- #!/bin/bash # The encoding used, utf8 is the usual one ENCODING=utf8 # We need to find out which virtual destop we are on VIRT_DESKTOP=$(dcop kwin KWinInterface currentDesktop) # We need to see if there is a pid file for that desktop if [ -f ~/.kate_pid/kate_pid.$VIRT_DESKTOP ] ; then #Yes there was, now we need to check if the kate process #belonging to that pid is still alive #First find the pid KATE_PID=$(cat ~/.kate_pid/kate_pid.$VIRT_DESKTOP) if [ $(dcop kate-$KATE_PID >/dev/null 2>&1; echo $?) -gt 0 ] ; then #No it is not, so we start it kate $@& # and record the pid for reuse echo -n $! > ~/.kate_pid/kate_pid.$VIRT_DESKTOP else # now some DCOP magic dcop kate-$KATE_PID KateApplication openURL $1 $ENCODING fi else #there was no kate_pid file so we start kate. kate $@& # and record the pid for reuse echo -n $! > ~/.kate_pid/kate_pid.$VIRT_DESKTOP fi --------------------<cut here>--------------------------- Use the start_kate.sh wrapper to start Kate on a virtual desktop. (Not really needed) Then make a new action in Konqueror to open files, and have it run: /the/path/to/the/script/kate_open_file.sh %U That should do it :-) Notice that there is no error checking at all in the scripts, so if you use it, please make it better and post the result :-) regards Jonas -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org