0

I've been trying to make a program that lives in /usr/bin, and it currently works fine from the terminal (because every beginner tutorial teaches you how to use terminal commands) but it doesn't work when I try running it from the file manager.

I want to know what kind of command/data/whatever is sent by Nautilus/Caja/Dolphin/PCManFM when a file is double-clicked, or right-clicked and an "Open With" option is selected, and what a program in any language would need to do to get the path to the file it needs to manipulate from that. The only language I know how to do this in is BASH script, and BASH's syntax prevents me from searching for information about what my code does.

This subject in general is very hard to search for, so I'd appreciate any information about it.

EDIT: to clarify, when I click here:

picture of right-click menu

What data is sent to the program "bleh", and how should it use that data?

I shouldn't need to restate this...

Wegko
  • 369
  • 1
  • 2
  • 9

2 Answers2

2

Your application needs to come with a .desktop file, and these files are placed at a standardized location.

See the specification here: http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html and some explanation here: http://library.gnome.org/admin/system-admin-guide/stable/mimetypes-registering.html.en

What is particularly important to answer your question is the "Registering MIME-Types" section.

ypnos
  • 50,202
  • 14
  • 95
  • 141
  • 1
    What is that link to Phoronix? The Desktop Entry Specification is [here](http://freedesktop.org/wiki/Specifications/desktop-entry-spec). The [Desktop Menu Specification](http://freedesktop.org/wiki/Specifications/menu-spec) is useful too, and they both rely on the [Basedir](http://freedesktop.org/wiki/Specifications/basedir-spec) spec. – ephemient Aug 31 '12 at 23:13
  • It definitely requires no such thing. Please read the question. – Wegko Aug 31 '12 at 23:55
  • 1
    @Wegko Tt's definitely relevant. See `MimeType` and `%U` in the xdg specs. – ephemient Sep 01 '12 at 01:50
  • Sorry I pasted the wrong link. Link is fixed now and I added another one. It explains what you need. – ypnos Sep 01 '12 at 10:15
  • Read my answer; THAT's what I needed. – Wegko Sep 01 '12 at 14:47
0

Okay, I figured this out myself.

The name of the file that was right-clicked on is sent as an argument, and the working directory is set to the user's home.

My problem was caused by my program trying to work on two different targets simultaneously: the file name sent to it by the file manager, and my (irrelevant) home directory. I specified a new target directory myself and it works fine now.

EDIT: This might be specific to TCL. If that is the case, then I apologize for posting this question.

Wegko
  • 369
  • 1
  • 2
  • 9