[NCLUG] gnome-open configuration or alternative

Chad Perrin perrin at apotheon.com
Wed Sep 5 11:16:23 MDT 2007


On Wed, Sep 05, 2007 at 06:19:57PM -0700, S Luke Jones wrote:
> Brett Johnson wrote:
> >I think most distros support the "update-alternatives" concept now.  For
> >your particular situation, you'd likely want to type:
> >
> >"sudo update-alternatives --config gnome-text-editor", and pick the text
> >editor you want gnome to use.  "sudo update-alternatives --all" will
> >take you through the whole list of alternatives (there are a lot).
> >
> >Also, in gnome, you can use nautilus (the gnome file browser) to set up
> >file opening preferences.  Simply open a directory with a .txt file
> >(from your "Places" menu), then right click on a .txt file.  Choose
> >"Properties" from the drop-down menu, and select the "Open With" tab.
> >
> >  
> Thanks, Brad. That's more information than I had before. I'm 100% 
> gnome-clueless. (Also KDE. The last window manager I learned how to 
> configure was fvwc.)
> 
> So I did this, as you suggest, and yes, I can see it's doing what I need 
> to have done. But so far as I can tell it doesn't provide a command line 
> interface to _use_ the data I just configured. It only sets up file 
> associations for the windowing system/file manager/desktop environment 
> to use.

If you're the scripting type, it shouldn't be too difficult to create
something to minimally suit your needs.  I imagine the file(1) utility
would be central to such a tool, and a simple plaintext flat file
database should do for configuration -- perhaps a series of tab-separated
lines indicating filetypes (matching the output of something like file
-bi filename).

For instance, running file(1) on a copy of the W9 form PDF I have on this
computer looks something like this:

  > file -bi fw9.pdf
  application/pdf

. . . while running it on a source code file looks more like this:

  > file -bi netstart.rb
  text/plain; charset=us-ascii

Some conditional stuff can be used to check for specific filename
extensions, of course, if you wish to have your script automatically run
interpreted code rather than opening it in a text editor, but I very
strongly recommend against that kind of behavior for security reasons.
I'll touch on that a little more, later in this email.


> 
> But.
> 
> That's my point. I don't care about the windowing system. I live inside 
> a terminal.

Join the club.  Well . . . except for Firefox, basically.


> 
> What I'm looking for is a single command-line tool (on the Mac it's 
> called "open") that is aware of this update-alternatives-kind of 
> database of filetype:application associations, and that lets me open the 
> different sorts of file from the command line with a single command. So 
> I don't type 'gv' or 'acroread' or 'gvim' or 'epiphany -some -weird 
> -options' but simply 'open' and the tool looks up those commands and 
> exec's them appropriately.
> 
> Is there anything like that in gnome? (Or better yet, 
> windowing-system-agnostic?)

There probably is, somewhere out there -- but I'll be surprised if anyone
knows of such a thing off the top of his/her head around here.  This
whole concept is sort of orthogonal (at least) to the philosophy of
unix-like operating systems, if not a touch antithetical to it.  If
something like that ends up in vogue in Linux circles, it's almost
certainly going to arise in something like the Ubuntu community.

Automagically picking an application to open a file is ubiquitous
behavior in the MS Windows world, and is to blame for a great many of its
security issues.  Malware writers and distributors rely on this sort of
behavior to get their malware running on victims' computers, as the more
automated the process of opening a file the less likely the user is to be
fully aware of what's running on the system and the potential security
risks associated with opening and executing files.

Obviously, there's nothing that specifically says setting a few file
associations will necessarily lead to the same security issues in your
case -- but it's something with which most of the Unix and Linux users
I've met would be profoundly uncomfortable, ignoring for the moment the
Linux "converts" who are mostly looking for a Windows-replacement rather
than a Unix-alike.

So . . . this was basically just a long-winded babble that might help
provide some understanding of why you haven't found such a thing yet.
It's all speculation on my part, of course, but it seems like a very
reasonable explanation based on my own experience.

-- 
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
awj @reddit: "The terms never and always are never always true."



More information about the NCLUG mailing list