dumon 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/bin/dumon +1 -1
- data/lib/dumon.rb +3 -3
- data/lib/dumon/omanager.rb +4 -2
- data/lib/dumon/ui.rb +30 -3
- data/lib/dumon/version.rb +1 -0
- metadata +2 -2
data/README.md
CHANGED
data/bin/dumon
CHANGED
data/lib/dumon.rb
CHANGED
@@ -23,8 +23,8 @@ module Dumon
|
|
23
23
|
|
24
24
|
###
|
25
25
|
# Runs the application.
|
26
|
-
def self.run
|
27
|
-
if
|
26
|
+
def self.run(daemon=false)
|
27
|
+
if daemon
|
28
28
|
if RUBY_VERSION < '1.9'
|
29
29
|
Dumon::logger.warn 'Daemon mode supported only in Ruby >= 1.9'
|
30
30
|
else
|
@@ -55,4 +55,4 @@ Dumon::logger.info \
|
|
55
55
|
|
56
56
|
# development
|
57
57
|
#Dumon::logger.level = Logger::DEBUG
|
58
|
-
#Dumon::run
|
58
|
+
#Dumon::run(ARGV[0] == '--daemon')
|
data/lib/dumon/omanager.rb
CHANGED
@@ -39,7 +39,8 @@ module Dumon
|
|
39
39
|
###
|
40
40
|
# Distributes output to given devices with given order and resolution.
|
41
41
|
# *param* outputs in form [["LVDS1", "1600x900"], [VGA1", "1920x1080"]]
|
42
|
-
|
42
|
+
# *param* primary name of primary output
|
43
|
+
def sequence(outputs, primary)
|
43
44
|
raise NotImplementedError, 'this should be overridden by concrete sub-class'
|
44
45
|
end
|
45
46
|
|
@@ -145,7 +146,7 @@ module Dumon
|
|
145
146
|
`#{cmd}`
|
146
147
|
end
|
147
148
|
|
148
|
-
def sequence(outputs) #:nodoc:
|
149
|
+
def sequence(outputs, primary=:none) #:nodoc:
|
149
150
|
raise 'not an array' unless outputs.kind_of?(Array)
|
150
151
|
outputs.each { |pair| raise 'item not a pair' if !pair.kind_of?(Array) and pair.size != 2 }
|
151
152
|
|
@@ -155,6 +156,7 @@ module Dumon
|
|
155
156
|
resolution = outputs[i][1]
|
156
157
|
resolution = self.default_resolution(output) if resolution.nil?
|
157
158
|
cmd << " --output #{output} --mode #{resolution}"
|
159
|
+
cmd << ' --primary' if primary.to_s == output
|
158
160
|
cmd << " --right-of #{outputs[i - 1][0]}" if i > 0
|
159
161
|
end
|
160
162
|
|
data/lib/dumon/ui.rb
CHANGED
@@ -59,6 +59,9 @@ module Dumon
|
|
59
59
|
# {"LVDS1" => "1600x900", "VGA1" => "800x600"}
|
60
60
|
@selected_resolution = {}
|
61
61
|
|
62
|
+
# primary output
|
63
|
+
@primary = :none
|
64
|
+
|
62
65
|
@tray = Gtk::StatusIcon.new
|
63
66
|
@tray.visible = true
|
64
67
|
@tray.pixbuf = Gdk::Pixbuf.new(::File.join(::File.dirname(__FILE__), '..', 'monitor.png'))
|
@@ -120,7 +123,7 @@ module Dumon
|
|
120
123
|
|
121
124
|
# mirror
|
122
125
|
item = Gtk::MenuItem.new('mirror')
|
123
|
-
if outputs.keys.size
|
126
|
+
if outputs.keys.size >= 2
|
124
127
|
submenu = Gtk::Menu.new
|
125
128
|
item.set_submenu(submenu)
|
126
129
|
else
|
@@ -134,20 +137,44 @@ module Dumon
|
|
134
137
|
end
|
135
138
|
rslt.append(item)
|
136
139
|
|
140
|
+
# separator
|
141
|
+
item = Gtk::SeparatorMenuItem.new
|
142
|
+
rslt.append(item)
|
143
|
+
|
144
|
+
# primary output
|
145
|
+
item = Gtk::MenuItem.new('primary output')
|
146
|
+
if outputs.keys.size >= 2
|
147
|
+
submenu = Gtk::Menu.new
|
148
|
+
item.set_submenu(submenu)
|
149
|
+
else
|
150
|
+
item.sensitive = false
|
151
|
+
end
|
152
|
+
|
153
|
+
radios = []
|
154
|
+
prims = outputs.keys.clone << :none
|
155
|
+
prims.each do |o|
|
156
|
+
si = Gtk::RadioMenuItem.new(radios, o.to_s)
|
157
|
+
si.active = (@primary.to_s == o.to_s)
|
158
|
+
radios << si
|
159
|
+
si.signal_connect('activate') { @primary = o.to_s if si.active? }
|
160
|
+
submenu.append(si)
|
161
|
+
end
|
162
|
+
rslt.append(item)
|
163
|
+
|
137
164
|
# sequence (currently supporting only 2 output devices)
|
138
165
|
if outputs.keys.size >= 2
|
139
166
|
o0 = outputs.keys[0]
|
140
167
|
o1 = outputs.keys[1]
|
141
168
|
item = Gtk::MenuItem.new("#{o0} left of #{o1}")
|
142
169
|
item.signal_connect('activate') do
|
143
|
-
self.omanager.sequence([[o0, @selected_resolution[o0]], [o1, @selected_resolution[o1]]])
|
170
|
+
self.omanager.sequence([[o0, @selected_resolution[o0]], [o1, @selected_resolution[o1]]], @primary)
|
144
171
|
# clear preferred resolution, by next rendering will be read from real state
|
145
172
|
@selected_resolution.clear
|
146
173
|
end
|
147
174
|
rslt.append(item)
|
148
175
|
item = Gtk::MenuItem.new("#{o1} left of #{o0}")
|
149
176
|
item.signal_connect('activate') do
|
150
|
-
self.omanager.sequence([[o1, @selected_resolution[o1]], [o0, @selected_resolution[o0]]])
|
177
|
+
self.omanager.sequence([[o1, @selected_resolution[o1]], [o0, @selected_resolution[o0]]], @primary)
|
151
178
|
# clear preferred resolution, by next rendering will be read from real state
|
152
179
|
@selected_resolution.clear
|
153
180
|
end
|
data/lib/dumon/version.rb
CHANGED
@@ -2,6 +2,7 @@ module Dumon
|
|
2
2
|
|
3
3
|
# Version history.
|
4
4
|
VERSION_HISTORY = [
|
5
|
+
['0.1.5', '2013-02-08', 'Enh #2: Support for primary output'],
|
5
6
|
['0.1.4', '2013-02-07', 'Enh #1: Starting as daemon'],
|
6
7
|
['0.1.3', '2013-02-03', 'Changed starting mechanism'],
|
7
8
|
['0.1.2', '2013-02-01', 'Refactoring: class name optimalization'],
|
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.1.
|
4
|
+
version: 0.1.5
|
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-02-
|
12
|
+
date: 2013-02-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gtk2
|