Creating Custom Service Menus in Konqueror

Written by BinnyVA on October 7, 2008 – 12:23 am -

If you are using Konqueror and have not used custom service menus, you are missing out. Just like the Nautilus Scripts in Nautilus, Konqueror also has the ability to customize the context menus. This post will show you how to do it.

We are going to create two different kind of service menus – one will create an item in the action part of the right click menu. The next type will create a submenu in the ‘actions’ menu with multiple menu items. Hopefully, you will get an idea about how to do it by yourself.

Single Item Service Menu

This service menu will create a menu item in the Action section of the context menu for all ISO files. For this to work as intended, the mimetype for ISO file must be application/x-iso .

  • Open ~/.kde/share/apps/konqueror/servicemenus folder
  • Create a file with the name ‘PlayISO.desktop’ – the name can be anything – but the extension must be ‘.desktop’
  • Enter the following content…
[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

Now lets see a line by line explanation of the code.

[Desktop Entry]
Start the file with this line.
ServiceTypes=application/x-iso
This decides which all file types must this service menu be shown to. You can find the mimetype for various files by taking Control Center > KDE Components > File Associations. Then search for the extension in the given text field.
Actions=PlayISOInXine
Name of the action – this will be defined in the next line
[Desktop Action PlayISOInXine]
The definition of the ‘PlayISOInXine’ action goes here.
Name=Play ISO File in Xine
The text to be shown in the menu item.
Icon=player_play
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 ‘/usr/share/icons/crystalsvg/16×16/actions’).
Exec=xine -pq –no-splash dvd:/%f
The command to be executed when the menu item is clicked. The %f stands for the full name of the file. The other options are listed in the documentation.

This is the end result…

Submenu Service Menu

This sample will give you the option to convert the selected html file to a plain text file or a compressed archive. The code looks like this…

[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"

Again, a line by line explanation…

[Desktop Entry]
You know.
ServiceTypes=text/html
This is only for HTML files – so we specify the mimetype as text/html
Actions=convertToText;convertToZip
We have two different actions instead of just one as in the last case. So we provide the name of both actions separated by a ‘;’.
X-KDE-Submenu=Convert
This will make sure its shown in a submenu – and that the name of the submenu is Convert.
[Desktop Action convertToText]
Defining the first action – convertToText
Name=Convert To Text
The label of the menu item
Icon=txt
And its icon
Exec=lynx -dump “%f” > “`dirname “%f”`/`basename “%f” “.html”`.txt”
This command will convert a html file to a text file and put the resulting file in the same folder as the html file.
[Desktop Action convertToZip]
Defining the next action – convertToZip
Name=Compress as Zip
Label
Icon=tar
And Icon
Exec=zip “`dirname “%f”`/`basename “%f” “.html”`.zip” “%f”
The command to compress the html file as a zip file.

If done correctly, it should look something like this…

Related Links


Tags: , , , , , ,
Posted in Applications, Configuration, KDE | 2 Comments »

Sharing Files Between Computers on a Local Network Using Linux

Written by BinnyVA on July 26, 2008 – 10:47 pm -

Windows has a nice feature in Networking – you just configure the IPs correctly, and the network sharing “magically” works. In Linux we will have to manually configure Samba or some other similar tool to share files between two linux systems – and that’s a bit daunting for a new user. But there is an easier way – using SSH.

SSH or Secure Shell is a program for logging into a remote machine and executing commands on a that machine. Don’t worry – you won’t have to type commands to transfer files – there are GUI clients that supports SSH protocol – for example, the great Konqueror.

SSH is installed and turned on in most distros – so chances are you are running an SSH server at the moment. But if its not installed by default, you can install it using these commands…

In Fedora/Red Hat

yum install openssh

In Ubuntu/Debian

apt-get install openssh

After installing it, you have to activate it in the Services configuration utility. Once that is done, SSH will turned on at boot. Make sure the remote machine have SSH installed and running before trying to connect to it.

An Example Implementation

I use SSH to transfer files between my system and my brothers system. This will give you an overview of the network…

Home Network

Both the systems have SSH enabled. Now if I want to get some files from my brother’s system, all I have to do is open Konqueror and enter this address in the Address bar: fish://username@192.168.1.20

That is fish://[Remote User]@[Remote Machine’s IP/Name].

This will show a password prompt – where you have to input the password of the remote user. Once that is done, you will see all the files in the remote machine that is accessable by the user you logged in as. All operation you are used to in Konqueror are still supported – Copy/Paste, Drag and Drop etc – they will work between the local system and the remote machine.

If you are a Gnome user, this is possible in Nautilus as well. Instead of fish://username@192.168.1.20 , you have to enter ssh://username@192.168.1.20 in the address bar – protocol is ssh:// instead of fish://.

Limitations

Keep in mind that this is practical only for small home networks. If you are implementing a large network with permission settings, shares and stuff, go with Samba. SSH is not a choice there.


Tags: , , , , , ,
Posted in KDE, Networking, Tools | 4 Comments »