Assigning an action to a folder

So I'm trying to figure out how to add a menu to a single folder, kinda like the trashcan when it hits me. We have this .directory file in there. I wonder how hard it would be to add a service menu to that folder via the .directory file? We already use that file for icons...

I wonder how hard that would be since the .directory file is already parsed to get the icon. What if we parsed it to get a set of service menus too. Im thinking of a folder on my desktop that contains a menu entry to rsync the folder with my remote file store.
[Desktop Action sync]
Exec=rsync ... %d %u
Name=Sync to Server...

[Desktop Entry]

[IconPosition::kweather page.desktop]

hrm... yet another thing on my todo list :)


if you have many rsync directories, it might get a bit tedious adding it everywhere... how about adding an entry that lists which servicemenu entries are appropriate and have those pulled from a .desktop file in share/apps/konqueror/servicemenus? the servicemenu could have an unmatchable (or no) mimetype to avoid showing up in the right click menu. it would simply mean adding a check to the .directory file when sorting out the servicemenus in konq_popupmenu.cc ...

By Aaron J. Seigo at Wed, 07/23/2003 - 05:16

but that kind of operation would be not what im looking for. what i want is a special folder that has an operation. like MacOS 8 had with folder actions. You could attach an apple script to a folder. The goal is NOT to have a generic action for every folder but to have a special action for a special folder.

By Ian Reinhart Geiser at Wed, 07/23/2003 - 05:44

btw, i have a patch that does what you want now... it's got a couple other things in it, though, as my servicemenu TODO isn't finished. i'll post it to kfm-devel for C&C sometime tomorrow after i test it thoroughly when i can do so without seeing double... gah.. almost 3am...

By Aaron J. Seigo at Wed, 07/23/2003 - 08:51

Ill be waiting. It would be cool to access global services. But the main objective is I want to make things like the trashcan generic. Notice how it has an empty menu item? I have a few applicaitons where that would come in handy.

By Ian Reinhart Geiser at Wed, 07/23/2003 - 16:23

{rant}One thing I don't like about this Developer Journals is that it takes interesting discussions from the developers' mailing lists... :( Why can't these be simple readonly journals? Sigh...{/rant}

What I would like to see is kind of a transfer of the mime type system to dirs, supplied with some meta data attributes here and there. There could be dirs like "x-music folder" that are associated with that "music folder view" from above (with a nautilius like player bar) and "rsynced" as an attribute, both resulting to the same action mapping as with the file mime type system.

Only problem might be to tell what is an attribut and what is an object...

Just an unelaborated idea...

Friedrich Kossebau

By KDE User at Fri, 07/25/2003 - 15:50

You will notice that this discussion started here before it was on the list. It is now on the list, but after some ideas where fleshed out.

By KDE User at Fri, 07/25/2003 - 18:12

what i described wouldn't prevent what you are after. it would simply relocate where the script was located, allowing you to use the same special action for multiple folders. it could be easier to seperate the reference to the script and the script itself thus preventing you from rewriting the script for each directory that you want that action attached to. this wouldn't prevent you from having a script that is only referenced from one directory, of course.

downsides i can think of: when you delete the directory, the script doesn't go with it; you'd have to give your scripts unique names (not very hard, since they aren't user visible)

the [Desktop Entry]::Actions key would be the same, but the Desktop Action would be kept elsewhere. in fact, it would be trivial to allow both scenarios: Desktop Action in the .dekstop file, or failing that, looking through the servicemenus for the appropriate action (which are already examined anyways)...

By Aaron J. Seigo at Wed, 07/23/2003 - 06:07

This feature could add actual security caveats. Anybody could "duplicate" some part of the menu (like the cut & copy & paste), but with malicious actions (like installing a troyan, deleting files, etc...)... that only by putting a file in a folder. One example : someone could add a malicious .desktop file in a zip file of a program, and instruct the user to use the "install" option in the context menu of the folder.

I know, there is nothing that couldn't be made by other means, specially with this relaying in social enginery, but when an option seems to be provided by the desktop itself, chances are people will believe the action can't be malicious.

IMHO it would be better to add a "service" to the control panel that would permit the user to define some special options and actions, and attach them to some multiple files&folders. But I recognize the amount of development effort implicated in my approaches is far greater than in the original one.

By KDE User at Wed, 07/23/2003 - 08:30

No, these are menu actions. These dont happen automaticly.

By Ian Reinhart Geiser at Wed, 07/23/2003 - 16:22

yep, so attacker changes meaning of copy to delete, user selects "copy" and deletes file. no need for this to happen automatically.

By KDE User at Fri, 07/25/2003 - 13:58