Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Standard file open/app launch commands for Mac, Win, and X11

15 views
Skip to first unread message

Kevin Walzer

unread,
Apr 29, 2006, 11:29:27 AM4/29/06
to
I'm developing a list of platform-specific file open/application launch
commands for use in my Tcl programs. The idea is that these commands
invoke the platform-specific API for managing a user's default
applications for specific file extensions and mimetypes; Tcl can just
hand that task off to the system command.

Here's what I've got so far:

OS X: exec open myphoto.jpg; exec open http://wiki.tcl.tk

Windows: eval exec [auto_execok start] myphoto.jpg; eval exec
[auto_execok start] http://wiki.tcl.tk


Linux/Unix (Gnome): exec gnome-open myphoto.jpg; exec gnome-open
http://wiki.tcl.tk

Linux/Unix (KDE): exec "kfmclient exec myphoto.jpg"; exec "kfmclient
exec http://wiki.tcl.tk"

Linux/Unix (other): tk_getOpenFile ("Please choose the program to open
this file":)

Two questions:

1. Are these the right commands to use, particularly on Linux, or are
there others (kstart?).
2. Am I missing anything major from the X11 world, i.e. other desktop
environments that have an API/system command for launching applications?
If so, can anyone point me in the right direction?

Thanks.

--
Kevin Walzer
Poetic Code
http://www.kevin-walzer.com

Benjamin Riefenstahl

unread,
Apr 29, 2006, 12:39:04 PM4/29/06
to
Hi Kevin,


Kevin Walzer writes:
> Windows: eval exec [auto_execok start] myphoto.jpg; [...]

That should be

eval exec [auto_execok start] [list "" "my photo.jpg"]

a) You need a "" for the "title" argument to START (check out
START/?). Otherwise, when the first argument is quoted, START will
treat that as a title. And the filename will be quoted when it
contains spaces. This is on NT/W2K, I don't know about W9x/Me.

b) You need [list] to offset the [eval] when your you do a) and/or
when your filename contains spaces.

> eval exec [auto_execok start] http://wiki.tcl.tk

See also <http://wiki.tcl.tk/557>.

The easiest on Windows is probably to write or re-use a binary
extension that wraps the ShellExecute API, like the one on
e.g. <http://wiki.tcl.tk/13925>.

> Linux/Unix (Gnome): exec gnome-open myphoto.jpg; exec gnome-open
> http://wiki.tcl.tk
>
> Linux/Unix (KDE): exec "kfmclient exec myphoto.jpg"; exec "kfmclient
> exec http://wiki.tcl.tk"
>
> Linux/Unix (other): tk_getOpenFile ("Please choose the program to open
> this file":)

You might want to look at what the Portland project plans with their
"xdg-utils" <http://portland.freedesktop.org>. They cover the same
ground here.


benny

0 new messages