Re: [opensuse] kde and the kate editor



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@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx



Relevant Pages

  • Re: [opensuse] kde and the kate editor
    ... So I get 30 kate windows on my desktop when all I want is one. ... Keep track of which Kate process is on which virtual desktop ... # We need to see if there is a pid file for that desktop ... Then make a new action in Konqueror to open files, ...
    (SuSE)
  • Re: [kde-linux] Encoding questions (Chusslove Illich)
    ... The encoding for the merriam-webster page seems to be ... Switching to utf-8 ... when I copy and paste stuff like that into kate ... displayed properly in konqueror, maybe when I get ...
    (KDE)
  • Re: Anyway to by-pass file assoc. in Kong browser
    ... Computers are very stupid indeed. ... Kate than to right-click and choose "open with" and then make a selection ... You just reduce your file associations list to only Konqueror and Kate. ... I just open one or several HTML files with a right click and I just drag and drop the next ones in Kate's window. ...
    (comp.windows.x.kde)
  • File types
    ... The plain text document is one I wrote, using Kate. ... but I was wondering why they are different file types. ... to be able to view them in Konqueror when I click on them, ... the unknown and diff files and pasting them into a newly created ...
    (alt.os.linux.suse)
  • Re: different konqueror settings per file type
    ... I would like to save different konqueror view settings for different ... How can I do this in konqueror? ... Kate - KDE Advanced Text Editor ...
    (comp.windows.x.kde)