Dot Series: Creating Konqueror Service Menus
Wednesday, 24 July 2002 | Aseigo
The ability to select mimetype-specific actions from Konqueror's context menu is an oft-requested feature. The pleasant surprise is that this is already possible. The even more pleasant surprise is that you don't need to be a software developer to do it. This article, the fourth in the dot tutorial series, details step-by-step how to quickly and easily add new actions to Konqueror's context menu.
Comments:
Almost off topic - Evan "JabberWokky" E. - 2002-07-23
The fact that you dressed your two year old son up as a penguin for halloween almost scares me. :) Great article. I used it to enhance that project I was asking questions about in irc. -- Evan
Re: Almost off topic - Aaron J. Seigo - 2002-07-23
but he's so damn cute as a penguin! i'm hoping that suit will fit him again this year, though i'm doubtful. hrm.. time to start thinking of something equally strange for this October ....... as for the article, i've added two tips to it in response to emails i've received: one for how to make a servicemenu appear for directories (inode/directory as the mimetype) and what to do when you have multiple commands to run (exec a shell! Exec=/bin/sh -c "whatever; whatever && whatever") these additions should be reflected in the online article shortly...
Re: Almost off topic - Richard Moore - 2002-07-23
It might be worth adding a note about using the UIServer dcop interface to display dialogs too. Rich.
Re: Almost off topic - Aaron J. Seigo - 2002-07-24
well, then it starts becoming a tutorial on scripting KDE using dcop rather than a tutorial on making servicemenus. i dipped very briefly into kdcop only to demystify how i got the Exec line in the example. a general "how to script kde" would make for a great tutorial, though. the topic is large enough to deffinitely warrant its own coverage. i polled people on irc the other evening for tutorial topics that they would like to see, and dcop scripitng was the first one they asked for nearly every time. =) maybe next month.....
Re: Almost off topic - Richard Moore - 2002-07-25
I guess you mean something like the one Olaf Zanger wrote see http://dot.kde.org/1001577974/ ;-) Rich.
Re: Almost off topic - Aaron J. Seigo - 2002-07-25
sort of. but a little less terse, a little more end-user oriented and updated to reflect the newer capabilities of the dcop command line app as well as the newer ones (e.g. dcopfind, dcopref) ... maybe some screenshots of kdcop in action, walking through writing a script step by step ... olaf's paper is great, its just not very accessable to end users and it's a little dated.
Re: Almost off topic - ac - 2002-07-24
That sounds bloody brilliant. Why don't more people know about this? I tried this and it worked perfectly! dcop kio_uiserver UIServer messageBox 1 1 "KDE Rules!" "Cool" "yes" "yes!" I don't know why this one doesn't work: dcop kio_uiserver UIServer infoMessage 1 "KDE Rules"
Re: Almost off topic - ineiti - 2002-07-24
# dcop kio_uiserver UIServer infoMessage 1 "KDE Rules" Not enough arguments. 'nough said...
Re: Almost off topic - Aaron J. Seigo - 2002-07-24
> dcop kio_uiserver UIServer infoMessage 1 "KDE Rules" you need a running job to show the message in its progress dialog for this to work AFAIK.
Re: Almost off topic - tuncer - 2005-03-29
danke
Re: Almost off topic - Chuckie Schumer - 2002-08-08
My first thought was "Execute with arguments..." but I can't figure out how to handle the dialogs through DCOP. I would love to see a dcop tutorial.
Re: Almost off topic - Mario - 2002-07-24
One thing I would like to know is if there is posible to group services created by the user un a submenu. this way you could avoid clutter if you have many services for an espcific mime type
Re: Almost off topic - Alex - 2002-07-25
>but he's so damn cute as a penguin! i'm hoping that suit will fit him again this year, though i'm doubtful. hrm.. time to start thinking of something equally strange for this October ....... Will Konqui do? :-) or some BSD demon?
Re: Almost off topic - Zack Rusin - 2002-07-24
> The fact that you dressed your two year old son up as a penguin for halloween almost scares me. :) You should've seen me in one, I gotta admit I don't look as cute, but hell, I turn some heads on the streets in it. Aaron, don't know your wife, but tell her another vegan says hi :) How do you find the time to do everything you do? KC-KDE, tutorials and huge amounts of super high quality code. Mad props to you for what you do!
Exellent!! - Fredrik C - 2002-07-24
Been wondering about how to do right click actions in KDE, and all along it's been so easy :-) Will these articles go into the help system? They sure are useful.
Wow - Wheely - 2002-07-24
This was one of the most interesting bits of information I've read about KDE for a while. I thought I was going to be thinking up stranger and stranger things to do with servicemenus but found myself absorbed by the dcop scripting possibilities instead. Now I've tried using this dcop thing, it seems to me like it's the KDE killer app. People need to know about this stuff! Thanks for all the efforts Aaron and the rest of the KDE crowd. Regards
Re: Wow - Matthew Kay - 2002-07-25
Yeah, dcop is amazing. I've been using it in combination with lineak (http://lineak.sourceforge.net/) to enable me to use the "internet keys" on my logitech wireless keyboard. For instance, I can make the "Media" button popup my noatun playlist, and then when I press it again it hides itself! Dcop scripting sets KDE apart, IMHO. Do any other desktops have something like this?
Re: Wow - Aaron J. Seigo - 2002-07-25
i remember something vaguely about applescript, which also kicked serious scripting ass. at least at the time; it's been several years since i was in the mac world.
service-menu repository? - Sebastian Eichner - 2002-07-24
BTW: is there any central repository where common service-menus are collected? Would be a great thing for "wow, i always wanted to have this!"-scripts with small efforts but big effects...
Re: service-menu repository? - Aaron J. Seigo - 2002-07-24
not that i know of. you could always start one, though =) ... if people want to send me the servicemenus they come up with i'll make sure they get up on the web and categorized somewhere. if we do get a bunch of these together then we'll want a small manager interface for them (turning them on/off, installing new ones, etc) which shouldn't be difficult to do.
thanx - gunnar - 2002-07-24
very!! usefull article. i will try it out @ home today thanx. gunnar
Applying a menu option to all file mime types? - y0k0 - 2002-07-24
WOW ! Really nice article! I am currently working on a gpg frontend + was able to integrate it to konqueror, adding options to encrypt/decrypt files, but i have one question: I would like to have my Encrypt file action applied to all file mimetypes. Is there an easy way to do it ? Thanks a lot !
Re: Applying a menu option to all file mime types? - Aaron J. Seigo - 2002-07-24
ServiceTypes=allfiles it would be nice if one could also do things like image/*
Re: Applying a menu option to all file mime types? - Waldo Bastian - 2002-07-25
image/all might work.
Re: Applying a menu option to all file mime types? - Aaron J. Seigo - 2002-07-25
unfortunately no. i tried that. =(
Re: Applying a menu option to all file mime types? - Dawit A. - 2002-07-24
ServiceTypes=allfiles Dawit A.
How would you? - TCorbin - 2002-07-25
How would you write an action which brings the image up as an attachment in a kmail composer?
Re: How would you? - Aaron J. Seigo - 2002-07-25
/me opens up kdcop and explores for a few seconds this one looks promising: dcop kmail KMailIface openComposer to cc bcc subject body hidden messageFile attachURL i imagine you'd call it something like: dcop kmail KMailIface openComposer '' '' '' '' '' 0 '' %u this is completely untested but might get you on your way =)
Re: How would you? - TCorbin - 2002-07-25
THANK YOU! Not only for this helpful reply, but for all the great work you and the other kde folks are doing. I absolutely LOVE kde. I think kde lives up to the promise of the original mac. I haven't been so excited about computers in a long time. It's funny, but one of my favorite things about KDE is the file open/save dialog. Absolutely head and shoulders above anyone else's and it really makes a huge difference is eas of use. So anyway - thanks.
Re: How would you? - ronino - 2002-07-25
I tried your example, but it didn't work, so I checked it out with some file in a shell and I got "cannot handle datatype 'KURL'". How to pass a file using a url of that type?
Re: How would you? - Aaron J. Seigo - 2002-07-25
the current version of dcop apparently doesn't support KURL via the command line. =( i talked w/waldo about it on IRC today and he's fixed it. now that it is in CVS i suppose we can expect a dcop command line tool that does KURLs in the upcoming beta =)
further scripting : HTML changes with javascript - CPH - 2002-07-25
Hi, After seeing this article I started to play around with Konqueror a small bit and even though my javascript knowledge is next to non-existant I was able to do a few things ( obviously you need to fill in XXXX and YYYY ): #change the status bar dcop konqueror-XXXXX html-widgetYYYY evalJS 'window.status="xxxx"' #change the background color dcop konqueror-XXXXX html-widgetYYYY evalJS 'document.bgColor = "blue" #popping up an alert box dcop konqueror-XXXXX html-widgetYYYY evalJS "alert(\"my message\")" #disable javascript for this window dcop konqueror-XXXXX html-widgetYYYY setJScriptEnabled false #set the value of the email field in the form when you are #in the "Post Reply" e.g. http://dot.kde.org/1027447529/addPostingForm dcop konqueror-XXXXX html-widgetYYYY evalJS "document.forms[0].email.value=\"cph\"" With the above you could easily have a small piece of javascript to set the username and password on those sites where they do not use cookies (or where you do not trust them with cookies). To find out which konqueror html-widgetYYYY you should be using use: dcop konqueror-XXXXX html-widgetYYYY evalJS "document.title"
DCOP - MyIS - 2002-07-25
Hrmmm... This is all grand. Seriously, this rocks. But I am wondering if there is something like this for Gnome. It would be a good thing to make DCOP an independent thing (unless it is already and I am missing out on stuff) and make it work anywhere, KDE, Gnome, or a non-GUI environment. And it would be a good thing, arguably, to make DCOP interface less binary-dependent, maybe? KDE ownz!
Re: DCOP - Anonymous - 2002-07-25
> But I am wondering if there is something like this for Gnome. http://g-scripts.sourceforge.net/
Re: DCOP - Aaron J. Seigo - 2002-07-25
he's talking about scripting w/dcop (generic, desktop-wide scripting), not application specific hacks. looking over that page, however, i see some interesting things about Nautilus that i wasn't aware of, such as: you need scripts to open files in a given editor? (Konqi just uses mimtypes and offers an Open With-> menu) showing special file info is done with scripts? (Konqi provide kfilemetainfo, which are actual coded plugins, have their UI integrated w/Konqi and are available to all KDE apps ... hmmmm... perhaps that could be the another article: writing KFMI plugins?) how do you ensure a script is only available for a given mimetype (e.g. is hidden when it doesn't apply)? p.s. this isn't meant to bash nautilus at all, these are honest questions i have after reading that page.
Re: DCOP - MyIS - 2002-07-26
My point is that advanced IPC like DCOP should be separate from a particular desktop suite. Then, competition and natural selection is much more focused - I'd like to be able to pick best parts of all OSS offerings instead of having my choice limited to the two camps.
Re: DCOP - Aaron J. Seigo - 2002-07-27
the dcop library has bindings to several languages and has very few dependencies itself. AFAIK the only thing it requires is X11 and it's ICE auth mechanism. so pretty much anyone could use it if they were so inclined.
Re: DCOP - ac - 2002-07-26
What you are looking for is Bonobo... it combines the speed of DCOP with the scriptability of KParts.
Re: DCOP - ac - 2002-07-26
*LOL*
Changing other menus - Johan Veenstra - 2002-07-26
Is it possible to change for example the 'copy here/move here/link here' menu that pops up when you drag and drop a file to another directory? Johan Veenstra
Re: Changing other menus - David Faure - 2002-07-26
No, but that one is in kdebase/libkonq/konq_operations.cc, you can change it there ;) (what do you want to change about it?)
Re: Changing other menus - Melchior FRANZ - 2002-07-27
> what do you want to change about it? Disable it because it is bothersome? You almost always want to =move= files. A modifier that allows to copy instead for the very rare cases where you want just that would suffice. As it is now, it looks like newbie stuff that bothers experienced users. And, yes, I know that I can control the behavior by modifiers now.
Re: Changing other menus - David Emerson - 2004-10-12
It would be great to be able to change the "Link Here" behavior to make a hard link rather than a symlink (or maybe add another option) Assumably to make such a change, I'd have to change the source, and recompile. What kind of undertaking is this? I'll keep looking, but any links to konqueror compilation instructions would be great! ~David.
Re: Changing other menus - David Faure - 2004-10-12
(you're replying to a two-year-old thread, but nevermind :) http://developer.kde.org/source for how to get the latest sources and compile them. kdebase/libkonq/konq_operations.cc for where the symlink operation is called. You would have to special case local files and avoid calling KIO::symlink for them, and call link(2) instead. KIO has no support for hardlinks. Also note that the operation will fail across filesystems...
Service Menus and URLs - SD - 2002-07-27
Creating service menu entries for file types is very cool...great article. But here's a question for the KDE gurus. How do you create a service menu that pops up when you right click a URL? Is this even possible? Thanks SD
Splendid! - Maciek - 2002-07-28
Finally I can add menus like "Add to ZIP" or "Add to TGZ"!
Re: Splendid! - ayudame - 2003-08-31
Hello I found a comment of yours which leads me to beleive that you know how to add functions to the right mouse click in konqueror. PLEASE tell me how. Specifically i want to add the funcions: add to zip, create zip and the same for tgz. thanks a million for your help. Ayudame
It didn't work. - jp - 2002-07-29
I followed the steps. I've got RH7.3 unofficial install of v3.0.2-0unl. It has the ark desktop definition in /usr/share. But the directory didn't even exist in ~/.kde/. Is there some funky permission thing going on? My file is: [Desktop Entry] ServiceTypes=image/png,image/jpeg,image/gif Actions=setAsWallpaper;setAsTiledpaper [Desktop Action setAsWallpaper] Name=Set As Background Image Icon=background Exec=dcop kdesktop KBackgroundIface setWallpaper %u 6 [Desktop Action setAsTiledpaper] Name=Set As Tiled Background Image Icon=background Exec=dcop kdesktop KBackgroundIface setWallpaper %u 2 Also, the article said you can edit the file in place and it would automatically update the menu. But, I'm not seeing that happening. Thanks.
RCS - Andreas Henningsson - 2002-07-30
is it possible to use this function together with RCS. For example when i have worked with a file I only hace to right click on the file and press "New version" or something like that, write a description of the file and so on. ci -u %u would be the command that I want to run I guess but I also want to add a comment for the change in the file. Is there any solution for this? Feel free to mail me a solution /Andreas