dumon 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dumon/omanager.rb +16 -9
- data/lib/dumon/ui.rb +14 -3
- data/lib/dumon/version.rb +1 -0
- data/lib/dumon.rb +1 -1
- metadata +2 -2
data/lib/dumon/omanager.rb
CHANGED
@@ -31,11 +31,11 @@ module Dumon
|
|
31
31
|
# Mirrored outputs:
|
32
32
|
# {:mode=>:mirror, :resolution=>'1600x900'}
|
33
33
|
# Sequence of outputs:
|
34
|
-
# {:mode=>:
|
34
|
+
# {:mode=>:hsequence, :outs=>['VGA1', 'LVDS1'], :resolutions=>['1920x1080', '1600x900'], :primary=>:none}
|
35
35
|
def switch(options)
|
36
36
|
# pre-conditions
|
37
37
|
verify_options(options, {
|
38
|
-
:mode => [:single, :mirror, :
|
38
|
+
:mode => [:single, :mirror, :hsequence, :vsequence],
|
39
39
|
:out => :optional, :outs => :optional,
|
40
40
|
:resolution => :optional, :resolutions => :optional,
|
41
41
|
:primary => :optional
|
@@ -60,14 +60,16 @@ module Dumon
|
|
60
60
|
assert(v[:resolutions].include?(options[:resolution]), "unknown resolution: #{options[:resolution]}, output: #{k}")
|
61
61
|
end
|
62
62
|
mirror(options[:resolution])
|
63
|
-
when :
|
64
|
-
verify_options(options, {:mode => [:
|
63
|
+
when :hsequence, :vsequence
|
64
|
+
verify_options(options, {:mode => [:hsequence, :vsequence], :outs => :mandatory, :resolutions => :mandatory, :primary => :optional})
|
65
65
|
assert(options[:outs].is_a?(Array), 'parameter :outs has to be Array')
|
66
66
|
assert(options[:resolutions].is_a?(Array), 'parameter :resolutions has to be Array')
|
67
67
|
assert(options[:outs].size == options[:resolutions].size, 'size of :outs and :resolutions does not match')
|
68
68
|
assert(options[:outs].size > 1, 'sequence mode expects at least 2 outputs')
|
69
|
-
|
70
|
-
|
69
|
+
if !options[:primary].nil? and options[:primary].to_sym != :none
|
70
|
+
assert(outputs.keys.include?(options[:primary]), "unknown primary output: #{options[:primary]}")
|
71
|
+
end
|
72
|
+
sequence(options[:outs], options[:resolutions], options[:primary], :hsequence === options[:mode])
|
71
73
|
end
|
72
74
|
|
73
75
|
Dumon::App.instance.current_profile = options
|
@@ -130,7 +132,8 @@ module Dumon
|
|
130
132
|
# *param* outs in form ['VGA1', 'LVDS1']
|
131
133
|
# *resolutions* in form ['1920x1080', '1600x900']
|
132
134
|
# *param* primary name of primary output
|
133
|
-
|
135
|
+
# *param* horizontal whether horizontal linie of outputs
|
136
|
+
def sequence(outs, resolutions, primary=:none, horizontal=true)
|
134
137
|
raise NotImplementedError, 'this should be overridden by concrete sub-class'
|
135
138
|
end
|
136
139
|
|
@@ -224,7 +227,7 @@ module Dumon
|
|
224
227
|
`#{cmd}`
|
225
228
|
end
|
226
229
|
|
227
|
-
def sequence(outs, resolutions, primary=:none) #:nodoc:
|
230
|
+
def sequence(outs, resolutions, primary=:none, horizontal=true) #:nodoc:
|
228
231
|
cmd = "#{self.stool}"
|
229
232
|
for i in 0..outs.size - 1
|
230
233
|
output = outs[i]
|
@@ -232,7 +235,11 @@ module Dumon
|
|
232
235
|
resolution = self.default_resolution(output) if resolution.nil?
|
233
236
|
cmd << " --output #{output} --mode #{resolution}"
|
234
237
|
cmd << ' --primary' if primary.to_s == output
|
235
|
-
|
238
|
+
if horizontal
|
239
|
+
cmd << " --right-of #{outs[i - 1]}" if i > 0
|
240
|
+
else
|
241
|
+
cmd << " --below #{outs[i - 1]}" if i > 0
|
242
|
+
end
|
236
243
|
end
|
237
244
|
|
238
245
|
Dumon::logger.debug "Command: #{cmd}"
|
data/lib/dumon/ui.rb
CHANGED
@@ -201,15 +201,26 @@ module Dumon
|
|
201
201
|
o1 = outputs.keys[1]
|
202
202
|
item = Gtk::MenuItem.new("#{o0} left of #{o1}")
|
203
203
|
item.signal_connect('activate') do
|
204
|
-
omanager.switch({:mode=>:
|
204
|
+
omanager.switch({:mode=>:hsequence, :outs=>[o0, o1], :resolutions=>[@selected_resolution[o0], @selected_resolution[o1]], :primary=>@primary_output})
|
205
205
|
# clear preferred resolution, by next rendering will be read from real state
|
206
206
|
@selected_resolution.clear
|
207
207
|
end
|
208
208
|
rslt.append(item)
|
209
209
|
item = Gtk::MenuItem.new("#{o1} left of #{o0}")
|
210
210
|
item.signal_connect('activate') do
|
211
|
-
omanager.switch({:mode=>:
|
212
|
-
|
211
|
+
omanager.switch({:mode=>:hsequence, :outs=>[o1, o0], :resolutions=>[@selected_resolution[o1], @selected_resolution[o0]], :primary=>@primary_output})
|
212
|
+
@selected_resolution.clear
|
213
|
+
end
|
214
|
+
rslt.append(item)
|
215
|
+
item = Gtk::MenuItem.new("#{o0} above #{o1}")
|
216
|
+
item.signal_connect('activate') do
|
217
|
+
omanager.switch({:mode=>:vsequence, :outs=>[o0, o1], :resolutions=>[@selected_resolution[o0], @selected_resolution[o1]], :primary=>@primary_output})
|
218
|
+
@selected_resolution.clear
|
219
|
+
end
|
220
|
+
rslt.append(item)
|
221
|
+
item = Gtk::MenuItem.new("#{o1} above #{o0}")
|
222
|
+
item.signal_connect('activate') do
|
223
|
+
omanager.switch({:mode=>:vsequence, :outs=>[o1, o0], :resolutions=>[@selected_resolution[o1], @selected_resolution[o0]], :primary=>@primary_output})
|
213
224
|
@selected_resolution.clear
|
214
225
|
end
|
215
226
|
rslt.append(item)
|
data/lib/dumon/version.rb
CHANGED
@@ -2,6 +2,7 @@ module Dumon
|
|
2
2
|
|
3
3
|
# Version history.
|
4
4
|
VERSION_HISTORY = [
|
5
|
+
['0.2.2', '2013-03-15', 'Enh #6: Vertical location of outputs'],
|
5
6
|
['0.2.1', '2013-03-13', 'BF #9: Crash Ruby 1.8.7 because of Dir.home'],
|
6
7
|
['0.2.0', '2013-03-12', 'Enh #5: Profiles; File based configuration'],
|
7
8
|
['0.1.7', '2013-02-13', 'Enh #4: About dialog'],
|
data/lib/dumon.rb
CHANGED
@@ -70,7 +70,7 @@ module Dumon
|
|
70
70
|
|
71
71
|
# check and create directory structure
|
72
72
|
dirname = File.dirname filename
|
73
|
-
::FileUtils.mkdir_p(dirname) unless
|
73
|
+
::FileUtils.mkdir_p(dirname) unless File.exist?(dirname)
|
74
74
|
|
75
75
|
# create file if does not exist
|
76
76
|
File.open(filename, 'w').close unless File.exist? filename
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dumon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gtk2
|