Musik




Creating a Konqueror Service menu PDF Print E-mail
Sunday, 25 March 2007

Creating a "mount iso/unmount iso" Konqueror Service menu. This is just as short tutorial on creating a service menu that is a bit more complicated than issuing a "Unzip here" or "Mail this in Kmail" menu item. Testing on Kubuntu 6.10 Edgy and 7.04 Feisty, but should work on most newer Linux distros.

Konqueror service menus allow added functionality by executing commands. It's really pretty simple. You create a file with a .desktop extension in one of two places:

/home/<username>/.kde/share/apps/konqueror/servicemenus

or

/usr/share/apps/konqueror/servicemenus

Placing the service menu file in the first choice gives all users the menu item and the second will only be available to you. 

No programming unless you need something really crazy, just the execution of commands and programs to make your file exploring in Konqueror more productive and personalized.

Our new service menu will be create a directory in ~/Desktop and mount an ISO disk image to that directory from Konqueror. Let's get to it!

Open a text editor, I use kate, and enter the following:

[Desktop Entry]
Actions=MountISO;UnmountISO
Encoding=UTF-8
ServiceTypes=application/x-iso,inode/ISO-image

[Desktop Action MountISO]
Name=Mount ISO
Icon=hdd_mount
Exec=mkdir $HOME/Desktop/iso; kdesu -c "mount -o loop %u $HOME/Desktop/iso"

[Desktop Action UnmountISO]
Name=Unmount ISO
Icon=hdd_unmount
Exec=kdesu -c umount $HOME/Desktop/iso; rmdir $HOME/Desktop/iso 

Save this file in:
/home/<your_user_name>/.kde/share/apps/konqueror/servicemenus/ as mountiso.desktop

Now open Konqueror and right click an ISO file then select Actions, Mount ISO. The mounted ISO should appear on the desktop. To remove right click the ISO again and select Unmount ISO and it will be removed.

The variables used: 

$HOME is your home path /home/<username>  you cannot use ~/

%u is the file and path of the file you selected.

%u will return the full path and filename or url and filename.

%f will return  the full path and filename.

for multiple file selections make either capitalized; %U, %F.

Actions are the items we want to execute, multiple actions must be separated by a simicolon and cannot contain spaces. 

Each Exec has two commands, one a simple make and remove directory command and the second a mount and unmount command with kdesu. kdesu is how we get the authentication command to ask for the root password in order to mount. Notice multiple commands on one line are separated by a simicolon, that is important! You will also noticed that you can have many menu actions added in one file. If you have problems with commands containing options, like is the case with mount try wrapping the command in double quotes. This was necessary for the mount command as the mount arguments, -o loop, as kdesu was getting confused.

 Service types can be set to basically filter the file types. For instance, if you wanted all files and directories to have access to your action menu you would use all/all. We only want our service menu available for .iso files.

For further reading take a look at this tutorial by Aaron J. Seigo .  He also goes into dcop. I figure between these two tutorials you should be well on your way to making your own custom service menus. I could go further into detail, but I don't need to reinvent the wheel...

 

 
< Prev
Content ©Copyright 2006-2008 Dark Artistry. Hosting by Dreamhost

download joomla cms download joomla cms