[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] launchy 0.1.2 Released

Jeremy Hinegardner

8/12/2007 6:51:00 AM

launchy version 0.1.2 has been released.

http://copiousfreetime.rubyforge.or...

Example:

Launchy.do_magic("http://www.rubyforge...)

or

Launchy::Spawnable::Browser.new.visit("http://www.ruby-lang....)

Launchy is helper class for launching cross-platform applications in a
fire and forget manner.

There are application concepts (browser, email client, etc) that are common
across all platforms, and they may be launched differently on each
platform. Launchy is here to make a common approach to launching
external application from within ruby programs.

{{ Changelog for Version 0.1.2 }}

=== Version 0.1.2 - 2007-08-11

* first publicly announced release
* make forked child exit without calling at_exit handlers

enjoy,

-jeremy

--
========================================================================
Jeremy Hinegardner jeremy@hinegardner.org


15 Answers

Trans

8/12/2007 9:31:00 AM

0



On Aug 11, 11:51 pm, Jeremy Hinegardner <jer...@hinegardner.org>
wrote:
> launchy version 0.1.2 has been released.
>
> http://copiousfreetime.rubyforge.or...
>
> Example:
>
> Launchy.do_magic("http://www.rubyforge...)
>
> or
>
> Launchy::Spawnable::Browser.new.visit("http://www.ruby-lang....)
>
> Launchy is helper class for launching cross-platform applications in a
> fire and forget manner.
>
> There are application concepts (browser, email client, etc) that are common
> across all platforms, and they may be launched differently on each
> platform. Launchy is here to make a common approach to launching
> external application from within ruby programs.
>
> {{ Changelog for Version 0.1.2 }}
>
> === Version 0.1.2 - 2007-08-11
>
> * first publicly announced release
> * make forked child exit without calling at_exit handlers
>
> enjoy,

Looks very interesting. I might use this on one of my projects. Some
thoughts/questions:

* This is clearly useful for launching a browser. (which is what I
could use it for). But will it really be useful for anything else?
Maybe I can see launching an email program, but I'm not even sure
about that.

* How does it deal with a systems that have more than one browser
installed? Which browser does it choose?

* What is Launchy::Specification for, how is it used?

* If I may make a suggestion... I think the API would be nicer if you
did without the Spawnable namespace. Just Launchy::Browser would be
much nicer.

Nice work!
T.


Sebastian Hungerecker

8/12/2007 9:54:00 AM

0

Trans wrote:
> On Aug 11, 11:51 pm, Jeremy Hinegardner wrote:

> > launchy version 0.1.2 has been released.
> >
> > Launchy is helper class for launching cross-platform applications in a
> > fire and forget manner.
>
> * How does it deal with a systems that have more than one browser
> installed? Which browser does it choose?

According to the documentation on the homepage:
APP_LIST = { :windows => %w[ firefox iexplore ], :darwin => %w[ open ],
:nix => %w[ firefox ], :unknown => [], }
So on OSX it uses the default browser and on any other system firefox, if
installed, or IE or nothing. I have to say, I find that somewhat suboptimal.
Certainly it's possible to detect the default browser on Windows, KDE and
GNOME, too, right? (Although, of course, it's still possible that someone
has neither KDE or GNOME installed or that he has both and is running neither,
which would make it hard to choose which default browser to use on *nix).


--
NP: Adema - Do What You Want To Do
Jabber: sepp2k@jabber.org
ICQ: 205544826

Olivier

8/12/2007 10:41:00 AM

0

Le dimanche 12 août 2007 11:53, Sebastian Hungerecker a écrit :
> Trans wrote:
> > On Aug 11, 11:51 pm, Jeremy Hinegardner wrote:
> > > launchy version 0.1.2 has been released.
> > >
> > > Launchy is helper class for launching cross-platform applications in a
> > > fire and forget manner.
> >
> > * How does it deal with a systems that have more than one browser
> > installed? Which browser does it choose?
>
> According to the documentation on the homepage:
> APP_LIST = { :windows => %w[ firefox iexplore ], :darwin => %w[ open ],
>
> :nix => %w[ firefox ], :unknown => [], }
>
> So on OSX it uses the default browser and on any other system firefox, if
> installed, or IE or nothing. I have to say, I find that somewhat
> suboptimal. Certainly it's possible to detect the default browser on
> Windows, KDE and GNOME, too, right? (Although, of course, it's still
> possible that someone has neither KDE or GNOME installed or that he has
> both and is running neither, which would make it hard to choose which
> default browser to use on *nix).

So, it won't work on my computer, since I run linux without firefox installed.
Under Windows, there is a default browser that can be set by the user, it
would be great to use this one, though I don't know how to get it. Maybe from
the registry ?
Under *nix, there is a BROWSER environement variable (but it is not often
correctly set, unfortunately).
Also, there should be Mozilla in the executable list, as the default after
firefox.
But the best for me would be that konqueror is used as the browser, with your
lib, since I run KDE. You can detect this from the env variable
DESKTOP_SESSION which is set to "kde".

--
Olivier Renaud

Detlef Reichl

8/12/2007 10:47:00 AM

0

Am Sonntag, den 12.08.2007, 19:41 +0900 schrieb Olivier Renaud:
> Le dimanche 12 août 2007 11:53, Sebastian Hungerecker a écrit :
> > Trans wrote:
> > > On Aug 11, 11:51 pm, Jeremy Hinegardner wrote:
> > > > launchy version 0.1.2 has been released.
> > > >
> > > > Launchy is helper class for launching cross-platform applications in a
> > > > fire and forget manner.
> > >
> > > * How does it deal with a systems that have more than one browser
> > > installed? Which browser does it choose?
> >
> > According to the documentation on the homepage:
> > APP_LIST = { :windows => %w[ firefox iexplore ], :darwin => %w[ open ],
> >
> > :nix => %w[ firefox ], :unknown => [], }
> >
> > So on OSX it uses the default browser and on any other system firefox, if
> > installed, or IE or nothing. I have to say, I find that somewhat
> > suboptimal. Certainly it's possible to detect the default browser on
> > Windows, KDE and GNOME, too, right? (Although, of course, it's still
> > possible that someone has neither KDE or GNOME installed or that he has
> > both and is running neither, which would make it hard to choose which
> > default browser to use on *nix).
>
> So, it won't work on my computer, since I run linux without firefox installed.
> Under Windows, there is a default browser that can be set by the user, it
> would be great to use this one, though I don't know how to get it. Maybe from
> the registry ?
> Under *nix, there is a BROWSER environement variable (but it is not often
> correctly set, unfortunately).
> Also, there should be Mozilla in the executable list, as the default after
> firefox.
> But the best for me would be that konqueror is used as the browser, with your
> lib, since I run KDE. You can detect this from the env variable
> DESKTOP_SESSION which is set to "kde".
>

Under GNOME the gconf key /desktop/gnome/url-handlers/http/command
contains the default browser.

Cheers
detlef


Olivier

8/12/2007 12:04:00 PM

0

> But the best for me would be that konqueror is used as the browser, with
> your lib, since I run KDE. You can detect this from the env variable
> DESKTOP_SESSION which is set to "kde".

I answer to myself :
DESKTOP_SESSION doesn't seem to be reliable, since its values are not standard
(and often is equal to "default").
So, maybe the best bet is to check the existence of KDE_SESSION_UID or
GNOME_SESSION_ID, to know which desktop is run, if any.

By the way, I was looking for the equivalent of OSX's "open" and
Windows' "start" under *nix. There is the command "xdg-open" from the
freedesktop project, which does just that. It's already on my system, maybe
it is already widely installed on systems that follow freedesktop guidelines.

--
Olivier Renaud

Daniel Schierbeck

8/12/2007 12:07:00 PM

0

On Sun, 2007-08-12 at 19:46 +0900, Detlef Reichl wrote:
> Am Sonntag, den 12.08.2007, 19:41 +0900 schrieb Olivier Renaud:
> > Le dimanche 12 août 2007 11:53, Sebastian Hungerecker a écrit :
> > > Trans wrote:
> > > > On Aug 11, 11:51 pm, Jeremy Hinegardner wrote:
> > > > > launchy version 0.1.2 has been released.
> > > > >
> > > > > Launchy is helper class for launching cross-platform applications in a
> > > > > fire and forget manner.
> > > >
> > > > * How does it deal with a systems that have more than one browser
> > > > installed? Which browser does it choose?
> > >
> > > According to the documentation on the homepage:
> > > APP_LIST = { :windows => %w[ firefox iexplore ], :darwin => %w[ open ],
> > >
> > > :nix => %w[ firefox ], :unknown => [], }
> > >
> > > So on OSX it uses the default browser and on any other system firefox, if
> > > installed, or IE or nothing. I have to say, I find that somewhat
> > > suboptimal. Certainly it's possible to detect the default browser on
> > > Windows, KDE and GNOME, too, right? (Although, of course, it's still
> > > possible that someone has neither KDE or GNOME installed or that he has
> > > both and is running neither, which would make it hard to choose which
> > > default browser to use on *nix).
> >
> > So, it won't work on my computer, since I run linux without firefox installed.
> > Under Windows, there is a default browser that can be set by the user, it
> > would be great to use this one, though I don't know how to get it. Maybe from
> > the registry ?
> > Under *nix, there is a BROWSER environement variable (but it is not often
> > correctly set, unfortunately).
> > Also, there should be Mozilla in the executable list, as the default after
> > firefox.
> > But the best for me would be that konqueror is used as the browser, with your
> > lib, since I run KDE. You can detect this from the env variable
> > DESKTOP_SESSION which is set to "kde".
> >
>
> Under GNOME the gconf key /desktop/gnome/url-handlers/http/command
> contains the default browser.

Calling gnome-open with the URL accomplishes the goal more easily.


Cheers,
Daniel Schierbeck

Trans

8/12/2007 1:14:00 PM

0



On Aug 12, 5:04 am, Olivier Renaud <o.ren...@laposte.net> wrote:
> > But the best for me would be that konqueror is used as the browser, with
> > your lib, since I run KDE. You can detect this from the env variable
> > DESKTOP_SESSION which is set to "kde".
>
> I answer to myself :
> DESKTOP_SESSION doesn't seem to be reliable, since its values are not standard
> (and often is equal to "default").
> So, maybe the best bet is to check the existence of KDE_SESSION_UID or
> GNOME_SESSION_ID, to know which desktop is run, if any.
>
> By the way, I was looking for the equivalent of OSX's "open" and
> Windows' "start" under *nix. There is the command "xdg-open" from the
> freedesktop project, which does just that. It's already on my system, maybe
> it is already widely installed on systems that follow freedesktop guidelines.

Interesting, but xdg-open opens Kate on my system.

T.


Jörg W Mittag

8/12/2007 2:22:00 PM

0

Olivier Renaud wrote:
> Le dimanche 12 août 2007 11:53, Sebastian Hungerecker a écrit :
>> Trans wrote:
>>> On Aug 11, 11:51 pm, Jeremy Hinegardner wrote:
>>>> launchy version 0.1.2 has been released.
>>>>
>>>> Launchy is helper class for launching cross-platform applications in a
>>>> fire and forget manner.
>>> * How does it deal with a systems that have more than one browser
>>> installed? Which browser does it choose?
>> According to the documentation on the homepage:
>> APP_LIST = { :windows => %w[ firefox iexplore ], :darwin => %w[ open ],
>> :nix => %w[ firefox ], :unknown => [], }
[...]
> So, it won't work on my computer, since I run linux without firefox installed.
> Under Windows, there is a default browser that can be set by the user, it
> would be great to use this one, though I don't know how to get it. Maybe from
> the registry ?

No need. Windows has had an equivalent to MacOS's 'open' since
Windows 95, I believe:

url = 'http://Ruby-Lang...
`start #{url}`

'start' will launch whatever application is registered to handle the
filetype (if the parameter is a file) or protocol (if the parameter is
a URI) in question -- in my case Opera.

So, just setting

Launchy::Spawnable::Browser::APP_LIST[:windows] = ['start']

*should* work, but, unfortunately, Launchy doesn't work for me at all,
so I can neither confirm nor deny that.

jwm

ara.t.howard

8/12/2007 2:40:00 PM

0


On Aug 12, 2007, at 12:51 AM, Jeremy Hinegardner wrote:

>
> Launchy is helper class for launching cross-platform applications in a
> fire and forget manner.
>

awesome!

a @ http://draw...
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama




ara.t.howard

8/12/2007 3:24:00 PM

0


On Aug 12, 2007, at 3:53 AM, Sebastian Hungerecker wrote:

>
> According to the documentation on the homepage:
> APP_LIST = { :windows => %w[ firefox iexplore ], :darwin => %w
> [ open ],
> :nix => %w[ firefox ], :unknown => [], }
> So on OSX it uses the default browser and on any other system
> firefox, if
> installed, or IE or nothing. I have to say, I find that somewhat
> suboptimal.
> Certainly it's possible to detect the default browser on Windows,
> KDE and
> GNOME, too, right? (Although, of course, it's still possible that
> someone
> has neither KDE or GNOME installed or that he has both and is
> running neither,
> which would make it hard to choose which default browser to use on
> *nix).
>

but no patch? ;-)

i think it's pretty simple on *nix

launchy_browser = ENV['LAUNCHY_BROWSER']

autocmds = %w[ htmlview ] ### and which ever others exist
for kde, etc

realcmds = %w[ firefox mozilla ] ### and some others


cmds = [ launchy_browser, autocmds, realcmds ].flatten.map{|cmd|
"( #{ cmd } >/dev/null 2>&1 )"}

cmd = cmds.join ' || '

system cmd

you could do some detection crap, but simply having a preferred list
of 'commands that find browsers' followed by a reasonable list of
browsers is going to work on 99% of *nix boxes. for everyone else
they can set an env var and all will be well. any unix user that
can't manage to set environment vars to make non-standard setups work
does deserve to surf the web anyhow ;-)

cheers.



a @ http://draw...
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama