Jonas Helgi Palsson wrote:
> 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

It looks like the source of the problem was this change in the code:

Revision 499764 - (view) (download) (as text) (annotate) - [select for
diffs]
Modified Wed Jan 18 16:49:04 2006 UTC (23 months, 3 weeks ago) by alund
File length: 10186 byte(s)
Diff to previous 498190

* Kate will export the PID of the instance in the environment variable
KATE_PID. You can use that to do some initialization in your ~/.bashrc
file for example, if you like to open files in kate from the built in
terminal:

# If we are running in a konsole in kate,
# $KATE_PID is the pid of that kate application instance.
if [ -n $KATE_PID ] ; then
  # open files in this instance
  alias kate="kate -u -p $KATE_PID"
  # allow creating a new instance
  alias kate_newinst="`which kate`"
fi

        The discussion continues and recognizes the difficulty in getting the
old behavior back.

Revision 495447 - (view) (download) (as text) (annotate) - [select for
diffs]
Modified Sun Jan 8 09:02:09 2006 UTC (2 years ago) by alund
File length: 9921 byte(s)
Diff to previous 465343

Always follow the configuration option for chosing a session  when none
is specified.
I commit this, since I can't see how else we can enable old style
behavior easily. The 'new' behavior can be achieved by keeping the
default configuration of starting a new session.
BUG: 119620


-- 
David C. Rankin, J.D., P.E.
Rankin Law Firm, PLLC
510 Ochiltree Street
Nacogdoches, Texas 75961
Telephone: (936) 715-9333
Facsimile: (936) 715-9339
www.rankinlawfirm.com
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to