LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-17-2005, 12:07 AM   #1
Zelator
Member
 
Registered: Jul 2005
Location: Melbourne Australia
Distribution: Netrunner
Posts: 75

Rep: Reputation: 17
Kate KDE Scripts - how to make them work


I need a wordcount in Kate on my newly-installed Kubuntu, and I found one at wiki.kate-editor.org. It consists of two files in .kde/share/apps/kate/scripts:

wordcount.desktop

[Desktop Entry]
Comment=Word Count
Encoding=UTF-8
Icon=
Name=Word Count
Type=ShellScript/bash
X-KDE-ScriptName=wordcount.sh

and

wordcount.sh
which I have made executable

#!/bin/bash
case "$1" in kate*) ;;
*) echo "Please call me from Kate" > &2 exit 1;;
esac
doc=`dcop $1 KateDocumentManager activeDocumentNumber`
dcop $1 editinterface#$doc text | wc | { \
read lines words chars kdialog -- title "Word Count" \
--msgbox "<qt><table> <tr><td>Total Lines:</td>
<td align=right><b>$lines</b></td></tr>
<tr><td>Total Words:</td><td
align=right><b>$words</b></td></tr>
<tr><td>Total Chars:</td><td
align=right><b>$chars</b></td></tr>
</table></qt>"
}

Kate evidently finds the wordcount.desktop, as the KDE scripts list on the Tools menu shows whatever I put in the Name field, but if I click it I get:

unable to find script "&Word Count"

As the other entries in the KDE scripts list do the same thing I assume either there is a config problem or the function is broken. The manual is no help at all. Anyone out there know how to fix this? I tried giving the full path for wordcount.sh but still nothing.
 
Old 11-22-2005, 09:44 PM   #2
Zelator
Member
 
Registered: Jul 2005
Location: Melbourne Australia
Distribution: Netrunner
Posts: 75

Original Poster
Rep: Reputation: 17
Doesn't work on Fedora Core 4 KDE either.
 
Old 11-24-2005, 08:11 PM   #3
Zelator
Member
 
Registered: Jul 2005
Location: Melbourne Australia
Distribution: Netrunner
Posts: 75

Original Poster
Rep: Reputation: 17
Thumbs up Kate scripts - word count

However, I went to the Kate project page and voted for a wordcount on the wishlist, and this, which works for me on FC4 KDE (I have given up on Kubuntu as it will not work with my DVD burner), was posted in reply:

QUOTE]
Meanwhile, kates 'external tools' feature provides you with a easy way to do this. Here is a very simple implementation, note though that this does not work with non-local files, and that it saves the document if it has changes. The next version (3.0) of kate will allow to pipe text into commands used for external tools. But adding the following to $KDEHOME/share/apps/kate/externaltools would provide you with a command "Tools->External tools->Word count" that will work with local files:�

[externaltool_Wordcount]
acname=externaltool_Wordcount
cmdname=
command=url=`echo %URL|sed -r 's,^\\w+\\:/+,/,'`\nkdialog --msgbox "Word count for\\n%URL:\\n$(wc -lwm $url|sed -r 's,\\s*(\\w+)\\s+(\\w+)\\s+(\\w+).*,Lines: \\1\\nWords: \\2\\nCharacters: \\3,')"
executable=wc
icon=
mimetypes=
name=Word count
save=1
[/QUOTE]

echo $KDEHOME came up with nothing, but I found externaltools in /usr/share/apps/kate or ~/.kde/share/apps/kate

Be sure to add ", externaltool_Wordcount" to the global list at the top.
Note you can also add a shortcut for it, I used Shift+F12 which seems to work.
 
Old 10-22-2009, 06:19 PM   #4
Zelator
Member
 
Registered: Jul 2005
Location: Melbourne Australia
Distribution: Netrunner
Posts: 75

Original Poster
Rep: Reputation: 17
Newer, simpler

I am now using this version, found on the Debian bug report

------- Additional Comment #13 From Dominik Haumann 2006-09-16 23:20 -------

external tool word count script

Step by step howto for Kate Application:
- Settings > Configure Kate...
- 'External Tools' page
- Create new external tool
Label: Word Count
Script: copy&paste 3 lines:

url=`echo "%URL"|sed -r 's,^\w+\:/+,/,'`
count=`wc -lwm "$url"`
kdialog --msgbox "Word count for\n%URL:\n$(echo $count|sed -r 's,\s*(\w+)\s+(\w+)\s+(\w+).*,Linebreaks: \1\nWords: \2\nCharacters: \3,')"

Executable: wc
Mime Types: leave blank
Save: Current Document
Command Line Name: leave blank or type 'word-count'
- Save & Apply

Use: Tools > External Tools > Word Count

----------------------------------------------
The file still gets saved.

Control key set through Settings > Configure Shortcuts - I used Alt + `
 
  


Reply

Tags
kate


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
KDE Kate - how to use project management feature? ToBe Linux - Software 1 08-09-2005 01:56 PM
kate complaining about KAccel missing (KDE 3.2) Siemen Mandriva 1 02-21-2005 08:43 PM
Kate Is Not Working, Kate editor is not starting in Redhat 9 apur Linux - General 4 05-11-2004 09:52 AM
Plugins for KDE- Kwrite Kate etc saurya_s Linux - Software 0 04-19-2004 03:50 PM
install kwrite/kate without kde wm? matthewchng Linux - Software 2 02-25-2004 03:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration