<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lindesk &#187; service</title>
	<atom:link href="http://lindesk.com/tag/service/feed/" rel="self" type="application/rss+xml" />
	<link>http://lindesk.com</link>
	<description>Linux - on the Desktop</description>
	<lastBuildDate>Tue, 23 Jun 2009 14:03:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating Custom Service Menus in Konqueror</title>
		<link>http://lindesk.com/2008/10/action-context-custom-service-menus-konqueror/</link>
		<comments>http://lindesk.com/2008/10/action-context-custom-service-menus-konqueror/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 18:53:37 +0000</pubDate>
		<dc:creator>BinnyVA</dc:creator>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[KDE]]></category>
		<category><![CDATA[action]]></category>
		<category><![CDATA[context]]></category>
		<category><![CDATA[desktop]]></category>
		<category><![CDATA[konquoror]]></category>
		<category><![CDATA[menu]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[service]]></category>

		<guid isPermaLink="false">http://lindesk.com/?p=140</guid>
		<description><![CDATA[f you are using <a href="http://lindesk.com/2007/04/konqueror-a-killer-app-for-linux/">Konqueror</a> and have not used custom service menus, you are missing out. Just like the <a href="http://lindesk.com/2007/04/nautilus-scripts-terminal-file-finder/">Nautilus Scripts</a> in Nautilus, <strong>Konqueror also has the ability to customize the context menus</strong>. This post will show you how to do it]]></description>
			<content:encoded><![CDATA[<p><img src="http://lindesk.com/wp-content/uploads/2007/04/konqueror.png" alt="" title="Konqueror Logo" width="170" height="168" class="alignnone size-full wp-image-21 intro" align="right" /></p>
<p class="intro">If you are using <a href="http://lindesk.com/2007/04/konqueror-a-killer-app-for-linux/">Konqueror</a> and have not used custom service menus, you are missing out. Just like the <a href="http://lindesk.com/2007/04/nautilus-scripts-terminal-file-finder/">Nautilus Scripts</a> in Nautilus, <strong class="highlight">Konqueror also has the ability to customize the context menus</strong>. This post will show you how to do it.</p>
<p>We are going to create two different kind of service menus &#8211; one will create an item in the action part of the right click menu. The next type will create a submenu in the &#8216;actions&#8217; menu with multiple menu items. Hopefully, you will get an idea about how to do it by yourself.</p>
<h2>Single Item Service Menu</h2>
<p>This service menu will <strong class="highlight">create a menu item in the Action section of the context menu for all ISO files</strong>. For this to work as intended, the mimetype for ISO file must be application/x-iso .</p>
<ul>
<li><strong class="highlight">Open ~/.kde/share/apps/konqueror/servicemenus folder</strong></li>
<li><strong class="highlight">Create a file with the name &#8216;PlayISO.desktop&#8217;</strong> &#8211; the name can be anything &#8211; but the <strong class="highlight">extension must be &#8216;.desktop&#8217;</strong></li>
<li>Enter the following content&#8230;</li>
</ul>
<pre><code class="desktop">[Desktop Entry]
ServiceTypes=application/x-iso
Actions=PlayISOInXine

[Desktop Action PlayISOInXine]
Name=Play ISO File in Xine
Icon=player_play
Exec=xine -pq --no-splash dvd:/%f
</code></pre>
<p>Now lets see a line by line explanation of the code.</p>
<dl>
<dt>[Desktop Entry]</dt>
<dd>Start the file with this line.</dd>
<dt>ServiceTypes=application/x-iso</dt>
<dd>This <strong class="highlight">decides which all file types must this service menu be shown</strong> to. You can find the mimetype for various files by taking Control Center &gt; KDE Components &gt; File Associations. Then search for the extension in the given text field.</dd>
<dt>Actions=PlayISOInXine</dt>
<dd>Name of the action &#8211; this will be defined in the next line</dd>
<dt>[Desktop Action PlayISOInXine]</dt>
<dd>The definition of the &#8216;PlayISOInXine&#8217; action goes here.</dd>
<dt>Name=Play ISO File in Xine</dt>
<dd>The text to be shown in the menu item.</dd>
<dt>Icon=player_play</dt>
<dd>The icon to be used in the menu. The icon can be an absolute path or the file name of an image in your current theme(for example, if you are using Crystal SVG theme, then the images you can use is in the folder &#8216;/usr/share/icons/crystalsvg/16&#215;16/actions&#8217;).</dd>
<dt>Exec=xine -pq &#8211;no-splash dvd:/%f</dt>
<dd>The <strong class="highlight">command to be executed when the menu item is clicked</strong>. The %f stands for the full name of the file. The other options are listed in the <a href="http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html">documentation</a>.</dd>
</dl>
<p>This is the end result&#8230;</p>
<p><img src="http://lindesk.com/wp-content/uploads/2008/10/iso_menu.png" alt="" title="ISO Action Menu Result" width="456" height="124" class="alignnone size-full wp-image-142" /></p>
<h3>Submenu Service Menu</h3>
<p>This sample will give you the option to <strong class="highlight">convert the selected html file to a plain text file or a compressed archive</strong>. The code looks like this&#8230;</p>
<pre><code class="desktop">[Desktop Entry]
ServiceTypes=text/html
Actions=convertToText;convertToZip
X-KDE-Submenu=Convert

[Desktop Action convertToText]
Name=Convert To Text
Icon=txt
Exec=lynx -dump "%f" > "`dirname "%f"`/`basename "%f" ".html"`.txt"

[Desktop Action convertToZip]
Name=Compress as Zip
Icon=tar
Exec=zip "`dirname "%f"`/`basename "%f" ".html"`.zip" "%f"
</code></pre>
<p>Again, a line by line explanation&#8230;</p>
<dl>
<dt>[Desktop Entry]</dt>
<dd>You know.</dd>
<dt>ServiceTypes=text/html</dt>
<dd>This is only for HTML files &#8211; so we specify the mimetype as text/html</dd>
<dt>Actions=convertToText;convertToZip</dt>
<dd>We have <strong class="highlight">two different actions</strong> instead of just one as in the last case. So we provide the name of both actions separated by a &#8216;;&#8217;.</dd>
<dt>X-KDE-Submenu=Convert</dt>
<dd>This will <strong class="highlight">make sure its shown in a submenu</strong> &#8211; and that the name of the submenu is Convert.</dd>
<dt>[Desktop Action convertToText]</dt>
<dd>Defining the first action &#8211; convertToText</dd>
<dt>Name=Convert To Text</dt>
<dd>The label of the menu item</dd>
<dt>Icon=txt</dt>
<dd>And its icon</dd>
<dt>Exec=lynx -dump &#8220;%f&#8221; &gt; &#8220;`dirname &#8220;%f&#8221;`/`basename &#8220;%f&#8221; &#8220;.html&#8221;`.txt&#8221;</dt>
<dd>This command will convert a html file to a text file and put the resulting file in the same folder as the html file.</dd>
<dt>[Desktop Action convertToZip]</dt>
<dd>Defining the next action &#8211; convertToZip</dd>
<dt>Name=Compress as Zip</dt>
<dd>Label</dd>
<dt>Icon=tar</dt>
<dd>And Icon</dd>
<dt>Exec=zip &#8220;`dirname &#8220;%f&#8221;`/`basename &#8220;%f&#8221; &#8220;.html&#8221;`.zip&#8221; &#8220;%f&#8221;</dt>
<dd>The command to compress the html file as a zip file.</dd>
</dl>
<p>If done correctly, it should look something like this&#8230;</p>
<p><img src="http://lindesk.com/wp-content/uploads/2008/10/html_menu.png" alt="" title="HTML Service Menu Result"  class="alignnone wp-image-141" /></p>
<h2>Related Links</h2>
<ul>
<li><a href="http://standards.freedesktop.org/desktop-entry-spec/latest/index.html">Desktop File Documentation</a></li>
<li><a href="http://www.linux.com/feature/148002">Do-it-yourself Konqueror commands</a></li>
<li><a href="http://www.kde-apps.org/?xcontentmode=287">Collection of Service Menu Scripts</a></li>
<li><a href="http://www.kde-apps.org/content/show.php/Service+Menu+Editor?content=85062">GUI Service Menu Editor</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://lindesk.com/2008/10/action-context-custom-service-menus-konqueror/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
