launchy version 0.1.2 has been released.
http://copiousfreetime.rubyforge.org/launchy/
Example:
Launchy.do_magic("http://www.rubyforge.org")
or
Launchy::Spawnable::Browser.new.visit("http://www.ruby-lang.org/")
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
On Aug 11, 11:51 pm, Jeremy H. [email protected]
wrote:
Launchy::Spawnable::Browser.new.visit("http://www.ruby-lang.org/")
=== 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.
Trans wrote:
On Aug 11, 11:51 pm, Jeremy H. 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).
Le dimanche 12 août 2007 11:53, Sebastian H. a écrit :
According to the documentation on the homepage:
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”.
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.
On 8/12/07, Sebastian H. [email protected] wrote:
installed? Which browser does it choose?
neither,
which would make it hard to choose which default browser to use on *nix).
For windows at least you can use the same trick you use on OS X, that is
use
the start command instead of a particular browser. That’ll use their
default. For “*nix” it seems to me to be a lot more hairy, since distros
will all have their own ways to indicating the default browser. I think
Debian for instance has a symlink to the user’s default browser named
sensible-browser or similar.
–
Am Sonntag, den 12.08.2007, 19:41 +0900 schrieb Olivier R.:
both and is running neither, which would make it hard to choose which
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
On Aug 12, 5:04 am, Olivier R. [email protected] wrote:
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.
Olivier R. wrote:
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.Org/’
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
On Aug 12, 2007, at 12:51 AM, Jeremy H. wrote:
Launchy is helper class for launching cross-platform applications in a
fire and forget manner.
awesome!
a @ http://drawohara.com/
On Sun, 2007-08-12 at 19:46 +0900, Detlef R. wrote:
installed? Which browser does it choose?
possible that someone has neither KDE or GNOME installed or that he has
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 S.
On Aug 12, 2007, at 3:53 AM, Sebastian H. wrote:
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://drawohara.com/
On 8/12/07, ara.t.howard [email protected] wrote:
firefox, if
realcmds = %w[ firefox mozilla ] ### and some others
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 
I think this kind of defeats the purpose of Launchy though no? I
thought
the idea was to use the user’s preferred browser instead of “a browser”
w/o
needing to config it. By making them set an env var to get the right
browser, there’s really no point in using Launchy at all. Any nix ruby
script can easily query an env on it’s lonesome, or try a list of
possible
browsers, I thought (correct me if I am wrong) was that the point of
Launchy
was to do the “hard part” of detecting the user’s preferred browser.
cheers.
On Aug 12, 2007, at 9:30 AM, Logan C. wrote:
browsers, I thought (correct me if I am wrong) was that the point
of Launchy
was to do the “hard part” of detecting the user’s preferred browser.
the point of the environment var is for those cases when it cannot be
detected or, for example, debugging launchy itself - there is no
requirement to set it. letting users override stuff is the unix way
-
trying to make a reasonable guess in all other cases is the realm
of applications like launchy. always guessing correctly is a very
tall order: the ‘preferred’ browser on our sysad machines is ‘lynx’
because we do not run X, nevertheless we do use a browser for hitting
admin panels, etc. it’s unreasonable to expect a library to run in
such an environment. in any case i think a reasonable algorithm, in
order of degredation, is
-
use user provided default iff given
-
use a preferred list of browser guessers (htmlview, for example)
-
use a preferred list of browsers
-
prompt user for browser, cache answer for next time
2 cts.
a @ http://drawohara.com/
On Sun, Aug 12, 2007 at 11:30:04PM +0900, J?rg W Mittag wrote:
According to the documentation on the homepage:
should work, but, unfortunately, Launchy doesn’t work for me at all,
so I can neither confirm nor deny that.
Thanks for the info, I personally don’t have a windows machine to test
on so I was shooting from the hip here. I’ll change the windows
launching and have a new release out today.
enjoy,
-jeremy
On 8/12/07, ara.t.howard [email protected] wrote:
needing to config it. By making them set an env var to get the right
requirement to set it. letting users override stuff is the unix way
-
use a preferred list of browser guessers (htmlview, for example)
-
use a preferred list of browsers
-
prompt user for browser, cache answer for next time
I agree mostly. However a lib with a method named “do_magic” should try
very
hard to fulfill that implicit promise IMO. (And I don’t see why xdg-open
or
equivalent couldn’t invoke lynx.) Man, I sound whiny today 
2 cts.
On Sun, Aug 12, 2007 at 09:04:04PM +0900, Olivier R. wrote:
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.
Thanks for the tip, xdg-open looks like a good thing, I’ll incorporate
what I can.
Looks like there’s lots of good things in xdg-utils.
enjoy,
-jeremy
On Mon, Aug 13, 2007 at 01:19:06AM +0900, Logan C. wrote:
browser" w/o
detected or, for example, debugging launchy itself - there is no
-
use a preferred list of browser guessers (htmlview, for example)
-
use a preferred list of browsers
-
prompt user for browser, cache answer for next time
I agree mostly. However a lib with a method named “do_magic” should try very
hard to fulfill that implicit promise IMO. (And I don’t see why xdg-open or
equivalent couldn’t invoke lynx.) Man, I sound whiny today 
Yes that is my goal, part of this release was to get feedback on other
ways to do things. I don’t have ‘every’ system; so the feedback is
necessary for launchy to “do_magic”.
Great feedback all around guys, I appreciate it. I’ll put it all
together and have another release out today which will hopefully work
for even MORE users.
enjoy,
-jeremy
On Sun, Aug 12, 2007 at 06:31:00PM +0900, Trans wrote:
Launchy.do_magic("http://www.rubyforge.org")
platform. Launchy is here to make a common approach to launching
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.
I’m not sure either, I would like to add email programs for sure, other
applications, I don’t know, I’ll leave it open to be filled as there is
demand. Music players? Image viewers?
- How does it deal with a systems that have more than one browser
installed? Which browser does it choose?
I’m working on that, primarily it should use an ‘autocmd’ on each system
that can detect the preferred application on the system, then fall back
to reasonable defaults.
- What is Launchy::Specification for, how is it used?
I bootstrapped the development of Launchy with another project I’m
working on, rabal (http://copiousfreetime.rubyforge.org/rabal/).
Rabal generates directory structure, Rakefiles, some classes useful for
most applicaiton (version.rb, initial unit testing, license templates
etc.). specification.rb is a generated file from rabal and an instance
of the Launchy::Specification is in gemspec.rb. This instance is used by
the Rakefiles for project management and can be used from within the
application itself for displaying help, contact information etc.
Rabal could use some feedback so if your interested I would love to hear
what anyone thinks. It resembles hoe in some respects, but it made
to be extensible, so if you have your own directory/file templates you
can write in a plugin to manage them and rabal will pick them up and
incorporate them into the application.
- 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.
I’ll think about it.
Nice work!
T.
Thanks!
-jeremy