Class: Bandshell::ScreenControl

Inherits:
Object
  • Object
show all
Defined in:
lib/bandshell/screen_control.rb

Class Method Summary collapse

Class Method Details

.control_availabilityObject

Returns a boolean and an explanatory string indicating whether the screen can be controlled by DPMS.



47
48
49
# File 'lib/bandshell/screen_control.rb', line 47

def control_availability
  dpms_availability
end

.default_displayObject

Only used if no display is set already.



9
10
11
# File 'lib/bandshell/screen_control.rb', line 9

def default_display
  ":0"
end

.enforce_screen_state(state) ⇒ Object

Ensures that the display is in the specified state by enforcing each of a number of parameters, passed as the “state” hash. Valid keys:

:on => (boolean value: true for on, false for off)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/bandshell/screen_control.rb', line 17

def enforce_screen_state(state)
  if !state.is_a? Hash
    raise "enforce_screen_state: did not receive a hash!"
  end
  if state.has_key? :on
    if state[:on] == true
      force_screen_on unless screen_is_on? == true
    elsif state[:on] == false
      force_screen_off unless screen_is_on? == false
    else
      raise "enforce_screen_state: Invalid value for :on!"
    end
  end
end

.force_screen_offObject



36
37
38
# File 'lib/bandshell/screen_control.rb', line 36

def force_screen_off
  dpms_force_screen_off
end

.force_screen_onObject



32
33
34
# File 'lib/bandshell/screen_control.rb', line 32

def force_screen_on
  dpms_force_screen_on
end

.screen_is_on?Boolean

true, false, or unknown

Returns:

  • (Boolean)


41
42
43
# File 'lib/bandshell/screen_control.rb', line 41

def screen_is_on?
  dpms_screen_is_on?
end