Class: RMonitor::Profiles
Class Method Summary
collapse
best_matching_configuration, has_matching_configuration, invokable?, necessary_devices_present?, user_defined_rules_satisfied?
turn_off, turn_on
Class Method Details
.parse(config_data) ⇒ Object
11
12
13
14
15
|
# File 'lib/rmonitor/profiles.rb', line 11
def self.parse(config_data)
profile_builder = ProfileBuilder.new
profile_builder.instance_eval(config_data)
profile_builder.profiles
end
|
.to_xrandr(devices, profile) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/rmonitor/profiles.rb', line 17
def self.to_xrandr(devices, profile)
xrandr = 'xrandr'
to_disable = devices.select { |d| d[:enabled ]}.map { |d| d[:name] } -
profile[:devices].map { |d| d[:name] }
unless to_disable.empty?
to_disable.each do |name|
xrandr << ' ' << turn_off(name)
end
xrandr << ' && xrandr'
end
if profile[:options] and profile[:options][:dpi]
xrandr << ' --dpi ' << profile[:options][:dpi].to_s
end
profile[:devices].each do |wanted_device|
device = devices.find { |d| d[:name] == wanted_device[:name] }
configuration = best_matching_configuration(device,
wanted_device[:mode],
wanted_device[:rate])
xrandr << ' ' << turn_on(device[:name],
configuration.merge(wanted_device))
end
xrandr
end
|