Bash: get name of selected item of the desktop

Is it possible to get the name of the selected item on the desktop using the right mouse button (file and path)?

My plan and idea is to run a script with the selected file.


“mogrify -normalize $selectedfile"
"mogrify -rotate 90 $selectedfile”

Greetings Lelldorin

Sounds like a perfect use case for TrackerScript, a TrackerAddon that will run a customized script on the selected items.
It use attribute to specify the script command.

See the recent discussion about Font Install traker add-on:

I think this is what you want:

hey Tracker get Selection of Poses of Window 0


Again I feel I’m missing something, but what’s wrong with drag&drop? Doesn’t a YAB app accept files dropped on either its icon or an open window? That’s how I specify files for almost everything I do.

yab does that just fine, I have used it in the past and am using it in my WebViewer app.

The Tracker add-on CopyNameToClipboard seems to be what lelldorin is looking for.

No i want to use it diectly and not to use another app to get the name and path.

Right click/menu option:imagemagick/flip image for example

On an open window, yes. You need to specify a specific view as the dropzone and then just keep looking for the appropriate message$ code in your main loop.

On the icon … Don’t know, I’ve never tried that, but peek$(“refsreceived”) might pick that up.

I does not want to make a second Imagemagick gui. I only want to make it possible to do fast image manipulation using the context menu. Imagemagick use a dropzone to open images.

Is this the correct string? I will take a look.

Give a look at TrackerScript. Should be easy to duplicate it with different script command and call it “Flip image”.
Don’t forget to set accepted MIME type to image/*, though.

[code]#include <Clipboard.h>
#include <Entry.h>
#include <Path.h>
#include <String.h>
#include <TrackerAddon.h>

void process_refs(entry_ref dir_ref, BMessage *msg, void *) {

BString ClipString;
 	BPath path; 

 	int refs;
 	entry_ref file_ref; 

for( refs=0; msg->FindRef(“refs”, refs, &file_ref)==B_NO_ERROR; refs++) {

 if (refs>0) ClipString.Append(" "); 

 BString FileString = filenameonly ? path.Leaf() : path.Path(); 
 bool quote = (FileString.FindFirst(" ") != B_ERROR ); 

 if (quote) ClipString.Append("\"").Append(FileString).Append("\""); 
 else ClipString.Append(FileString); 


commandline = new BString("mogrify -flip "+BEntry);

Will this be run?
How i can get the header files?

Using makefile-engine (copy skeleton Makefile from /boot/system/develop/etc/Makefile) it should be easy to build your code.

Some issues in your code:

  • last line is buggy, it’s not BEntry but ClipString you want to concatenate to the mogrify -flig string.
  • refs could be a directory too.