launchy 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +7 -3
- data/lib/launchy/spawnable/application.rb +41 -19
- data/lib/launchy/spawnable/browser.rb +22 -29
- data/lib/launchy/version.rb +1 -1
- metadata +2 -2
data/CHANGES
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
-
==
|
1
|
+
== Changes
|
2
|
+
|
3
|
+
=== Version 0.2.1 - 2007-08-18
|
4
|
+
|
5
|
+
* fix inability to find windows executables [Bug #13132]
|
2
6
|
|
3
7
|
=== Version 0.2.0 - 2007-08-11
|
4
8
|
|
5
9
|
* rework browser finding
|
6
|
-
|
7
|
-
|
10
|
+
* manual override with LAUNCHY_BROWSER environment variable
|
11
|
+
* on *nix use desktop application launcher with fallback to list of browsers
|
8
12
|
* On windows, switch to 'start' command and remove dependency on win32-process
|
9
13
|
* removed win32 gem
|
10
14
|
* Add debug output by setting LAUNCHY_DEBUG environment variable to 'true'
|
@@ -27,25 +27,7 @@ module Launchy
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
# linux centric. The detection is based upon the detection used by xdg-open from
|
32
|
-
# http://portland.freedesktop.org/wiki/XdgUtils
|
33
|
-
def nix_desktop_environment
|
34
|
-
de = :generic
|
35
|
-
if ENV["KDE_FULL_SESSION"] || ENV["KDE_SESSION_UID"] then
|
36
|
-
de = :kde
|
37
|
-
elsif ENV["GNOME_DESKTOP_SESSION_ID"] then
|
38
|
-
de = :gnome
|
39
|
-
elsif find_executable("xprop") then
|
40
|
-
if %x[ xprop -root _DT_SAVE_MODE | grep ' = \"xfce\"$' ].strip.size > 0 then
|
41
|
-
de = :xfce
|
42
|
-
end
|
43
|
-
end
|
44
|
-
Launchy.log "nix_desktop_environment => #{de}"
|
45
|
-
return de
|
46
|
-
end
|
47
|
-
|
48
|
-
# find an executable in the available paths
|
30
|
+
# find an executable in the available paths
|
49
31
|
# mkrf did such a good job on this I had to borrow it.
|
50
32
|
def find_executable(bin,*paths)
|
51
33
|
paths = ENV['PATH'].split(File::PATH_SEPARATOR) if paths.empty?
|
@@ -90,6 +72,27 @@ module Launchy
|
|
90
72
|
end
|
91
73
|
end
|
92
74
|
end
|
75
|
+
|
76
|
+
|
77
|
+
# Determine the appropriate desktop environment for *nix machine. Currently this is
|
78
|
+
# linux centric. The detection is based upon the detection used by xdg-open from
|
79
|
+
# http://portland.freedesktop.org/wiki/XdgUtils
|
80
|
+
def nix_desktop_environment
|
81
|
+
if not @nix_desktop_environment then
|
82
|
+
@nix_desktop_environment = :generic
|
83
|
+
if ENV["KDE_FULL_SESSION"] || ENV["KDE_SESSION_UID"] then
|
84
|
+
@nix_desktop_environment = :kde
|
85
|
+
elsif ENV["GNOME_DESKTOP_SESSION_ID"] then
|
86
|
+
@nix_desktop_environment = :gnome
|
87
|
+
elsif find_executable("xprop") then
|
88
|
+
if %x[ xprop -root _DT_SAVE_MODE | grep ' = \"xfce\"$' ].strip.size > 0 then
|
89
|
+
@nix_desktop_environment = :xfce
|
90
|
+
end
|
91
|
+
end
|
92
|
+
Launchy.log "nix_desktop_environment => #{@nix_dekstop_environment}"
|
93
|
+
end
|
94
|
+
return @nix_desktop_environment
|
95
|
+
end
|
93
96
|
|
94
97
|
# find an executable in the available paths
|
95
98
|
def find_executable(bin,*paths)
|
@@ -106,6 +109,25 @@ module Launchy
|
|
106
109
|
Application.my_os_family(test_os)
|
107
110
|
end
|
108
111
|
|
112
|
+
# returns the list of command line application names for the current os. The list
|
113
|
+
# returned should only contain appliations or commands that actually exist on the
|
114
|
+
# system. The list members should have their full path to the executable.
|
115
|
+
def app_list
|
116
|
+
@app_list ||= self.send("#{my_os_family}_app_list")
|
117
|
+
end
|
118
|
+
|
119
|
+
# On darwin a good general default is the 'open' executable.
|
120
|
+
def darwin_app_list
|
121
|
+
Launchy.log "Using 'open' application on darwin."
|
122
|
+
[ find_executable('open') ]
|
123
|
+
end
|
124
|
+
|
125
|
+
# On windows a good general default is the 'start' Command Shell command
|
126
|
+
def windows_app_list
|
127
|
+
Launchy.log "Using 'start' command on windows."
|
128
|
+
%w[ start ]
|
129
|
+
end
|
130
|
+
|
109
131
|
# run the command
|
110
132
|
def run(cmd,*args)
|
111
133
|
args.unshift(cmd)
|
@@ -28,41 +28,32 @@ module Launchy
|
|
28
28
|
return false
|
29
29
|
end
|
30
30
|
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize
|
34
|
+
raise "Unable to find browser to launch for os family '#{my_os_family}'." unless browser
|
35
|
+
end
|
31
36
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
# Find a list of potential browser applications to run on *nix machines.
|
38
|
+
# The order is:
|
39
|
+
# 1) What is in ENV['LAUNCHY_BROWSER'] or ENV['BROWSER']
|
40
|
+
# 2) xdg-open
|
41
|
+
# 3) desktop environment launcher program
|
42
|
+
# 4) a list of fallback browsers
|
43
|
+
def nix_app_list
|
44
|
+
if not @nix_app_list then
|
39
45
|
browser_cmds = ['xdg-open']
|
40
46
|
browser_cmds << DESKTOP_ENVIRONMENT_BROWSER_LAUNCHERS[nix_desktop_environment]
|
41
47
|
browser_cmds << FALLBACK_BROWSERS
|
42
48
|
browser_cmds.flatten!
|
43
49
|
browser_cmds.delete_if { |b| b.nil? || (b.strip.size == 0) }
|
44
|
-
Launchy.log "*Nix Browser List: #{browser_cmds.join(', ')}"
|
45
|
-
browser_cmds
|
50
|
+
Launchy.log "Initial *Nix Browser List: #{browser_cmds.join(', ')}"
|
51
|
+
@nix_app_list = browser_cmds.collect { |bin| find_executable(bin) }.find_all { |x| not x.nil? }
|
52
|
+
Launchy.log "Filtered *Nix Browser List: #{@nix_app_list.join(', ')}"
|
46
53
|
end
|
47
|
-
|
54
|
+
@nix_app_list
|
48
55
|
end
|
49
|
-
|
50
|
-
APP_LIST = {
|
51
|
-
:windows => %w[ start ],
|
52
|
-
:darwin => %w[ open ],
|
53
|
-
:nix => nix_app_list,
|
54
|
-
:unknown => [],
|
55
|
-
}
|
56
|
-
|
57
|
-
def initialize
|
58
|
-
raise "Unable to find browser to launch for os family '#{my_os_family}'." unless browser
|
59
|
-
end
|
60
|
-
|
61
|
-
# returns the list of command line application names for the current os
|
62
|
-
def app_list
|
63
|
-
APP_LIST[my_os_family]
|
64
|
-
end
|
65
|
-
|
56
|
+
|
66
57
|
# return the full command line path to the browser or nil
|
67
58
|
def browser
|
68
59
|
if not @browser then
|
@@ -72,9 +63,11 @@ module Launchy
|
|
72
63
|
elsif ENV['BROWSER'] and File.exists?(ENV['BROWSER']) then
|
73
64
|
Launchy.log "Using BROWSER environment variable : #{ENV['BROWSER']}"
|
74
65
|
@browser = ENV['BROWSER']
|
75
|
-
|
76
|
-
@browser = app_list.
|
66
|
+
elsif app_list.size > 0 then
|
67
|
+
@browser = app_list.first
|
77
68
|
Launchy.log "Using application list : #{@browser}"
|
69
|
+
else
|
70
|
+
$stderr.puts "Unable to launch. No Browser application found."
|
78
71
|
end
|
79
72
|
end
|
80
73
|
return @browser
|
data/lib/launchy/version.rb
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: launchy
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date: 2007-08-
|
6
|
+
version: 0.2.1
|
7
|
+
date: 2007-08-18 00:00:00 -06:00
|
8
8
|
summary: A helper to launch apps from within ruby programs.
|
9
9
|
require_paths:
|
10
10
|
- lib
|